Instructions to use Edaizi/KG-TRACES with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Edaizi/KG-TRACES with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Edaizi/KG-TRACES") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Edaizi/KG-TRACES") model = AutoModelForCausalLM.from_pretrained("Edaizi/KG-TRACES") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use Edaizi/KG-TRACES with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Edaizi/KG-TRACES" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Edaizi/KG-TRACES", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Edaizi/KG-TRACES
- SGLang
How to use Edaizi/KG-TRACES with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Edaizi/KG-TRACES" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Edaizi/KG-TRACES", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Edaizi/KG-TRACES" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Edaizi/KG-TRACES", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Edaizi/KG-TRACES with Docker Model Runner:
docker model run hf.co/Edaizi/KG-TRACES
β¨ KG-TRACES: Unleashing Explainable Reasoning in LLMs with Knowledge Graphs β¨
This repository contains the official implementation of KG-TRACES, a novel framework that enhances the reasoning ability of Large Language Models (LLMs) through explicit supervision over reasoning paths and processes. KG-TRACES aims to provide explainable, accurate, and traceable reasoning by leveraging the power of Knowledge Graphs.
For more details, refer to the accompanying paper: KG-TRACES: Enhancing Large Language Models with Knowledge Graph-constrained Trajectory Reasoning and Attribution Supervision
The full codebase and more information can be found on the official GitHub repository: https://github.com/Edaizi/KG-TRACES
π‘ Our Solution: KG-TRACES
KG-TRACES is a novel framework that explicitly teaches LLMs how to reason by supervising their internal "thought process" with knowledge graphs guidance. We guide them to:
- πΊοΈ Chart the Course: Predict symbolic knowledge graph reasoning paths from question to answer.
- π Show Their Work: Generate attribution-aware reasoning explanations, clearly claim whether each step comes from the KG or the LLM's internal knowledge π§ , and how effective it was!
π Why KG-TRACES Rocks
- π Crystal-Clear Explanations: Understand why the LLM reached its conclusion.
- π‘οΈ Trustworthy & Attributable: Know the evidence source of each reasoning step.
- πͺ Robust Performance: Excels even with limited or no direct KG access during inference.
- π Versatile: Shows strong generalization to specialized fields like medicine.
π Quickstart: Pretrained Models
You can easily load our fine-tuned KG-TRACES models from the Hugging Face Model Hub using the transformers library:
from transformers import AutoModelForCausalLM, AutoTokenizer
model_hub_name = "Edaizi/KG-TRACES"
tokenizer = AutoTokenizer.from_pretrained(model_hub_name)
model = AutoModelForCausalLM.from_pretrained(model_hub_name)
π Datasets
We've meticulously prepared augmented SFT datasets for WebQSP and CWQ, packed with reasoning paths and augmented reasoning processes with source attributions. Find them on Hugging Face:
You can load these datasets as follows:
from datasets import load_dataset
webqsp_sft_data = load_dataset("Edaizi/KG-TRACES-WebQSP")
cwq_sft_data = load_dataset("Edaizi/KG-TRACES-CWQ")
π Citation
If KG-TRACES helps your research or project, we'd love a shout-out! Please cite:
@misc{wu2025kgtracesenhancinglargelanguage,
title={KG-TRACES: Enhancing Large Language Models with Knowledge Graph-constrained Trajectory Reasoning and Attribution Supervision},
author={Rong Wu and Pinlong Cai and Jianbiao Mei and Licheng Wen and Tao Hu and Xuemeng Yang and Daocheng Fu and Botian Shi},
year={2025},
eprint={2506.00783},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2506.00783},
}
- Downloads last month
- 3