Cambium 🌱
Advanced LLM Architecture Augmentation Library
Expand your LLMs like nature intended - surgically, efficiently, and beautifully.
Cambium is an open-source Python library that enables surgical expansion of Large Language Models (LLMs). Named after the plant tissue responsible for secondary growth, Cambium allows developers and researchers to add new layers or architecture blocks to existing models using familiar PyTorch-like APIs.
🌱 Our Vision
We believe that experimenting with LLM architecture should not require a multi-million-dollar compute cluster.
Today, the frontier of language-model research is largely locked behind paywalls of scale—prohibitive GPU hours, massive infrastructure, and closed-source decisions made by a handful of organizations. Cambium exists to change that. We want anyone with curiosity and a laptop to be able to ask: "What if I add a new attention mechanism here?" or "What happens if I widen the hidden dimensions of layer 12?"—and actually try it, on real models, in minutes.
By making surgical model expansion lightweight, reproducible, and accessible, we hope to empower students, indie researchers, and open-source teams to push the boundaries of LLM architecture without the traditional barriers of cost and scale. Every new idea deserves a fair shot, regardless of the size of your GPU budget.
🎯 The Core Idea
Traditional: Train new 7B model from scratch (expensive 💰)
Cambium: Expand 2B → 4B, preserve weights, train only new (efficient 🌱)
Key Benefits:
- 🔄 Preserve pretrained knowledge - Keep all original weights intact
- 📈 Modular expansion - Add capacity where needed
- 🎛️ Staged training - Progressive unfreezing strategies
- ⚡ Minimal compute - Train only new parameters initially
- 🤝 Framework compatible - Works with HF Transformers, TRL, PEFT
📦 Installation
# Basic installation
pip install cambium-llm
# With training dependencies (recommended)
pip install "cambium-llm[train]"
# Development installation
pip install "cambium-llm[dev]"
🚀 Quick Start
from cambium import ExpandableModel, InterleavedExpansion
from cambium.training import StagedTrainer
import torch
# 1. Load base model
model = ExpandableModel.from_pretrained("HuggingFaceTB/SmolLM2-135M", dtype=torch.float32)
# 2. Expand with 4 new transformer blocks
model.expand(InterleavedExpansion(num_layers=4, initialization="identity"))
# 3. Setup staged training
trainer = StagedTrainer(model)
trainer.add_phase(name="warmup", freeze="original", lr=1e-4, epochs=2)
trainer.add_phase(name="finetune", freeze="none", lr=1e-6, epochs=1)
# 4. Train
trainer.train(train_dataloader, eval_dataloader)
# 5. Save
model.save_expanded("./my-expanded-model")
📚 Expansion Strategies
1. Interleaved Block Expansion (LLaMA-Pro style)
Insert new transformer blocks between existing ones:
from cambium import InterleavedExpansion
expander = InterleavedExpansion(
num_layers=4,
initialization="identity", # Near-identity init
)
model.expand(expander)
# Original: [Block0] → [Block1] → [Block2]
# Expanded: [Block0] → [New0] → [Block1] → [New1] → [Block2]
2. Width Expansion
Increase hidden dimensions:
from cambium.strategies import WidthExpansion
expander = WidthExpansion(
hidden_dim_multiplier=1.5, # 768 → 1152
initialization="copy",
)
model.expand(expander)
3. Parallel Adapters
Add parallel pathways:
from cambium.strategies import ParallelAdapterExpansion
expander = ParallelAdapterExpansion(
adapter_type="bottleneck",
bottleneck_dim=256,
target_layers=[20, 21, 22, 23], # Last 4 layers
)
model.expand(expander)
4. Custom Block Expansion
Define and insert your own architecture blocks:
from cambium import CustomBlockExpansion
from cambium.blocks import CambiumBlock, SwiGLUBlock
import torch.nn as nn
# Use a template
model.expand(CustomBlockExpansion(
block_class=SwiGLUBlock,
num_layers=4,
residual_connection=True,
))
# Or define your own
class MyBlock(CambiumBlock):
required_config_keys = ["hidden_size"]
def __init__(self, config, layer_idx=0):
super().__init__()
self.proj = nn.Linear(config.hidden_size, config.hidden_size)
def forward(self, hidden_states, **kwargs):
return self.proj(hidden_states)
model.expand(CustomBlockExpansion(
block_class=MyBlock,
num_layers=2,
residual_connection=True,
))
🎓 Training Strategies
Phase 1: Warmup New Layers
trainer.add_phase(
name="warmup",
freeze="original", # Freeze all original weights
lr=1e-4,
epochs=2,
)
Phase 2: Progressive Unfreezing
trainer.add_phase(
name="unfreeze",
unfreeze_groups=[-4, -3, -2, -1], # Last 4 layer groups
lr=5e-5,
epochs=1,
)
Phase 3: Full Fine-tuning
trainer.add_phase(
name="finetune",
freeze="none", # Unfreeze all
lr=1e-6,
discriminative_lr={
"embeddings": 1e-8,
"original_layers": 1e-6,
"new_layers": 1e-5,
},
epochs=1,
)
🔧 Supported Models
| Model | Block Expansion | Width Expansion | Adapters |
|---|---|---|---|
| LLaMA 2/3 | ✅ | ✅ | ✅ |
| Gemma / Gemma 3 | ✅ | ⚠️ | ⚠️ |
| Mistral | ✅ | ⚠️ | ⚠️ |
| Qwen2 / Qwen3 | ✅ | ⚠️ | ⚠️ |
✅ Verified end-to-end for block expansion (
InterleavedExpansion) on all listed models. ⚠️ Width expansion and adapters are currently verified only on LLaMA-family models.More models coming soon!
📖 Documentation
- 01 - Quickstart Guide
- 02 - Interleaved Expansion
- 03 - Staged Training
- 04 - Complete Workflow
- 05 - Width Expansion
- 06 - Parallel Adapters
- 07 - Custom Blocks
🏗️ Architecture
cambium/
├── core/ # Low-level surgical operations
│ ├── expansion.py # Model surgery engine
│ ├── initialization.py # Smart init strategies
│ └── freezing.py # Advanced freezing logic
├── strategies/ # Expansion strategies
│ ├── block_expansion.py
│ ├── width_expansion.py
│ ├── parallel_adapters.py
│ └── custom_expansion.py # Custom block insertion
├── blocks/ # Custom block definitions
│ ├── base.py # CambiumBlock ABC, ResidualWrapper
│ └── templates.py # Pre-built blocks (SwiGLU, etc.)
├── training/ # Training utilities
│ ├── staged_trainer.py
│ └── utilities.py
├── models/ # Model wrappers
│ └── expandable.py
├── utils/ # Helper utilities
│ ├── memory.py
│ └── validation.py
└── exceptions.py # Error classes
🧪 Testing
# Run tests
pytest tests/
# Run with coverage
pytest --cov=cambium tests/
# Run specific test file
pytest tests/unit/test_expansion.py -v
🤝 Contributing
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
Development Setup
# Clone the repository
git clone https://github.com/SorawitChok/Cambium.git
cd cambium
# Install in development mode
pip install -e ".[dev]"
# Install pre-commit hooks
pre-commit install
📊 Comparison with Alternatives
| Approach | Method | Pros | Cons |
|---|---|---|---|
| Cambium | Add new blocks | Full capacity increase | More memory |
| LoRA | Low-rank adapters | Minimal params | Limited capacity |
| IA³ | Learned scaling | Preserves structure | Architecture-specific |
| Prefix Tuning | Learned prefixes | No model changes | Limited expressiveness |
| Full Fine-tune | Train all params | Best performance | Expensive |
When to use Cambium:
- You need more model capacity than adapters can provide
- You want to add architectural components (new attention types, etc.)
- You have compute for training new layers but not full models
- You want progressive training strategies
📄 Citation
If you use Cambium in your research, please cite:
@software{cambium2026,
title={Cambium: Advanced LLM Architecture Augmentation},
author={Sorawit Chokphantavee, Sirawit Chokphantavee, and Cambium Team},
year={2026},
url={https://github.com/SorawitChok/Cambium}
}
📜 License
Cambium is released under the Apache License 2.0. See LICENSE for details.
🙏 Acknowledgments
Cambium builds on the excellent work of:
- Hugging Face Transformers
- PyTorch
- LLaMA-Pro (inspiration for interleaved expansion)
💬 Community
- GitHub Issues: Bug reports and feature requests
- Discussions: Q&A and general discussion
Grow your models like nature intended 🌱
Metadata
Release files for cambium-llm 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cambium_llm-0.1.1.tar.gz | 121.0 kB | Without provenance | Details for cambium_llm-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cambium_llm-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for cambium_llm-0.1.1-py3-none-any.whl |
Total release size: 190.5 kB
Release files / cambium_llm-0.1.1.tar.gz
| Download URL | cambium_llm-0.1.1.tar.gz |
|---|---|
| Size | 121.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e273c6dabc2126cb6403f5312e07d0d24078e1c32d4c10e341470a3b28bbc79f
|
|
BLAKE2b-256 checksum How to use checksums |
bc63b8c6419033fdb2957b7e4188ae06fd5655499975aa02e6448c873ff36094
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / cambium_llm-0.1.1-py3-none-any.whl
| Download URL | cambium_llm-0.1.1-py3-none-any.whl |
|---|---|
| Size | 69.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1a1fc3f8c150de9b2046b0cd2823aa9bdbc469f58f3d04ef25639ed6bf02645b
|
|
BLAKE2b-256 checksum How to use checksums |
56d55ff02143d33a82f815c6e94c91cf9236a9651fc90e3b206ccc05bc7ebb32
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Security for cambium-llm 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.