Archive of AI

Source Snapshot / 2023-08-08-stable-code-edge-coding-llm-3

stabilityai/stable-code-3b

Linked event: 2023-08-08 · Stability AI Releases Lightweight Open-Source Coding Model Series Stable Code for Local Completion on GPU-Free Laptops

Publisher
Hugging Face
Archived
2026-11-23
Capture Method
Direct page capture
HTTP / SHA-256
200 / ef1ca5b9a674474f
Original URL
Open source ↗
Wayback Backup
Not archived
This page preserves a plain-text static snapshot against link rot. When citing figures, tables, or full legal terms, verify against the original URL and Wayback Machine archive.

Hugging Face

Search models, datasets, users... ⌘K

stable-code-3b

Stability AI 40.8k

Text Generation

Transformers

Eval Results (legacy)

arxiv: 7 papers

License: other

Model card Files Files and versions

Copy to bucket

Use this model

Please note: For commercial use, please refer to https://stability.ai/license.

Model Description

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.

Deepseek Coder

Wizard Coder

Replit Code V1.5

Key Features

Fill in Middle Capability (FIM)

Supports Long Context, trained with Sequences upto 16,384

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(

max_new_tokens=48,

temperature=0.2,

do_sample=True,

print(tokenizer.decode(tokens[0], skip_special_tokens=True))

Run with Fill in Middle (FIM) ⚡️

Click to expand

attn_implementation="flash_attention_2",

inputs = tokenizer("<fim_prefix>def fib(n):<fim_suffix> else:\n return fib(n - 2) + fib(n - 1)<fim_middle>", return_tensors="pt").to(model.device)

Run with Flash Attention 2 ⚡️

tokenizer = AutoTokenizer.from_pretrained("stabilityai/stable-code-3b", trust_remote_code=True)

trust_remote_code=True,

+ attn_implementation="flash_attention_2",

Model Details

Developed by: Stability AI

Model type: stable-code-3b models are auto-regressive language models based on the transformer decoder architecture.

Language(s): English, Code

Library: GPT-NeoX

License: Stability AI Community License.

Commercial License: to use this model commercially, please refer to https://stability.ai/license

Contact: For questions and comments about the model, please email lm@stability.ai

Model Architecture

The model is a decoder-only transformer similar to the LLaMA (Touvron et al., 2023) architecture with the following modifications:

Sequence Length

2,796,431,360

Position Embeddings: Rotary Position Embeddings (Su et al., 2021) applied to the first 25% of head embedding dimensions for improved throughput following Black et al. (2022).

Tokenizer: We use a modified version of the GPTNeoX Tokenizer.NeoX. We add special tokens to train for Fill in the Middle (FIM) capabilities like <FIM_PREFIX> and <FIM_SUFFIX> along with other special tokens.

Training Dataset

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:

Jupyter-Clean

RestructuredText

Training Procedure

The model is pre-trained on the aforementioned datasets in bfloat16 precision, optimized with AdamW.

Training Infrastructure

Hardware: stable-code-3b was trained on the Stability AI cluster across 256 NVIDIA A100 40GB GPUs (AWS P4d instances).

Software: We use a fork of gpt-neox (EleutherAI, 2021), train under 2D parallelism (Data and Tensor Parallel) with ZeRO-1 (Rajbhandari et al., 2019), and rely on flash-attention as well as SwiGLU and Rotary Embedding kernels from FlashAttention-2 (Dao et al., 2023)

Use and Limitations

Intended Use

The model is intended to be used as a foundational base model for application-specific fine-tuning. Developers must evaluate and fine-tune the model for safe performance in downstream applications. For commercial use, please refer to https://stability.ai/license.

Limitations and Bias

As a base model, this model may exhibit unreliable, unsafe, or other undesirable behaviors that must be corrected through evaluation and fine-tuning prior to deployment. The pre-training dataset may have contained offensive or inappropriate content, even after applying data cleansing filters, which can be reflected in the model-generated text. We recommend that users exercise caution when using these models in production systems. Do not use the models if they are unsuitable for your application, or for any applications that may cause deliberate or unintentional harm to others.

@misc{stable-code-3b,

url={[https://huggingface.co/stabilityai/stable-code-3b](https://huggingface.co/stabilityai/stable-code-3b)},

title={Stable Code 3B},

author={Pinnaparaju, Nikhil and Adithyan, Reshinth and Phung, Duy and Tow, Jonathan and Baicoianu, James and Cooper, Nathan}

Downloads last month 6,053

Model tree for stabilityai/stable-code-3b

Quantizations

Datasets used to train stabilityai/stable-code-3b

Spaces using stabilityai/stable-code-3b 23

Collection including stabilityai/stable-code-3b

Suite of developer assistant models • 5 items • Updated Jan 9, 2025 • 46

Papers for stabilityai/stable-code-3b

Llemma: An Open Language Model For Mathematics

Paper • 2310.10631 • Published Oct 16, 2023 • 57

MetaMath: Bootstrap Your Own Mathematical Questions for Large Language

Paper • 2309.12284 • Published Sep 21, 2023 • 19

Llama 2: Open Foundation and Fine-Tuned Chat Models

Paper • 2307.09288 • Published Jul 18, 2023 • 252

StarCoder: may the source be with you!

Paper • 2305.06161 • Published May 9, 2023 • 34

GPT-NeoX-20B: An Open-Source Autoregressive Language Model

Paper • 2204.06745 • Published Apr 14, 2022 • 1

Evaluation results

pass@1 on MultiPL-HumanEval (Python)

self-reported

pass@1 on MultiPL-HumanEval (C++)

pass@1 on MultiPL-HumanEval (Java)

pass@1 on MultiPL-HumanEval (JavaScript)

pass@1 on MultiPL-HumanEval (PHP)

pass@1 on MultiPL-HumanEval (Rust)