jinlong22 / NeSyGPT

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NeSyGPT: A Unified Neural-Symbolic Framework for Structured Knowledge Querying with Large Language Model


🌈 Model Architecture

πŸ“• Dependencies

pip install -r requirements.txt

πŸ’‘ Quick start

NOTE: Please write the API key in api_key.txt before running the code. And the api_key.txt file should have the same number of keys as num_process. The default num_process in the following shell script is 5.

# WikiSQL
>> bash scripts/wikisql/wikisql_gpt3.5.sh
>> bash scripts/wikisql/wikisql_gpt4.sh

# WTQ
>> bash scripts/WTQ/WTQ_gpt3.5.sh
>> bash scripts/WTQ/WTQ_gpt4.sh

# MetaQA
>> bash scripts/MetaQA/metaqa_1hop.sh
>> bash scripts/MetaQA/metaqa_2hop.sh
>> bash scripts/MetaQA/metaqa_3hop.sh

# WebQSP
>> bash scripts/WQSP/wqsp3.5/WQSP_overall_gpt3.5.sh
>> bash scripts/WQSP/wqsp4/WQSP_overall_gpt4.sh

# CronQuestion
>> bash scripts/CronQuestion/CronQuestion_gpt3.5.sh
>> bash scripts/CronQuestion/CronQuestion_gpt4.sh

πŸ“š Code path

πŸ‘ˆ πŸ”Ž Click
root
β”œβ”€β”€ dataset
β”œβ”€β”€ evaluate
β”œβ”€β”€ output
β”œβ”€β”€ scripts
β”œβ”€β”€ structllm
β”‚   └── prompt_
β”œβ”€β”€ api_key.txt
β”œβ”€β”€ CGdata_for_CronQuestion.py
β”œβ”€β”€ CGdata_for_KGQA.py
β”œβ”€β”€ CGdata_for_tableqa.py
└── CGdata_for_WQSP.py

Data Path

❗NOTE: The data we provide is the data after conversion to CGdata.

πŸ‘ˆ πŸ”Ž Click
dataset
  β”œβ”€β”€ CronQuestion_CG
  β”‚   β”œβ”€β”€ kg_test.txt
  β”‚   β”œβ”€β”€ kg.txt
  β”‚   β”œβ”€β”€ qa_test.jsonl
  β”‚   └── qa_valid.jsonl
  β”œβ”€β”€ MetaQA_CG
  β”œβ”€β”€ WikiSQL_CG
  β”œβ”€β”€ WikiSQL_TB_csv
  β”œβ”€β”€ WQSP
  β”œβ”€β”€ WTQ
  └── deal_raw.py

Evaluate Path

πŸ‘ˆ πŸ”Ž Click
evaluate
  β”œβ”€β”€ evaluate_for_CronQuestion.py
  β”œβ”€β”€ evaluate_for_metaqa.py
  β”œβ”€β”€ evaluate_for_tableqa.py
  └── evaluate_for_wqsp.py

Prompt Path

πŸ‘ˆ πŸ”Ž Click
prompt_
   β”œβ”€β”€ MetaQA
   β”‚   β”œβ”€β”€ 1hop.json
   β”‚   β”œβ”€β”€ 2hop.json
   β”‚   └── 3hop.json
   β”œβ”€β”€ WQSP
   β”‚   β”œβ”€β”€ WQSP_name.json
   β”‚   └── WQSP_unname.json
   β”œβ”€β”€ CronQuestion.json
   β”œβ”€β”€ wikisql.json
   └── WTQ.json

🎯 Results

Result on TableQA dataset

Result on KGQA dataset

Result on CronQuestion dataset

About


Languages

Language:Python 95.7%Language:Shell 4.3%