MCPcopy Index your code
hub / github.com/DataArcTech/ToG

github.com/DataArcTech/ToG @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
144 symbols 448 edges 25 files 11 documented · 8%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

ToG

The code for paper: "Think-on-Graph: Deep and Responsible Reasoning of Large Language Model on Knowledge Graph".

The original repo for ToG is Here.

News!

Our paper is accepted by ICLR 2024 🥳🥳🥳.

Here is the illustration of ToG:

image

The pipeline of ToG:

image

Project Structure

  • requirements.txt: Pip environment file.
  • data/: Evaluation datasets. See data/README.md for details.
  • CoT/: CoT methods. See CoT/README.md for details.
  • eval/: Evaluation script. See eval/README.md for details.
  • Freebase/: Freebase environment setting. See Freebase/README.md for details.
  • Wikidata/: Wikidata environment setting. See Wikidata/README.md for details.
  • tools/: Common tools used in ToG. See tools/README.md for details.
  • ToG/: Source codes.
  • client.py: Pre-defined Wikidata APIs, copy from Wikidata/.
  • server_urls.txt: Wikidata server urls, copy from Wikidata/.
  • main_freebase.py: The main file of ToG where Freebase as KG source. See README.md for details.
  • main_wiki.py: Same as above but using Wikidata as KG source. See README.md for details.
  • prompt_list.py: The prompts for the ToG to pruning, reasoning and generating.
  • freebase_func.py: All the functions used in main_freebase.py.
  • wiki_func.py: All the functions used in main_wiki.py.
  • utils.py: All the functions used in ToG.

Get started

Before running ToG, please ensure that you have successfully installed either Freebase or Wikidata on your local machine. The comprehensive installation instructions and necessary configuration details can be found in the README.md file located within the respective folder.

The required libraries for running ToG can be found in requirements.txt.

When using the Wikidata service, copy the client.py and server_urls.txt files from the Wikidata directory into the ToG folder.

How to run

See ToG/ README.md

How to eval

Upon obtaining the result file, such as ToG_cwq.jsonl, you should using the jsonl2json.py script from the tools directory to convert the ToG_cwq.jsonl to ToG_cwq.json. Then, evaluate using the script in the eval folder (see README.md in eval folder).

How to cite

If you interested or inspired by this work, you can cite us by:

@misc{sun2023thinkongraph,
      title={Think-on-Graph: Deep and Responsible Reasoning of Large Language Model with Knowledge Graph}, 
      author={Jiashuo Sun and Chengjin Xu and Lumingyuan Tang and Saizhuo Wang and Chen Lin and Yeyun Gong and Heung-Yeung Shum and Jian Guo},
      year={2023},
      eprint={2307.07697},
      archivePrefix={arXiv},
      primaryClass={cs.CL}
}

Experiment:

image

Application:

image

Claims

This project uses the Apache 2.0 protocol. The project assumes no legal responsibility for any of the model's output and will not be held liable for any damages that may result from the use of the resources and output.

FYI

We are looking for self-motivated interns at IDEA (Shenzhen). If you are interested in the topics of LLMs and KGs, please send us your resume by email. Our email address is xuchengjin@idea.edu.cn

Core symbols most depended-on inside this repo

get_batch_files
called by 11
Wikidata/simple_wikidata_db/db_deploy/utils.py
query_all
called by 10
ToG/client.py
run_llm
called by 9
ToG/utils.py
save_2_jsonl
called by 8
ToG/utils.py
half_stop
called by 6
ToG/wiki_func.py
jsonl_generator
called by 5
Wikidata/simple_wikidata_db/db_deploy/utils.py
write
called by 5
Wikidata/simple_wikidata_db/preprocess_utils/writer_process.py
generate_without_explored_paths
called by 4
ToG/utils.py

Shape

Function 86
Method 47
Class 11

Languages

Python100%

Modules by API surface

ToG/freebase_func.py19 symbols
ToG/client.py17 symbols
Wikidata/simple_wikidata_db/db_deploy/server.py16 symbols
Wikidata/simple_wikidata_db/db_deploy/client.py16 symbols
ToG/wiki_func.py16 symbols
ToG/utils.py15 symbols
Wikidata/simple_wikidata_db/preprocess_utils/writer_process.py9 symbols
eval/utils.py8 symbols
Wikidata/simple_wikidata_db/db_deploy/utils.py7 symbols
Wikidata/simple_wikidata_db/db_deploy/build_index.py6 symbols
Wikidata/simple_wikidata_db/utils.py5 symbols
Wikidata/simple_wikidata_db/preprocess_utils/worker_process.py3 symbols

For agents

$ claude mcp add ToG \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact