socialist-AI is a local multi-agent inference framework for socialist analysis. It runs a shared local LLM through several role-based agents — a theoretician, a historian, a strategist, and a democratic socialist critic — then synthesizes their discussion into a concise consensus answer.
- Demonstrates multi-agent reasoning with a single local model.
- Emphasizes socialist theory, historical materialism, and democratic pluralism.
- Supports hidden agent reasoning while keeping visible output clean.
- Designed for portable local inference using 4-bit quantization.
- Multi-agent debate architecture with role-based prompts
- Batch generation for efficient round-based discussion
- Streaming and batch UI support via
gui.py - Hidden reasoning capture for developer inspection
- Optional LoRA adapter training with
train_adapter.py - Benchmark mode for measuring model performance
agent_controller.py— multi-agent debate orchestration and final-answer generationgui.py— desktop-style interface for running debates locallyprompts.py— role prompts and conversation templatesmodel_utils.py— model loading, generation helpers, and reasoning filteringconfig.py— default model settings and inference parameterstrain_adapter.py— adapter training script for domain specializationvalidate_model.py— lightweight model path validationdownload_qwen_model.py— helper for retrieving a local Qwen modeldata/socialist_instructions.jsonl— sample dataset placeholder for trainingrequirements.txt— core Python dependencies
- Python 3.10+ (recommended)
- PyTorch with CUDA support for GPU inference
transformers,accelerate,bitsandbytes,peft, and related packages
Install dependencies:
python -m pip install -r requirements.txtThis repository does not include model weights. A compatible local model directory is required, for example:
models/qwen-3.5-9b
The default config points at models/qwen-3.5-9b, but you can override it with LOCAL_MODEL_PATH.
Qwen/Qwen3.5-9B(local directory with tokenizer and weight files)- 4-bit quantization is used by default for lower VRAM usage
python -m pip install huggingface_hub
$env:HUGGINGFACE_HUB_TOKEN = "<your_token_here>"
python download_qwen_model.py --model-dir models/qwen-3.5-9b --repo-id Qwen/Qwen3.5-9BRun a single debate question:
python agent_controller.py "What is the socialist critique of corporate power?"Or explicitly set the model path:
LOCAL_MODEL_PATH=models/qwen-3.5-9b python agent_controller.py "Can socialism be democratic?"Start the desktop interface:
python gui.pyThe GUI provides a retro-styled debate terminal, sidebar controls, and a hidden reasoning window for internal debug output.
The core configuration is in config.py, including:
load_in_4bit— enable 4-bit quantizationuse_torch_compile— usetorch.compile()for repeated inferenceattn_implementation— choose attention kernel (sdpaby default)agent_max_new_tokens— max response length per agentdebate_rounds— number of discussion roundssoft_token_limit— allow buffer tokens for safe generation
Measure inference performance with a simple benchmark:
python agent_controller.py --benchmark --benchmark-output benchmark_results.md --benchmark-seed 42 "What is the socialist critique of the state?"Benchmark mode runs a small suite of cases and writes a Markdown report.
If you want to specialize the system via LoRA, add examples to data/socialist_instructions.jsonl and run:
python train_adapter.py- This repo is designed for local inference only.
- Do not commit large model files or private credentials.
models/andadapters/are excluded from the public repository via.gitignore.- The project is best used on a GPU with at least ~10GB VRAM.
Contributions are welcome. Suggested improvements:
- add more socialist role prompts
- refine hidden reasoning extraction
- add example discussion prompts and training data
- support additional lightweight LLM backends
Include your preferred license when publishing this repository.