Model reference · open weights
stable-code is an open-weight language model from stabilityai. AxForge deploys and operates it for you on dedicated EU-owned hardware — with the licence handled where one is required.
Available as managed deployment — configured and operated for you on dedicated EU hardware, quoted per deployment.
What it is
| Maker | stabilityai |
|---|---|
| Type | Language models |
| Task | Text gen |
| Parameters (lead) | 2.8B |
| Runs with | transformers |
| Released | 2024-01-09 |
| Popularity | 6k downloads / month |
| Licence | Commercial licence needed |
About
Please note: For commercial use, please refer to https://stability.ai/license.
stable-code-3b is a 2.7B billion parameter decoder-only language model pre-trained on 1.3 trillion tokens of diverse textual and code datasets. stable-code-3b is trained on 18 programming languages (selected based on the 2023 StackOverflow Developer Survey) and demonstrates state-of-the-art performance (compared to models of similar size) on the MultiPL-E metrics across multiple programming languages tested using BigCode's Evaluation Harness.
| 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% |
| Wizard Coder | 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% |
| Deci Coder | 1B | 19.1% | 6.8% | 18.4% | 16.7% | 2.1% | 1.7% |
Key Features
Get started generating text with stable-code-3b by using the following code snippet:
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("stabilityai/stable-code-3b")
model = AutoModelForCausalLM.from_pretrained(
"stabilityai/stable-code-3b",
torch_dtype="auto",
)
model.cuda()
inputs = tokenizer("import torch\nimport torch.nn as nn", return_tensors="pt").to(model.device)
tokens = model.generate(
**inputs,
max_new_tokens=48,
temperature=0.2,
do_sample=True,
)
print(tokenizer.decode(tokens[0], skip_special_tokens=True))
from transformers import AutoModelForCausalLM, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("stabilityai/stable-code-3b")
model = AutoModelForCausalLM.from_pretrained(
"stabilityai/stable-code-3b",
torch_dtype="auto",
attn_implementation="flash_attention_2",
)
model.cuda()
inputs = tokenizer("def fib(n): else:\n return fib(n - 2) + fib(n - 1)", return_tensors="pt").to(model.device)
tokens = model.generate(
**inputs,
max_new_tokens=48,
temperature=0.2,
do_sample=True,
)
print(tokenizer.decode(tokens[0], skip_special_tokens=True))
from transformers import AutoModelForCausalLM, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("stabilityai/stable-code-3b", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
"stabilityai/stable-code-3b",
trust_remote_code=True,
torch_dtype="auto",
+ attn_implementation="flash_attention_2",
)
model.cuda()
inputs = tokenizer("import torch\nimport torch.nn as nn", return_tensors="pt").to(model.device)
tokens = model.generate(
**inputs,
max_new_tokens=48,
temperature=0.2,
do_sample=True,
)
print(tokenizer.decode(tokens[0], skip_special_tokens=True))
stable-code-3b models are auto-regressive language models based on the transformer decoder architecture.lm@stability.aiThe model is a decoder-only transformer similar to the LLaMA (Touvron et al., 2023) architecture with the following modifications:
| Parameters | Hidden Size | Layers | Heads | Sequence Length |
|---|---|---|---|---|
| 2,796,431,360 | 2560 | 32 | 32 | 16384 |
NeoX. We add special tokens to train for Fill in the Middle (FIM) capabilities like and along with other special tokens.The dataset is comprised of a filtered mixture of open-source large-scale datasets available on the HuggingFace Hub: Falcon RefinedWeb extract (Penedo et al., 2023), along with CommitPackFT and Github Issues (BigCode., 2023), and StarCoder (Li et al., 2023). We further supplement our training with data from mathematical domains (Azerbayev, Zhangir, et al., 2023 and, Yu, Longhui, et al., 2023).
Top 18 programming languages trained on:
The model is pre-trained on the aforementioned datasets in bfloat16 precision, optimized with AdamW.
stable-code-3b was trained on the Stability AI cluster across 256 NVIDIA A100 40GB GPUs (AWS PFrom the published model card. Full card on the HuggingFace links in the sidebar.
Benchmarks
As published on the model card — the maker's own numbers, not measured by AxForge.
| Task | Dataset | Metric | Score |
|---|---|---|---|
| text-generation | MultiPL-HumanEval (Python) | pass@1 | 32.400 |
| text-generation | MultiPL-HumanEval (C++) | pass@1 | 30.900 |
| text-generation | MultiPL-HumanEval (Java) | pass@1 | 32.100 |
| text-generation | MultiPL-HumanEval (JavaScript) | pass@1 | 32.100 |
| text-generation | MultiPL-HumanEval (PHP) | pass@1 | 24.200 |
| text-generation | MultiPL-HumanEval (Rust) | pass@1 | 23 |
Using it via the API
Once AxForge deploys stable-code for you, it answers on the OpenAI-compatible API — the same base URL and keys as every other model. (stable-code below is illustrative; you get the exact model name on deployment.)
$ curl -sS https://api.axforge.ai/v1/chat/completions \
-H "Authorization: Bearer $AXFORGE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"stable-code","messages":[{"role":"user","content":"Hello"}]}'
Create an account — your API key is available in the console. 5M tokens/month currently included with every new account at launch.