DeepChain is a Python-based pipeline that applies a three-stage refinement process to LLM outputs (using gemma2:9b via Ollama). By combining chain-of-thought prompting, context-aware improvements, and fact‐checking, it produces more accurate and in-depth answers from a compact model.
-
Three-Stage Refinement Pipeline
- Basic Analysis: Generates an initial (“naive”) response to your prompt.
- Contextual Refinement: Adds context, performs intent analysis, and fact-checks the initial output.
- Final Synthesis: Integrates and cross-validates information from earlier stages into a polished, comprehensive answer.
-
Hallucination Reduction
Intermediate checks and cross-validation between stages reduce misinformation and incorrect facts. -
Easy Setup & Lightweight
Just Python 3.8+ + Ollama + gemma2:9b. No heavyweight frameworks are required. -
Simple, Clear Code
All core logic lives in a singlesrc/main.py
, making it easy to understand and extend.
In this example, the user sends the ambiguous query "How many disks does Madonna have?". Through DeepChain's refinement process, the system demonstrates how a small Gemma2:9B model is enhanced with multi-stage reasoning capabilities. The system showcases improved analytical performance by providing a comprehensive answer that categorizes Madonna's discography into studio albums, live recordings, and compilations. The answer includes key information about her most significant releases, offering the appropriate context for a complete answer to the query - all achieved by applying refinement techniques to a relatively compact 9B parameter model that wouldn't typically exhibit such sophisticated reasoning on its own.
- Clone and Install
git clone https://github.com/KazKozDev/deepchain-refinement.git
cd deepchain-refinement
pip install -r requirements.txt
- Run the Pipeline
python src/main.py --prompt "How many discs does Madonna have?"
- Ensure Python 3.8+ is installed.
- Install Ollama and confirm it is running locally.
- Clone this repository:
git clone https://github.com/KazKozDev/deepchain-refinement.git
cd deepchain-refinement
- Install Python dependencies:
pip install -r requirements.txt
deepchain-refinement/
├── src/
│ └── main.py # Core implementation with three refinement stages
├── requirements.txt # Python dependencies
├── LICENSE # MIT license text
└── README.md # This file
If you like this project, please give it a star ⭐
For questions, feedback, or support, reach out to: