CoolFace
Apppublic

zade-frontier/andrej-karpathy-llm-council

sourceHugging Faceupdated 10mo agoView on Hugging Face
1likes
App README

๐Ÿข 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

  1. 1.Stage 1 - Individual Responses: 5 different AI models independently answer your question
  2. 2.Stage 2 - Peer Review: Each model ranks the anonymized responses from others
  3. 3.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)

  1. 1.Fork/Duplicate this Space
  2. 2.Add your API keys in Settings โ†’ Repository secrets:
  3. 3.OPENAI_API_KEY - Get from OpenAI
  4. 4.HUGGINGFACE_API_KEY - Get from HuggingFace
  5. 5.Done! Your space will auto-deploy

๐Ÿ’ป Run Locally

bash
# 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.py

Visit http://localhost:7860

๐Ÿ”‘ Getting API Keys

OpenAI API Key (Required)

  1. 1.Go to https://platform.openai.com/api-keys
  2. 2.Create new secret key
  3. 3.Copy and save it (costs ~$0.01-0.03 per query)

HuggingFace Token (Required for FREE models)

  1. 1.Go to https://huggingface.co/settings/tokens
  2. 2.Create new token (read access is enough)
  3. 3.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:

python
# 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!