Skip to content

πŸŽ‰ Repo For My Undergrad Final Year Project "Course Q&A System Based on Fusion of Large Language Models(LLMs) With Knowledge Graphs"

License

Notifications You must be signed in to change notification settings

XavierXinchi/LivCourse-ChatBot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

57 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

LivCourse-ChatBot

πŸ‡¨πŸ‡³Chinese | 🌐English | ❓Issues

GitHub version os GitHub last commit

πŸ“ Introduction

LivCourse-ChatBot ia a chatbot about the University of Liverpool courses based on a fusion of knowledge graphs (KG) and large language models (LLMs). It combines the advantages of LLMs and KGs to answer both generic and domain-specific questions, such as information about course modules at the University of Liverpool.

πŸ’‘The following image shows the chatbot demo after deployment.

πŸ’« Features

  • Memory-based: The model can understant the context of the use's questions
  • Domain-specific: The model can answer specific questions about the couse information of the University of Liverpool
  • Scalable: Developers can add additional personalized corpus for the model learning

The following image shows the structure of the model:

In the first module, the large language model will combine the user's original question with the historical dialog to produce a processed question.

In the second module, the processed question will be sent to the Agent, which will generate a chain of thoughts to determine which category the question belongs to, and hand it over to the function of the corresponding category to generate the final answer.

  • Generic_func: For answering questions in generalized areas of knowledge, such as greetings.
  • Retrival_func: For answering questions from additional corpus, e.g. campus gym information in this project.
  • Graph_func: For answering questions about the nodes and relationships stored in the graph database neo4j, such as University of Liverpool courses, degrees, modules, etc.
  • Search_func: For answering questions through a search engine (Google) when other functions don't generate the correct answers.

πŸ› οΈ Quick Start

1. Install dependencies

Create a virtual conda environment, activate it and install the packages:

conda create -n LivCourse python=3.9
conda activate LivCourse
pip install -r requirements.txt

2. Setup the neo4j graph database

Apply for your OpenAI API key in its website.

Go to .env file, and set your OPENAI_API_KEY, NEO4J_URI, and NEO4J_PASSWORD.

Run the following codes to generate the knowledge graphs in your neo4j database:

python gen_kg.py

3. Use LangSmith to monitor the application (Optional)

Go to LangSmith website to apply for your API key and create a project called LivCourse-ChatBot. Configure environment to connect to LangSmith.

export LANGCHAIN_TRACING_V2=true
export LANGCHAIN_ENDPOINT="https://api.smith.langchain.com"
export LANGCHAIN_API_KEY="<your langchain smith api>"
export LANGCHAIN_PROJECT="LivCourse-ChatBot"

4. Run the chatbot demo

python app.py

The file structure is look like this

.
β”œβ”€β”€ LICENSE
β”œβ”€β”€ README.md
β”œβ”€β”€ __pycache__
β”‚Β Β  β”œβ”€β”€ agent.cpython-39.pyc
β”‚Β Β  β”œβ”€β”€ config.cpython-39.pyc
β”‚Β Β  β”œβ”€β”€ prompt.cpython-39.pyc
β”‚Β Β  β”œβ”€β”€ service.cpython-39.pyc
β”‚Β Β  └── utils.cpython-39.pyc
β”œβ”€β”€ agent.py
β”œβ”€β”€ app.py
β”œβ”€β”€ config.py
β”œβ”€β”€ data
β”‚Β Β  └── db
β”‚Β Β      β”œβ”€β”€ chroma.sqlite3
β”‚Β Β      └── f4e6c6f1-3933-4325-b4d3-51ea2dceec57
β”‚Β Β          β”œβ”€β”€ data_level0.bin
β”‚Β Β          β”œβ”€β”€ header.bin
β”‚Β Β          β”œβ”€β”€ length.bin
β”‚Β Β          └── link_lists.bin
β”œβ”€β”€ data_process.py
β”œβ”€β”€ dataset
β”‚Β Β  └── dataset.json
β”œβ”€β”€ gen_kg.py
β”œβ”€β”€ img
β”‚Β Β  β”œβ”€β”€ demo.png
β”‚Β Β  β”œβ”€β”€ diagram.png
β”‚Β Β  └── diagram.svg
β”œβ”€β”€ inputs
β”‚Β Β  └── gym.txt
β”œβ”€β”€ prompt.py
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ service.py
└── utils.py

⚠️ Disclaimer

This project-related resources are for academic research only, strictly prohibited for commercial use. When using parts involving third-party code, please strictly follow the corresponding open source agreement. For any content of the model output, this project does not assume any legal responsibility, and does not assume responsibility for any loss that may arise from the use of related resources and output results.

🌟 Support

If you like this project, please don't forget to star✨ this repository.

About

πŸŽ‰ Repo For My Undergrad Final Year Project "Course Q&A System Based on Fusion of Large Language Models(LLMs) With Knowledge Graphs"

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages