
Self-Adaptive LLMs
https://github.com/sakanaai/self-adaptive-llms- Category
- AI Tools
- Rank
- No. 1134Tools index
- Pricing
- Open Source
- Type
- TOOL
- Builder
- sakanaai
- GitHub
- 1.2k stars
- Date
About
Framework that lets LLMs adapt to unseen tasks in real time by composing expert modules on the fly.
What it does
Transformer² modifies selected singular values inside a language model’s feed-forward weight matrices. It first classifies each prompt by task type, then applies or mixes reinforcement-trained expert parameters before generating and evaluating the answer.
Why it's ranked here
This is compelling research code because the adaptation mechanism is concrete, inspectable, and paired with training and evaluation workflows. Its narrow model support, GPU assumptions, manual setup, and script-driven interface make it better suited to experiments than general deployment.
What's good
The method changes compact singular-value masks instead of retraining every model weight. It includes reinforcement learning, random-search optimization, prompt routing, few-shot evaluation, checkpoint loading, optional LoRA handling, experiment logging, and task adapters covering mathematics, code, science questions, and classification.
Tradeoffs
Setup requires cloning the repository, creating a specific Python environment, installing pinned dependencies, and separately installing the evaluator. The implementation assumes CUDA hardware, uses fixed GPU placement in core training code, reaches into vLLM internals, and explicitly supports only two named model families in the supplied tasks.
How to use it well
Use it for controlled research on task-specific weight adaptation, especially when you can provision GPUs and reproduce the supplied benchmark workflow. Start with the provided training and evaluation scripts, then add task adapters carefully. It does not serve as a hosted API, polished application, or general model-serving layer.
Technical notes+
svd_reinforce_hydra.py drives Hydra-configured training and evaluation, decomposes non-normalization weights with torch.svd, stores factors, hard-codes cuda:1, and transfers rebuilt parameters into vLLM. policy/base.py creates bfloat16 learnable vectors for parameters containing mlp and converts them to sigmoid masks. utils.py reconstructs weights as U, masked S, and transposed V, rescales their singular-value sum, classifies prompts into code, math, reasoning, or other, and swaps expert weights before evaluation. optim_modules.py supplies REINFORCE with optional KL loss plus random shooting. tasks/base.py defines the task contract and few-shot wrapper; tasks/arc.py, tasks/gsm8k.py, tasks/math.py, tasks/mbpp2.py, and tasks/cls.py provide benchmark-specific prompts, rewards, metrics, and vLLM settings.
Observed
- Primary language
- Python
- Install surface
- Repository clone, Conda environment with Python 3.11, pip requirements, and a separately installed editable evaluator
- User interface
- Shell scripts for training, prompt-based evaluation, and few-shot evaluation
- Compute stack
- PyTorch, Transformers, vLLM, bfloat16 model execution, and CUDA device placement
- Configuration
- Hydra-based experiment configuration
- Supplied task coverage
- ARC, GSM8K, competition mathematics, MBPP and HumanEval code evaluation, plus task-category classification
Read from README.md, requirements.txt, utils.py, logging_utils.py, optim_modules.py, svd_reinforce_hydra.py, tasks/arc.py, tasks/cls.py, tasks/base.py, tasks/math.py, policy/base.py, tasks/gsm8k.py, tasks/mbpp2.py, tasks/__init__.py, policy/__init__.py.
What it can do
Adapt to new task types without retraining
Novel task description or prompt → Task-specific LLM configuration
Compose expert modules dynamically
Task requirements and available expert modules → Custom module combination optimized for the task
Process unseen tasks in real-time
Previously unencountered task with data → Task completion results
Select relevant expert modules automatically
Task analysis and module repository → Ranked list of applicable expert modules
Generate task-specific responses
User query and composed expert modules → Specialized response tailored to task domain
Optimize module composition for performance
Task metrics and module combinations → Performance-optimized expert module arrangement
Tags
Tech Stack
Comments (0)
No comments yet
Editorially curated, with community endorsements as a secondary signal. Corrections welcome.