├── .gitignore ├── README.md ├── data ├── dev_data.json └── trn_data.json └── zhang2021namer.pdf /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CKBQA 2 | 3 | >**Update June 2nd, 2021**: add BibTex. 4 | 5 | >**Update May 6th, 2021**: our [paper](zhang2021namer.pdf) will appear at [NAACL 2021 System Demonstration track](https://www.aclweb.org/anthology/2021.naacl-demos.3/), please check it out for more details on data annotations and evaluations. 6 | 7 | ## Introduction 8 | 9 | This repository contains a Chinese KBQA dataset expanded from CCKS CKBQA Competition Dataset. We also provide a novel framework based on these additional annotations in a [paper](zhang2021namer.pdf), an online [demo](http://kbqademo.gstore.cn/) of such KBQA system is available, have fun checking it out! 10 | 11 | 12 | ## Citation & Trouble Shooting 13 | 14 | Please contact us via *{zhangminhao, ry_zhang}@pku.edu.cn* if you have any questions or kindly cite the following paper if you find this resource helpful. 15 | 16 | ``` 17 | @inproceedings{zhang-etal-2021-namer, 18 | title = "{NAMER}: A Node-Based Multitasking Framework for Multi-Hop Knowledge Base Question Answering", 19 | author = "Zhang, Minhao and 20 | Zhang, Ruoyu and 21 | Zou, Lei and 22 | Lin, Yinnian and 23 | Hu, Sen", 24 | booktitle = "Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies: Demonstrations", 25 | month = jun, 26 | year = "2021", 27 | address = "Online", 28 | publisher = "Association for Computational Linguistics", 29 | url = "https://www.aclweb.org/anthology/2021.naacl-demos.3", 30 | pages = "18--25", 31 | } 32 | ``` 33 | 34 | ## Data Format 35 | 36 | The validation dataset and training dataset are provided in this repository in json format. Each entry contains a question, its question id, its corresponding gold SPARQL, and the **struct** of the SPARQL. We define variable, entity, literal and type in SPARQL as **node**. The struct shows triples' **relation**s, the head and tail nodes of triples and their **mentions**, including start and end offsets. Besides, **filter** information is also contained in the struct. 37 | 38 | Here are two examples: 39 | 40 | **SPARQL:** select ?x where { <微软> <主要软件产品> ?x. } 41 | 42 | **Struct:** { 43 | "selected_variable": { 44 | "node": "?x", 45 | "type": "variable", 46 | "mention": { 47 | "start_offset": 7, 48 | "end_offset": 11, 49 | "natural_language": "软件产品" 50 | } 51 | }, 52 | "triple": [ 53 | { 54 | "head": { 55 | "node": "<微软>", 56 | "type": "entity", 57 | "mention": { 58 | "start_offset": 0, 59 | "end_offset": 4, 60 | "natural_language": "微软公司" 61 | } 62 | }, 63 | "relation": "<主要软件产品>", 64 | "tail": { 65 | "node": "?x", 66 | "type": "variable", 67 | "mention": { 68 | "start_offset": 7, 69 | "end_offset": 11, 70 | "natural_language": "软件产品" 71 | } 72 | } 73 | } 74 | ], 75 | "filter": [] 76 | } 77 | 78 | **SPARQL:** select ?y where { <最后的晚餐_(达·芬奇画作)> <作者> ?x. ?x <职业> ?z. ?y <职业> ?z. filter(?y!=?x). } 79 | 80 | **Struct:** { 81 | "selected_variable": { 82 | "node": "?y", 83 | "type": "variable", 84 | "mention": { 85 | "start_offset": 17, 86 | "end_offset": 18, 87 | "natural_language": "人" 88 | } 89 | }, 90 | "triple": [ 91 | { 92 | "head": { 93 | "node": "<最后的晚餐_(达·芬奇画作)>", 94 | "type": "entity", 95 | "mention": { 96 | "start_offset": 1, 97 | "end_offset": 8, 98 | "natural_language": "《最后的晚餐》" 99 | } 100 | }, 101 | "relation": "<作者>", 102 | "tail": { 103 | "node": "?x", 104 | "type": "variable", 105 | "mention": { 106 | "start_offset": 9, 107 | "end_offset": 11, 108 | "natural_language": "作者" 109 | } 110 | } 111 | }, 112 | { 113 | "head": { 114 | "node": "?x", 115 | "type": "variable", 116 | "mention": { 117 | "start_offset": 9, 118 | "end_offset": 11, 119 | "natural_language": "作者" 120 | } 121 | }, 122 | "relation": "<职业>", 123 | "tail": { 124 | "node": "?z", 125 | "type": "variable", 126 | "mention": { 127 | "start_offset": 14, 128 | "end_offset": 16, 129 | "natural_language": "职业" 130 | } 131 | } 132 | }, 133 | { 134 | "head": { 135 | "node": "?y", 136 | "type": "variable", 137 | "mention": { 138 | "start_offset": 17, 139 | "end_offset": 18, 140 | "natural_language": "人" 141 | } 142 | }, 143 | "relation": "<职业>", 144 | "tail": { 145 | "node": "?z", 146 | "type": "variable", 147 | "mention": { 148 | "start_offset": 14, 149 | "end_offset": 16, 150 | "natural_language": "职业" 151 | } 152 | } 153 | } 154 | ], 155 | "filter": [ 156 | "filter(?y!=?x)" 157 | ] 158 | } 159 | -------------------------------------------------------------------------------- /zhang2021namer.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ridiculouz/CKBQA/8a6bf2e7f225eb6d458131b7f2595e0f3ec4e2a4/zhang2021namer.pdf --------------------------------------------------------------------------------