{"id":13754279,"url":"https://github.com/nju-websoft/SPARQA","last_synced_at":"2025-05-09T22:31:47.686Z","repository":{"id":37663403,"uuid":"222273678","full_name":"nju-websoft/SPARQA","owner":"nju-websoft","description":"SPARQA: Skeleton-based Semantic Parsing for Complex Questions over Knowledge Bases (AAAI 2020)","archived":false,"fork":false,"pushed_at":"2023-05-22T21:39:42.000Z","size":45424,"stargazers_count":69,"open_issues_count":15,"forks_count":10,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-11-16T07:33:18.114Z","etag":null,"topics":["kbqa","qa","semantic-parsing"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nju-websoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-11-17T16:00:32.000Z","updated_at":"2024-09-25T06:53:04.000Z","dependencies_parsed_at":"2024-08-03T09:17:18.462Z","dependency_job_id":null,"html_url":"https://github.com/nju-websoft/SPARQA","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nju-websoft%2FSPARQA","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nju-websoft%2FSPARQA/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nju-websoft%2FSPARQA/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nju-websoft%2FSPARQA/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nju-websoft","download_url":"https://codeload.github.com/nju-websoft/SPARQA/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253335751,"owners_count":21892727,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["kbqa","qa","semantic-parsing"],"created_at":"2024-08-03T09:01:52.978Z","updated_at":"2025-05-09T22:31:42.666Z","avatar_url":"https://github.com/nju-websoft.png","language":"Python","funding_links":[],"categories":["知识图谱问答KBQA、多跳推理","Paper"],"sub_categories":["其他_文本生成、文本对话","KBQA"],"readme":"# SPARQA: question answering over knowledge bases\n\nCodes for paper: \"SPARQA: Skeleton-based Semantic Parsing for Complex Questions over Knowledge Bases\" (AAAI-2020) [detail](https://aaai.org/ojs/index.php/AAAI/article/view/6426).\nIf you meet any questions, please email to him (ywsun at smail.nju.edu.cn). \n\n**Note that SPARQA is updated to SkeletonKBQA. If you are interested in SkeletonKBQA, please see [here](https://github.com/nju-websoft/SkeletonKBQA).**\n\n## Project Structure:\n\n\u003ctable\u003e\n    \u003ctr\u003e\n        \u003cth\u003eFile\u003c/th\u003e\u003cth\u003eDescription\u003c/th\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003ecode\u003c/td\u003e\u003ctd\u003ecodes\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eskeleton\u003c/td\u003e\u003ctd\u003eskeleton bank\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eslides\u003c/td\u003e\u003ctd\u003eslides and poster\u003c/td\u003e\n    \u003c/tr\u003e\n\u003c/table\u003e\n \n## Requirements\n* [requirements.txt](https://github.com/nju-websoft/SPARQA/blob/master/code/requirements.txt)\n\n## Configuration\n* Root of dataset: default D:/dataset. Note that you can edit it in common/globals_args.py. \n\n**Note that the following files are in baidu wangpan. The extraction code of all files is kbqa.**\n\n## Common Resources\n* [Eight Resources](https://pan.baidu.com/s/1__BBXhEvUuRfqdurofHooQ): GloVe (glove.6B.300d), Stanford CoreNLP server, SUTime Java library, BERT pre-trained Models, and four preprocessing files(stopwords.txt, ordinal_fengli.tsv, unimportantphrase, and unimportantwords). unzip and save in the root.\n* Two version Freebase: [latest version](https://pan.baidu.com/s/1CCxljj_yH9S3Y4Zeh6epmw) and [2013 version](https://pan.baidu.com/s/1FWwv1R_7JtO_mpk_6pL_TQ). Next, download a virtuoso server and load the KBs. You can also download the KBs from [freebase site](https://developers.google.com/freebase). The [file](http://ws.nju.edu.cn/blog/2017/03/virtuoso%E5%AE%89%E8%A3%85%E5%92%8C%E5%AF%BC%E5%85%A5%E6%95%B0%E6%8D%AE/) is helpful, if you meet questions.\n\n## Specific CWQ 1.1 Resources\n* [CWQ 1.1 dataset](https://pan.baidu.com/s/1N_WBCmoQIvNCk_W4oFHeKA): skeleton parsing models, word-level scorer model, sentence-level scorer model. unzip and save in the root.\n* [Lexicons](https://pan.baidu.com/s/146e7C4LCrNiQJp6urZU_ZQ): entity-related lexicons and KB schema-related lexicons. unzip and save in the root.\n\n## Specific GraphQuestions Resources\n* [GraphQuestions dataset](https://pan.baidu.com/s/106vC73W9WKXyuuFcaoPIuQ): Skeleton Parsing models, Word-level scorer model. unzip and save in the root.\n* [Lexicons](https://pan.baidu.com/s/1VfF7O0TDRCKiZxqxRpQ8fQ): Entity-related Lexicons and KB schema-related lexicons. unzip and save in the root.\n\n## Run SPARQA Pipeline\nThe pipeline has two steps for answering questions: \n\n* (1) KB-indenpendent graph-structured ungrounded query generation.\n* (2) KB-dependent graph-structure grounded query generation and ranking.\n\nSee running/freebase/pipeline_cwq.py if run CWQ 1.1.\nSee running/freebase/pipeline_grapqh.py if run GraphQuestions.\nBelow, an example on GraphQuestions.\n\n**Note that the steps are not friendly. To understand easliy, we provided samples of these steps in the output_graphq folder.**\n\n### Specific-dataset Configuration\n\n* Set datset in the common/globals_args.py: q_mode=graphq. (note that q_mode=cwq if CWQ 1.1)\n* Set skeleton parsing in the common/globals_args.py: parser_mode=head, which means skeleton parsing. (note that parser_mode=dep, which means dependency parsing).\n* Replace the freebase_pyodbc_info and freebase_sparql_html_info in the common/globals_args.py with your local address. (note that 2013 version is for GraphQuestions, and latest version is for CWQ 1.1).\n\n### KB-indenpendent query generation\n* Run KB-indenpendent query generation. Setup variable module=1.0. The input: dataset. The output: structure with 1.0 ungrounded graph. We provided sample in output_graphq folder.\n\n### KB-dependent query generation\n* Generate variant generation. Set variable module=2.1. The input: structure with 1.0 ungrounded graph. The output: structure with 2.1 grounded graph. We provided sample in output_graphq folder.\n* Ground candidate queries. Set module=2.2. The input: structure with 2.1 grounded graph. The output: structure with 2.2 grounded graphs. We provided samples of questions in output_graphq folder. [one sample](https://github.com/nju-websoft/SPARQA/blob/master/slides/274000300.json).\n* Rank using word-level scorer. Set module=2.3_word_match. The input: 2.2 grounded graphs.\n* Combine sentence-level scorer and word-level scorer. Set module=2.3_add_question_match. The input: 2.2 grounded graphs.\n* Run evaluation. Set module=3_evaluation. The input: 2.2 grounded graphs. The output: result. \n\n## Skeleton Parsing\n* SPARQA also provides a tool of parsing. The input is a question. The output is the skeleton of the question. (Now, it only supports English language. Later, it will support Chinese language)\n* You can use SPARQA's skeleton parsing to train yourself language. (It need replace the pre-trained models and annotated data with your language)\n\n## Multi-Strategy Scoring\n* SPARQA has provided a trained word-level scorer model and sentence-level scorer in dataset folder.\n\n## Oracle Grounded Graph\n* We provide the code of offline ways, [oracle graphs of CWQ 1.1](https://pan.baidu.com/s/11138yi_oe3TaV9NiuL6pVQ) and [oracle graphs of GraphQuestions](https://pan.baidu.com/s/1DAcCX2ic-eFYptn3FeEWbg). The way first retrieve oracle graphs (to reduce storage space) and then generate candidate queries from oracle graphs. About oracle graph, please see [this paper](https://www.aclweb.org/anthology/Q16-1010.pdf).\n* We can also provide the code of online ways. The way is to generate candidate queries online. The problem is efficiency issue.\n\n## Compare with Baselines\n* GraphQuestions: PARA4QA, SCANNER, UDEPLAMBDA.\n* CWQ 1.1: PullNet, SPLITQA, and MHQA-GRN. Note that PullNet used annotated topic entities of questions in its KB only setting. SPARQA, an end-to-end method, do not use annotated topic entities. Thus, it is not comparable.\n\n## Citation\n\n\t@inproceedings{SunZ0Q20,\n\t  author    = {Yawei Sun and Lingling Zhang and Gong Cheng and Yuzhong Qu},\n\t  title     = {{SPARQA:} Skeleton-Based Semantic Parsing for Complex Questions over Knowledge Bases},\n\t  booktitle = {The Thirty-Fourth {AAAI} Conference on Artificial Intelligence, {AAAI} 2020, The Thirty-Second Innovative Applications of Artificial Intelligence Conference, {IAAI} 2020, The Tenth {AAAI} Symposium on Educational Advances in Artificial Intelligence, {EAAI} 2020, New York, NY, USA, February 7-12, 2020},\n\t  pages     = {8952--8959},\n\t  publisher = {{AAAI} Press},\n\t  year      = {2020},\n\t  url       = {https://aaai.org/ojs/index.php/AAAI/article/view/6426},\n\t}\n\n## Contacts\nIf you have any difficulty or questions in running codes, reproducing experimental results, and skeleton parsing, please email to him (ywsun at smail.nju.edu.cn).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnju-websoft%2FSPARQA","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnju-websoft%2FSPARQA","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnju-websoft%2FSPARQA/lists"}