Language Version: English | ไธญๆ
LTRAG (Logic-enhanced Text Retrieval Augmented Generation) is a logic reasoning-based text retrieval augmented generation framework specifically designed for handling complex logical reasoning tasks.
- LTRAG
The LTRAG framework combines Retrieval Augmented Generation (RAG) technology with logical reasoning capabilities, aiming to improve the performance of large language models on complex logical reasoning tasks. The framework supports two main logical reasoning datasets:
- FOLIO: First-Order Logic reasoning dataset
- AR-LSAT: Law School Admission Test logical reasoning questions
Knowledge base data for AR-LSAT and FOLIO are stored in the dataset_example folder:
FOLIO-fix.csv: Fixed version of the FOLIO datasetFOLIO-translation.csv: Translated version of the FOLIO datasetLSAT-fix.csv: Fixed version of the LSAT datasetLSAT-translation.csv: Translated version of the LSAT dataset
Note: Due to historical reasons, the two frameworks are not completely unified
Environment Requirements: Python 3.12
Code Location: FOLIO_framework folder
Main Features:
- Symbolic logic reasoning
- Error correction mechanism
- Multiple reasoning mode support
Core Files:
run_symbol.py: Symbolic logic reasoning (without correction)run_errfix.py: Error correction based on symbolic reasoningrun_cot.py: Chain-of-thought reasoningrun_standard.py: Standard reasoning mode
Environment Requirements: Python 3.12
Code Location: LSAT_framework folder
run_symbol.py: Symbolic logical reasoning (controls whether to apply fixes via the parameterFIX_FLAG)run_cot.py: Chain-of-thought reasoning (distinguishes between CoT and standard reasoning by modifying parts of the CoT prompt)
- Python 3.12+
- Dependencies listed in
FOLIO_framework/requirements.txtandLSAT_framework/requirements.txt
- Clone the repository:
git clone <repository-url>
cd LTRAG- Install dependencies:
cd FOLIO_framework
pip install -r requirements.txtLSAT_framework is similar to the above.
First, you need to construct a FastGPT knowledge base, then configure it in FOLIO_framework/config/config.yaml:
fastgpt:
url: "https://your-fastgpt-url"
key: "fastgpt-your-api-key"Configure various model API keys in config.yaml:
sf: # SiliconFlow
api_key: "sk-your-api-key"
base_url: "https://api.siliconflow.cn/v1"
qdd: # QDD
api_key: "sk-your-api-key"
base_url: "https://35.aigcbest.top/v1"
deepseek: # DeepSeek
api_key: "sk-your-api-key"
base_url: "https://api.deepseek.com"Set the corresponding knowledge base ID in the agent configuration:
agent:
symbol:
kb_id: "your-knowledge-base-id"For LSAT, the above operations are performed in config.ini.
- Symbolic Logic Reasoning (without correction):
cd FOLIO_framework
python run_symbol.py- Reasoning with Error Correction:
cd FOLIO_framework
python run_errfix.py- Chain-of-Thought Reasoning:
cd FOLIO_framework
python run_cot.py- Standard Reasoning Mode:
cd FOLIO_framework
python run_standard.py- Symbolic Reasoning (controlled by setting the value of
FIX_FLAG; set toTrueto apply fixes):
cd LSAT_framework
python run_symbol.py- Chain-of-Thought Reasoning (set the CoT prompt in
llm/agent/cot.pyto enable CoT reasoning; removing the CoT portion results in standard reasoning):
cd LSAT_framework
python run_cot.pyLTRAG/
โโโ FOLIO_framework/ # FOLIO framework main directory
โ โโโ config/ # Configuration files
โ โ โโโ config.yaml # Main configuration file
โ โ โโโ Settings.py # Configuration loader
โ โโโ data/ # Data directory
โ โโโ llm/ # Large language model related
โ โ โโโ agent/ # Agent implementations
โ โ โโโ prompt/ # Prompt templates
โ โโโ utils/ # Utility functions
โ โโโ validator/ # Validator modules
โ โโโ requirements.txt # Python dependencies
โ โโโ run_*.py # Run scripts
โโโ LSAT_framework/ # Main directory of the LSAT framework
โ โโโ data/ # Data directory
โ โโโ llm/ # Related to large language models
โ โ โโโ agent/ # Agent implementation
โ โ โโโ base/ # Base model configuration
โ โ โโโ AgentBase.py # General model configuration
โ โโโ utils/ # Utility functions, including solvers
โ โโโ config.ini # Configuration file
โ โโโ requirements.txt # Python dependencies
โ โโโ run_*.py # Execution scripts
โโโ dataset_example/ # Example datasets
โโโ README.md # English documentation
โโโ README_CN.md # Chinese documentation
โโโ LICENSE # License file
This project is licensed under the corresponding open source license. See the LICENSE file for details.