Views
No views yet
stable-code-3bstable-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% |
stable-code-3b by using the following code snippet:1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3tokenizer = AutoTokenizer.from_pretrained("stabilityai/stable-code-3b")
4model = AutoModelForCausalLM.from_pretrained(
5 "stabilityai/stable-code-3b",
6 torch_dtype="auto",
7)
8model.cuda()
9inputs = tokenizer("import torch\nimport torch.nn as nn", return_tensors="pt").to(model.device)
10tokens = model.generate(
11 **inputs,
12 max_new_tokens=48,
13 temperature=0.2,
14 do_sample=True,
15)
16print(tokenizer.decode(tokens[0], skip_special_tokens=True))1from transformers import AutoModelForCausalLM, AutoTokenizer
2tokenizer = AutoTokenizer.from_pretrained("stabilityai/stable-code-3b")
3model = AutoModelForCausalLM.from_pretrained(
4 "stabilityai/stable-code-3b",
5 torch_dtype="auto",
6 attn_implementation="flash_attention_2",
7)
8model.cuda()
9inputs = 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)
10tokens = model.generate(
11 **inputs,
12 max_new_tokens=48,
13 temperature=0.2,
14 do_sample=True,
15)
16print(tokenizer.decode(tokens[0], skip_special_tokens=True))1from transformers import AutoModelForCausalLM, AutoTokenizer
2tokenizer = AutoTokenizer.from_pretrained("stabilityai/stable-code-3b", trust_remote_code=True)
3model = AutoModelForCausalLM.from_pretrained(
4 "stabilityai/stable-code-3b",
5 trust_remote_code=True,
6 torch_dtype="auto",
7+ attn_implementation="flash_attention_2",
8)
9model.cuda()
10inputs = tokenizer("import torch\nimport torch.nn as nn", return_tensors="pt").to(model.device)
11tokens = model.generate(
12 **inputs,
13 max_new_tokens=48,
14 temperature=0.2,
15 do_sample=True,
16)
17print(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.ai| 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 <FIM_PREFIX> and <FIM_SUFFIX> along with other special tokens.bfloat16 precision, optimized with AdamW.stable-code-3b was trained on the Stability AI cluster across 256 NVIDIA A100 40GB GPUs (AWS P4d instances).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)1@misc{stable-code-3b,
2 url={[https://huggingface.co/stabilityai/stable-code-3b](https://huggingface.co/stabilityai/stable-code-3b)},
3 title={Stable Code 3B},
4 author={Pinnaparaju, Nikhil and Adithyan, Reshinth and Phung, Duy and Tow, Jonathan and Baicoianu, James and Cooper, Nathan}
5}