← 开源
BaranziniLab

KG_RAG

Empower Large Language Models (LLM) using Knowledge Graph based Retrieval-Augmented Generation (KG-RAG) for knowledge intensive tasks

AI EngineeringGive agent knowledgeJupyter Notebook
在 GitHub 打开
增长势头
+024 小时新增 Star0.0%
946
Star
115
Fork
+0
本周
4
贡献者
创建于 2023-11-11 · 更新于 2026-10-11 · 今日第 12464 名
主要开发者
karthiksomannaminjarlor

BaranziniLab/KG_RAG 排名第 12,464,有 946 个星标。

同类别比较

BaranziniLab/KG_RAG 排名第 12,464,此处有 8 个同类条目;kaplanelad/shellfirm 排名第 12,467。

同类别比较
名称排名指标
ysc/cws_evaluation12,443
语言:
Lex
星标数:
950
分叉数:
341
简介:
Java开源项目cws_evaluation:中文分词器分词效果评估对比
Caho1/open-claude-ui12,444
语言:
TypeScript
星标数:
949
分叉数:
212
简介:
基于 REA 深度拆解并高保真还原 Claude 官方桌面端 UI。还原 30 个独立 React 组件与 8 项硬核交互物理算法,附带 3000+ 行逆向分析手册。
inngest/agent-kit12,458
语言:
TypeScript
星标数:
947
分叉数:
145
简介:
AgentKit: Build multi-agent networks in TypeScript with deterministic routing and rich tooling via MCP.
nullquant/ComfyUI-BrushNet12,460
语言:
Python
星标数:
947
分叉数:
53
简介:
ComfyUI BrushNet nodes
kaplanelad/shellfirm12,467
语言:
Rust
星标数:
946
分叉数:
33
简介:
Safety guardrails for ai coding agents and human terminal commands
Pipelex/pipelex12,470
语言:
Python
星标数:
945
分叉数:
78
简介:
Build AI methods with your coding agent, then run them anywhere: as an MCP for chatbots, as a webapp for people, or via API for your software.
CopilotKit/channels-sdk12,497
星标数:
941
分叉数:
63
简介:
The open-source SDK for bringing any agent into any chat platform: Slack, Microsoft Teams, Discord, Telegram - with native, Interactive UI.
Anarkh-Lee/universal-db-mcp12,502
语言:
TypeScript
星标数:
940
分叉数:
92
简介:
通用数据库 MCP 连接器:支持 MySQL、PostgreSQL、Oracle、MongoDB 等 17 种数据库,支持 Claude Desktop、Cursor、Windsurf、VS Code、ChatGPT 等 50+ 平台,用自然语言查询和分析数据
关键参数与规格
关键参数与规格
参数值
语言Jupyter Notebook
类别AI Engineering
子类别Give agent knowledge
关键词Biomedical, RAG
星标数946
分叉数115
贡献者4
创建日期2023-11-11
更新日期2026-10-11
1 天星标数0
7 天星标数0
排名12,464
上次排名12,392
排名变化-72
7 天星标排名13,438
上次 7 天星标排名13,449
7 天星标排名变化11
总星标排名11,636
上次总星标排名11,621
总星标排名变化-15
国家USA
README 摘录

Table of Contents What is KG-RAG Example use case of KG-RAG Prompting GPT without KG-RAG Prompting GPT with KG-RAG Example notebook for KG-RAG with GPT How to run KG-RAG Step 1: Clone the repo Step 2: Create a virtual environment Step 3: Install dependencies Step 4: Update config. yaml Step 5: Run the setup script Step 6: Run KG-RAG from your terminal Command line arguments for KG-RAG BiomixQA: Benchmark dataset Citation What

is KG-RAG? KG-RAG stands for Knowledge Graph-based Retrieval Augmented Generation. Start by watching the video of KG-RAG It is a task agnostic framework that combines the explicit knowledge of a Knowledge Graph (KG) with the implicit knowledge of a Large Language Model (LLM). Here, we utilize a massive biomedical KG called SPOKE as the provider for the biomedical context. SPOKE has incorporated over 40 biomedical knowledge repositories from diverse domains, each focusing on biomedical concept like

genes, proteins, drugs, compounds, diseases, and their established connections. SPOKE consists of more than 27 million nodes of 21 different types and 53 million edges of 55 types [Ref] The main feature of KG-RAG is that it extracts "prompt-aware context" from SPOKE KG, which is defined as: **the minimal context sufficient enough to respond to the user prompt. ** Hence, this framework empowers a general-purpose LLM by incorporating an optimized domain-specific 'prompt-aware context' from a biomedical

KG. Example use case of KG-RAG Following snippet shows the news from FDA website about the drug **"setmelanotide"** approved by FDA for weight management in patients with *Bardet-Biedl Syndrome* Ask GPT-4 about the above drug: WITHOUT KG-RAG *Note: This example was run using KG-RAG v0. We are prompting GPT from the terminal, NOT from the chatGPT browser. Temperature parameter is set to 0 for all the analysis. Refer this yaml file for parameter setting* WITH

KG-RAG *Note: This example was run using KG-RAG v0. Temperature parameter is set to 0 for all the analysis. Refer this yaml file for parameter setting* You can see that, KG-RAG was able to give the correct information about the FDA approved drug. How to run KG-RAG **Note: At the moment, KG-RAG is specifically designed for running prompts related to Diseases. We are actively working on improving its versatility. ** Step 1: Clone the repo Clone

this repository. All Biomedical data used in the paper are uploaded to this repository, hence you don't have to download that separately. Step 2: Create a virtual environment Note: Scripts in this repository were run using python 3. 9 Step 3: Install dependencies Step 4: Update config. yaml holds all the necessary information required to run the scripts in your machine. Make sure to populate this yaml file accordingly. Note: There is another yaml file called system_prompts. This is

already populated and it holds all the system prompts used in the KG-RAG framework. Step 5: Run the setup

常见问题

记录了多少星标和分叉?

BaranziniLab/KG_RAG 有 946 个星标和 115 个分叉。

仓库排名是多少?

BaranziniLab/KG_RAG 排名第 12,464。

记录的语言和类别是什么?

BaranziniLab/KG_RAG 有 946 个星标,语言为 Jupyter Notebook,类别为 AI Engineering。

哪个仓库排名最接近?

BaranziniLab/KG_RAG 与 kaplanelad/shellfirm 比较,后者排名第 12,467,有 946 个星标。

README

Table of Contents

What is KG-RAG

Example use case of KG-RAG

How to run KG-RAG

BiomixQA: Benchmark dataset

Citation

What is KG-RAG?

KG-RAG stands for Knowledge Graph-based Retrieval Augmented Generation.

Start by watching the video of KG-RAG

It is a task agnostic framework that combines the explicit knowledge of a Knowledge Graph (KG) with the implicit knowledge of a Large Language Model (LLM). Here is the arXiv preprint of the work.

Here, we utilize a massive biomedical KG called SPOKE as the provider for the biomedical context. SPOKE has incorporated over 40 biomedical knowledge repositories from diverse domains, each focusing on biomedical concept like genes, proteins, drugs, compounds, diseases, and their established connections. SPOKE consists of more than 27 million nodes of 21 different types and 53 million edges of 55 types [Ref]

The main feature of KG-RAG is that it extracts "prompt-aware context" from SPOKE KG, which is defined as:

the minimal context sufficient enough to respond to the user prompt.

Hence, this framework empowers a general-purpose LLM by incorporating an optimized domain-specific 'prompt-aware context' from a biomedical KG.

Example use case of KG-RAG

Following snippet shows the news from FDA website about the drug "setmelanotide" approved by FDA for weight management in patients with Bardet-Biedl Syndrome

Ask GPT-4 about the above drug:

WITHOUT KG-RAG

Note: This example was run using KG-RAG v0.3.0. We are prompting GPT from the terminal, NOT from the chatGPT browser. Temperature parameter is set to 0 for all the analysis. Refer this yaml file for parameter setting

WITH KG-RAG

Note: This example was run using KG-RAG v0.3.0. Temperature parameter is set to 0 for all the analysis. Refer this yaml file for parameter setting

You can see that, KG-RAG was able to give the correct information about the FDA approved drug.

How to run KG-RAG

Note: At the moment, KG-RAG is specifically designed for running prompts related to Diseases. We are actively working on improving its versatility.

Step 1: Clone the repo

Clone this repository. All Biomedical data used in the paper are uploaded to this repository, hence you don't have to download that separately.

Step 2: Create a virtual environment

Note: Scripts in this repository were run using python 3.10.9

conda create -n kg_rag python=3.10.9
conda activate kg_rag
cd KG_RAG

Step 3: Install dependencies

pip install -r requirements.txt

Step 4: Update config.yaml

config.yaml holds all the necessary information required to run the scripts in your machine. Make sure to populate this yaml file accordingly.

Note: There is another yaml file called system_prompts.yaml. This is already populated and it holds all the system prompts used in the KG-RAG framework.

Step 5: Run the setup script

Note: Make sure you are in KG_RAG folder

Setup script runs in an interactive fashion.

Running the setup script will:

  • create disease vector database for KG-RAG
  • download Llama model in your machine (optional, you can skip this and that is totally fine)
python -m kg_rag.run_setup

Step 6: Run KG-RAG from your terminal

Note: Make sure you are in KG_RAG folder

You can run KG-RAG using GPT and Llama model.

Using GPT

# GPT_API_TYPE='azure'
python -m kg_rag.rag_based_generation.GPT.text_generation -g 
# GPT_API_TYPE='openai'
python -m kg_rag.rag_based_generation.GPT.text_generation -g 

Example:

Note: The following example was run on AWS p3.8xlarge EC2 instance and using KG-RAG v0.3.0.

Using GPT interactive mode

This allows the user to go over each step of the process in an interactive fashion

# GPT_API_TYPE='azure'
python -m kg_rag.rag_based_generation.GPT.text_generation -i True -g 
# GPT_API_TYPE='openai'
python -m kg_rag.rag_based_generation.GPT.text_generation -i True -g 

Using Llama

Note: If you haven't downloaded Llama during setup step, then when you run the following, it may take sometime since it will download the model first.

python -m kg_rag.rag_based_generation.Llama.text_generation -m 

Example:

Note: The following example was run on AWS p3.8xlarge EC2 instance and using KG-RAG v0.3.0.

Using Llama interactive mode

This allows the user to go over each step of the process in an interactive fashion

python -m kg_rag.rag_based_generation.Llama.text_generation -i True -m 

Command line arguments for KG-RAG

Argument Default Value Definition Allowed Options Notes
-g gpt-35-turbo GPT model selection gpt models provided by OpenAI Use only for GPT models
-i False Flag for interactive mode (shows step-by-step) True or False Can be used for both GPT and Llama models
-e False Flag for showing evidence of association from the graph True or False Can be used for both GPT and Llama models
-m method-1 Which tokenizer method to use method-1 or method-2. method-1 uses 'AutoTokenizer' and method-2 uses 'LlamaTokenizer' and with an additional 'legacy' flag set to False while initiating the tokenizer Use only for Llama models

BiomixQA: Benchmark dataset

BiomixQA is a curated biomedical question-answering dataset utilized to validate KG-RAG framework across different LLMs. This consists of:

  • Multiple Choice Questions (MCQ)
  • True/False Questions

The diverse nature of questions in this dataset, spanning multiple choice and true/false formats, along with its coverage of various biomedical concepts, makes it particularly suitable to support research and development in biomedical natural language processing, knowledge graph reasoning, and question-answering systems.

This dataset is currently hosted in Hugging Face and you can find it here.

It’s easy to get started with BiomixQA—just three lines of Python to load the dataset:

from datasets import load_dataset

# For MCQ data
mcq_data = load_dataset("kg-rag/BiomixQA", "mcq")

# For True/False data
tf_data = load_dataset("kg-rag/BiomixQA", "true_false")

Citation

@article{soman2023biomedical,
  title={Biomedical knowledge graph-enhanced prompt generation for large language models},
  author={Soman, Karthik and Rose, Peter W and Morris, John H and Akbas, Rabia E and Smith, Brett and Peetoom, Braian and Villouta-Reyes, Catalina and Cerono, Gabriel and Shi, Yongmei and Rizk-Jackson, Angela and others},
  journal={arXiv preprint arXiv:2311.17330},
  year={2023}
}
排名相邻
同类项目