zade-frontier/andrej-karpathy-llm-council
1
๐ข LLM Council - Multi-Model AI Deliberation System
A sophisticated system where multiple LLMs collaboratively answer questions through a 3-stage deliberation process.
๐ฏ How It Works
- Stage 1 - Individual Responses: 5 different AI models independently answer your question
- Stage 2 - Peer Review: Each model ranks the anonymized responses from others
- Stage 3 - Synthesis: A chairman model synthesizes the final answer based on all inputs
๐ฐ Cost: Mostly FREE!
This version uses FREE HuggingFace Inference API models:
- โ Meta Llama 3.3 70B (FREE)
- โ Qwen 2.5 72B (FREE)
- โ Mixtral 8x7B (FREE)
- ๐ต OpenAI GPT-4o-mini (low cost)
- ๐ต OpenAI GPT-3.5-turbo (low cost)
Cost per query: ~$0.01-0.03 (mostly OpenAI, HF is free!)
โก Quick Start
๐ Deploy to Hugging Face (Recommended)
- Fork/Duplicate this Space
- Add your API keys in Settings โ Repository secrets:
OPENAI_API_KEY- Get from OpenAIHUGGINGFACE_API_KEY- Get from HuggingFace- Done! Your space will auto-deploy
๐ป Run Locally
# Clone repository
git clone https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME
cd YOUR_SPACE_NAME
# Install dependencies
pip install -r requirements.txt
# Create .env file with your API keys
cp .env.example .env
# Edit .env and add:
# OPENAI_API_KEY=your_openai_key
# HUGGINGFACE_API_KEY=your_hf_token
# Run the app
python app.pyVisit http://localhost:7860
๐ Getting API Keys
OpenAI API Key (Required)
- Go to https://platform.openai.com/api-keys
- Create new secret key
- Copy and save it (costs ~$0.01-0.03 per query)
HuggingFace Token (Required for FREE models)
- Go to https://huggingface.co/settings/tokens
- Create new token (read access is enough)
- Copy and save it (100% FREE to use!)
๐ค Council Models
Current Configuration
- Meta Llama 3.3 70B - Excellent reasoning, FREE
- Qwen 2.5 72B - Strong performance, FREE
- Mixtral 8x7B - Mixture of experts, FREE
- OpenAI GPT-4o-mini - Fast & capable, low cost
- OpenAI GPT-3.5-turbo - Reliable, low cost
Chairman
- OpenAI GPT-4o-mini - Excellent synthesis capabilities
Want to customize? Edit backend/config_free.py!
๐ Performance
- Response Time: 60-120 seconds (3 stages, parallel processing)
- Quality: Better than single-model responses
- Cost: ~$0.01-0.03 per query (mostly FREE!)
- Reliability: Automatic retries & error handling
๐ ๏ธ Tech Stack
- Frontend: Gradio 6.0+ (with MCP server support)
- Backend: Python async/await
- APIs:
- HuggingFace Inference API (FREE models)
- OpenAI API (paid models)
- Storage: JSON-based conversation persistence
๐ Project Structure
llm_council/
โโโ app.py # Main Gradio interface
โโโ requirements.txt # Python dependencies
โโโ .env.example # Environment template
โโโ backend/
โ โโโ config_free.py # FREE model configuration
โ โโโ api_client.py # HF + OpenAI API client
โ โโโ council_free.py # 3-stage orchestration
โ โโโ storage.py # Conversation storage
โ โโโ main.py # FastAPI backend (optional)
โโโ docs/
โโโ QUICKSTART.md
โโโ DEPLOYMENT_GUIDE.md
โโโ CODE_ANALYSIS.md๐ง Configuration
Want different models? Edit backend/config_free.py:
# Use ALL FREE models (no OpenAI cost):
COUNCIL_MODELS = [
{"id": "meta-llama/Llama-3.3-70B-Instruct", "provider": "huggingface"},
{"id": "Qwen/Qwen2.5-72B-Instruct", "provider": "huggingface"},
{"id": "mistralai/Mixtral-8x7B-Instruct-v0.1", "provider": "huggingface"},
{"id": "google/gemma-2-27b-it", "provider": "huggingface"},
]๐ค Contributing
Improvements welcome! See CODE_ANALYSIS.md for refactoring suggestions.
๐ Credits
- Implementation: Community contributions
- FREE models: Meta, Qwen, Mistral via HuggingFace
๐ License
See original repository for license information.
Need Help? Check the docs folder for detailed guides!
