Coder Social home page Coder Social logo

pksvv / chatrule Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rmanluo/chatrule

0.0 0.0 0.0 40.24 MB

Mining Logical Rules with Large Language Models for Knowledge Graph Reasoning with 1 dollar.

Home Page: https://arxiv.org/abs/2309.01538

License: MIT License

Shell 1.67% Python 98.33%

chatrule's Introduction

ChatRule

Mining Logical Rules with Large Language Models for Knowledge Graph Reasoning with 1 dollar.

Official Implementation of "ChatRule: Mining Logical Rules with Large Language Models for Knowledge Graph Reasoning".

Logical rules are essential for uncovering the logical connections between relations, which could improve reasoning performance and provide interpretable results on knowledge graphs (KGs). In this paper, we propose a novel framework, ChatRule, unleashing the power of large language models (LLMs) for mining logical rules over knowledge graphs with less than 1 dollar. The final rules can be used to conduct reasoning over KGs without additional model training.

Requirements

pip install -r requirements.txt

Set your OpenAI API key in .env file

Mining Rules with ChatRule

Please check examples of different datasets and LLMs in here.

  1. Sample Paths
python path_sampler.py --dataset ${DATASET} --max_path_len 3 --anchor 100 --cores 8
  1. Generate Rules
python chat_rule_generator.py --dataset ${DATASET} --model_name gpt-3.5-turbo -f 50 -l 10
  1. Collect and Clean Rules
python clean_rule.py --dataset ${DATASET} -p gpt-3.5-turbo --model none
  1. Rank Rules
python rank_rule.py --dataset ${DATASET} -p clean_rules/${DATASET}/gpt-3.5-turbo-top-0-f-50-l-10/none
  1. Evaluate Completion
python kg_completion.py --dataset ${DATASET} -p ranked_rules/${DATASET}/gpt-3.5-turbo-top-0-f-50-l-10/none/all

Reproduce KGC results with mined rules.

python kg_completion.py --dataset family -p FinalRules/family
python kg_completion.py --dataset umls -p FinalRules/umls
python kg_completion.py --dataset wn-18rr -p FinalRules/wn-18rr
python kg_completion.py --dataset yago -p FinalRules/yago

Results

Bibinfo

If you found this repo helpful, please help us by citing this paper:

@article{luo2023chatrule,
  title={Chatrule: Mining logical rules with large language models for knowledge graph reasoning},
  author={Luo, Linhao and Ju, Jiaxin and Xiong, Bo and Li, Yuan-Fang and Haffari, Gholamreza and Pan, Shirui},
  journal={arXiv preprint arXiv:2309.01538},
  year={2023}
}

Acknowledgement

The code of KGC reasoning in this work is mainly based on NCRL with a bug in ranking function fixed. We thank the authors for their great works.

chatrule's People

Contributors

rmanluo avatar rmanbio avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.