Stable Code 3B: Technical Analysis & Performance Guide
Stability AI's small code model: its architecture, the benchmarks Stability published, how much memory it needs, and how to run it with Ollama
Technical Specifications
Model Size: 2.8 billion parameters (2,796,431,360)
Architecture: Decoder-only transformer, 32 layers, hidden size 2,560
Context Window: 16,384 tokens
Model File: 1.6 GB in Ollama (Q4_0)
License: Stability AI Community License (commercial use free under US$1M annual revenue)
Installation: ollama pull stable-code:3b
Table of Contents
Model Overview & Architecture
Stable Code 3B is Stability AI's small code model, announced on 16 January 2024. The model card lists 2,796,431,360 parameters, pre-trained on 1.3 trillion tokens of text and code, and Stability's announcement describes it as 60% smaller than CodeLlama 7B with similar performance across programming languages.
It starts from Stability's Stable LM 3B, trained on 4 trillion tokens of natural language, and adds code and software-engineering data: a Falcon RefinedWeb extract, CommitPackFT, GitHub Issues and StarCoder data, plus mathematics datasets. Training used sequences of up to 16,384 tokens.
Architecture Details
Core Architecture
- • Decoder-only transformer, similar to LLaMA
- • 2,796,431,360 parameters
- • 32 layers, hidden size 2,560, 32 attention heads
- • 16,384-token context (the trained sequence length)
- • Rotary position embeddings on the first 25% of each head's dimensions
Training Focus
- • 18 programming languages, picked from the 2023 Stack Overflow Developer Survey
- • Fill-in-the-middle training for editor autocomplete
- • A modified GPT-NeoX tokenizer with FIM special tokens
- • An instruct variant, Stable Code Instruct 3B, tuned with DPO for code chat and SQL
The 18 languages: C, C++, Java, JavaScript, CSS, Go, HTML, Ruby, Rust, Markdown, Shell, PHP, SQL, R, TypeScript, Python, Jupyter notebooks and reStructuredText.
Key Features
- • Fill-in-the-Middle: completes code between a prefix and a suffix, which is what editor autocomplete needs
- • Long Context: trained on sequences of up to 16,384 tokens; Stability says raising the rotary base can stretch this to 100k tokens
- • Two Builds in Ollama:
stable-code:3b(instruct, for chat) andstable-code:code(base, for completion) - • No GPU Required: Stability's announcement says it “operates offline even without a GPU on common laptops such as a MacBook Air”
- • Local Deployment: runs on your own machine, so your code stays private
External Sources & References
- • Hugging Face: stable-code-3b model card and stable-code-instruct-3b model card
- • Research: Stable Code Technical Report (arXiv, April 2024)
- • Announcement: Stable Code 3B: Coding on the Edge (Stability AI, January 2024)
- • Ollama: stable-code in the Ollama library
Performance Analysis
Stability published MultiPL-E pass@1 scores (HumanEval translated into other languages, run with BigCode's evaluation harness) for both builds. These are Stability's numbers from the two model cards; this site has not re-run them.
| Language | Stable Code 3B (base) | Stable Code Instruct 3B |
|---|---|---|
| Python | 32.4% | 59% |
| C++ | 30.9% | 49% |
| JavaScript | 32.1% | 49% |
| Java | 32.1% | 44% |
| PHP | 24.2% | 45% |
| Rust | 23.0% | 37% |
On the coding questions of MT-Bench, Stability scores the instruct model 5.8, against 4.6 for DeepSeek Coder 1.3B, 6.9 for DeepSeek Coder 6.7B and 3.55 for CodeLlama Instruct 7B (instruct model card).
Hardware Requirements
The Ollama file for Stable Code 3B is 1.6 GB. The key-value cache adds about 0.33 MB per token of context at 16-bit (32 layers, 32 KV heads of 80 dimensions), so memory depends mostly on how much context you give it.
| Context | KV cache | Weights + cache |
|---|---|---|
| 2,048 tokens | 0.7 GB | 2.3 GB |
| 4,096 tokens | 1.3 GB | 3.0 GB |
| 16,384 tokens (the maximum) | 5.4 GB | 7.0 GB |
Ollama needs some working memory on top of these figures. That makes 4 GB of free memory enough at a 4K context and 8 GB enough for the full 16K. A GPU is optional: Stability says the model runs offline on laptops without one.
Speed Ceilings
Each generated token reads the full 1.6 GB of weights, so memory bandwidth caps the speed. Bandwidth ÷ 1.61 GB gives ceilings of about 169 tok/s on an RTX 4060 (272 GB/s), 224 tok/s on an RTX 3060 12GB (360 GB/s) and 93 tok/s on an Apple M3 Pro (150 GB/s). These are ceilings, not measurements; real generation lands below them.
Installation Guide
Installing Stable Code 3B is straightforward with Ollama, requiring minimal configuration to get started with AI-assisted coding workflows.
The installation process involves downloading the 1.6 GB model file and pointing your editor at the local Ollama server. Pull stable-code:3b for chat and stable-code:code if you also want autocomplete.
System Requirements
Install Ollama
Linux install script shown; macOS and Windows installers are at ollama.com/download
System Requirements Check
On Linux, show the GPU, free memory and free disk space
Download Model
Pull Stable Code Instruct 3B, the 1.6 GB build that stable-code:3b and stable-code:latest point to
Code Generation Test
Test basic code generation functionality
Completion Model for IDE Integration
For inline autocomplete, pull the base model, whose card lists fill-in-the-middle (another 1.6 GB)
IDE Integration
VS Code Setup
# Install the Continue extension for VS Code
code --install-extension continue.continue
# ~/.continue/config.yaml
name: Local Config
version: 0.0.1
schema: v1
models:
- name: Stable Code Instruct 3B
provider: ollama
model: stable-code:3b
roles:
- chat
- name: Stable Code 3B (autocomplete)
provider: ollama
model: stable-code:code
roles:
- autocompleteAlternative Editors
# Ollama serves every pulled model on localhost:11434
# Test the API from any editor or script
curl http://localhost:11434/api/generate -d '{"model":"stable-code:3b","prompt":"def hello():","stream":false}'Use Cases & Applications
The two builds split the work. The base model (stable-code:code) is for completion and fill-in-the-middle in an editor; the instruct model (stable-code:3b) is tuned for software-engineering chat and SQL, according to Stability's model cards. Typical jobs:
Code Generation
- • Function Generation: Complete function implementations
- • Class Creation: Object-oriented programming patterns
- • API Development: REST endpoint implementations
- • Database Queries: SQL query generation
Code Completion
- • Auto-completion: Intelligent code suggestions
- • Pattern Recognition: Common coding patterns
- • Syntax Completion: Bracket and quote matching
- • Import Suggestions: Library import recommendations
Documentation
- • Docstring Generation: Function documentation
- • Code Comments: Explanatory comments
- • README Creation: Project documentation
- • API Documentation: Interface descriptions
Learning & Education
- • Code Examples: Programming examples
- • Concept Explanation: Technical concepts
- • Best Practices: Coding standards
- • Debugging Assistance: Error analysis
At this size it makes more mistakes than larger code models: on Stability's own MultiPL-E numbers the base model solves about a third of the Python problems on the first try, so run and test what it writes.
Model Comparison
Comparing Stable Code 3B with other code generation models helps understand its competitive position and appropriate use cases for development workflows.
Stability's model card compares the base model with other open code models of early 2024 on MultiPL-E pass@1. All rows are Stability's figures for base models; newer small code models have been released since.
| Model | Size | Python | C++ | JavaScript | Java | PHP | Rust |
|---|---|---|---|---|---|---|---|
| Stable Code | 3B | 32.4% | 30.9% | 32.1% | 32.1% | 24.2% | 23.0% |
| CodeLlama | 7B | 30.0% | 28.2% | 32.5% | 31.1% | 25.7% | 26.3% |
| DeepSeek Coder | 1.3B | 28.6% | 29.2% | 28.7% | 29.0% | 23.6% | 18.5% |
| WizardCoder | 3B | 31.6% | 25.6% | 26.2% | 25.8% | 25.3% | 20.4% |
| StarCoder | 3B | 21.6% | 19.8% | 21.5% | 20.5% | 19.0% | 16.9% |
| Replit Code V1.5 | 3B | 23.0% | 25.9% | 26.2% | 23.6% | 23.2% | 21.5% |
| DeciCoder | 1B | 19.1% | 6.8% | 18.4% | 16.7% | 2.1% | 1.7% |
Performance Optimization
Optimizing Stable Code 3B performance involves system configuration, resource management, and integration with development tools. These techniques help achieve optimal code generation speed and accuracy.
System Optimization
- • Memory Management: Efficient RAM allocation
- • GPU Utilization: Optimal GPU memory usage
- • Keep It Loaded: OLLAMA_KEEP_ALIVE stops Ollama unloading the model between requests
- • Thread Management: Multi-core processing
Development Integration
- • IDE Plugins: Editor integration setup
- • API Configuration: Local server optimization
- • Response Formatting: Structured output handling
- • Error Handling: Graceful failure management
Code Quality
- • Prompt Engineering: Effective code generation prompts
- • Context Management: Optimal code context
- • Style Consistency: Consistent code formatting
- • Validation: Generated code verification
Monitoring & Maintenance
- • Performance Metrics: Response time tracking
- • Quality Assessment: Code quality evaluation
- • Usage Analytics: Development pattern analysis
- • Resource Monitoring: System resource tracking
Implementing these optimization strategies requires continuous monitoring and adjustment based on actual development workflows. Developers should establish baseline performance metrics and refine configurations based on their specific coding patterns and project requirements.
Frequently Asked Questions
What programming languages does Stable Code 3B support best?
It was trained on 18 languages, from C, C++, Java, JavaScript, Python and Go to SQL, Shell, Markdown and Jupyter notebooks. On Stability's MultiPL-E numbers the base model does best in Python (32.4%), JavaScript and Java (32.1% each) and C++ (30.9%), and weakest in PHP (24.2%) and Rust (23.0%).
Can Stable Code 3B be used for commercial projects?
Yes, within limits. Under the Stability AI Community License, commercial use is free once you register with Stability AI, as long as you and your affiliates make less than US$1 million a year; above that you need an enterprise licence from Stability AI. Research and non-commercial use are free.
What are the limitations of Stable Code 3B?
It is a small model from early 2024: the base build solves about a third of the MultiPL-E Python problems on the first try, and Stability describes it as a base model for fine-tuning that may produce unreliable output, so test what it writes.
How can I integrate Stable Code 3B with my IDE?
Through Ollama, which serves it at http://localhost:11434, including an OpenAI-compatible API under /v1. Editor extensions such as Continue can use stable-code:3b for chat and stable-code:code for autocomplete; the config in the installation section shows both.
Stable Code 3B Research Documentation
The primary sources for the figures on this page, plus the benchmark and harness Stability used to score the model.
Official Documentation
Evaluation Tools
Explore Related Code Generation Models
Build Real AI on Your Machine
RAG, agents, NLP, vision, and MLOps - chapters across 25 courses that take you from reading about AI to building AI.
Related Guides
Continue your local AI journey with these comprehensive guides
📚 Continue Learning: Code Generation Models
Stable Code 3B: Local vs Cloud
Run through Ollama, your prompts and code stay on your computer instead of going to a provider's servers
Go from reading about AI to building with AI
25 structured courses. Hands-on projects. Runs on your machine. Start free.

Written by
Barsha Mohapatra
Founder and Editor, Local AI Master · Founder, Little AI Master
Founder of Little AI Master and the editor behind every course and guide on Local AI Master. Years of tutoring students taught her where AI education actually fails.
- PILLARLocal AI Models Directory: Every Model Compared
- DeepSeek V4 Local Setup: 1M Context, MIT (2026)
- models/llama-3-1-8b
- models/deepseek-coder-v2-236b
- Phi-3 Mini 3.8B: 69% MMLU on 8GB RAM (Microsoft SLM)
- models/gemma-2-9b
- GPT-5.6 Explained: Luna, Terra, Sol Pricing & Local Options
- StarCoder 2 15B – Technical Analysis & Performance Guide
- models/gpt-oss
- models/devstral
Grab the AI Starter Kit — career roadmap, cheat sheet, setup guide
No spam. Unsubscribe with one click.
Found your model? Now build something with it.
25 hands-on courses — RAG, agents, fine-tuning — all running locally. First chapter free, no card.