Run this model with HF Jobs
Run bigcode/santacoder on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/bigcode/santacoder. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/bigcode/santacoder on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/bigcode/santacoder. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/bigcode/santacoder. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use bigcode/santacoder with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use bigcode/santacoder with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="bigcode/santacoder", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("bigcode/santacoder", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("bigcode/santacoder", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use bigcode/santacoder with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "bigcode/santacoder" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "bigcode/santacoder", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/bigcode/santacoder
- SGLang
How to use bigcode/santacoder with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "bigcode/santacoder" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "bigcode/santacoder", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "bigcode/santacoder" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "bigcode/santacoder", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use bigcode/santacoder with Docker Model Runner:
docker model run hf.co/bigcode/santacoder
SantaCoder
Play with the model on the SantaCoder Space Demo.
Table of Contents
Model Summary
The SantaCoder models are a series of 1.1B parameter models trained on the Python, Java, and JavaScript subset of The Stack (v1.1) (which excluded opt-out requests). The main model uses Multi Query Attention, a context window of 2048 tokens, and was trained using near-deduplication and comment-to-code ratio as filtering criteria and using the Fill-in-the-Middle objective. In addition there are several models that were trained on datasets with different filter parameters and with architecture and objective variations.
- Repository: bigcode/Megatron-LM
- Project Website: bigcode-project.org
- Paper: π SantaCoder: Don't reach for the stars!π
- Point of Contact: contact@bigcode-project.org
- Languages: Python, Java, and JavaScript
| Model | Architecture | Objective | Filtering |
|---|---|---|---|
mha |
MHA | AR + FIM | Base |
no-fim |
MQA | AR | Base |
fim |
MQA | AR + FIM | Base |
stars |
MQA | AR + FIM | GitHub stars |
fertility |
MQA | AR + FIM | Tokenizer fertility |
comments |
MQA | AR + FIM | Comment-to-code ratio |
dedup-alt |
MQA | AR + FIM | Stronger near-deduplication |
final |
MQA | AR + FIM | Stronger near-deduplication and comment-to-code ratio |
The final model is the best performing model and was trained twice as long (236B tokens) as the others. This checkpoint is the default model and available on the main branch. All other checkpoints are on separate branches with according names.
Use
Intended use
The model was trained on GitHub code. As such it is not an instruction model and commands like "Write a function that computes the square root." do not work well.
You should phrase commands like they occur in source code such as comments (e.g. # the following function computes the sqrt) or write a function signature and docstring and let the model complete the function body.
Feel free to share your generations in the Community tab!
How to use
Generation
# pip install -q transformers
from transformers import AutoModelForCausalLM, AutoTokenizer
checkpoint = "bigcode/santacoder"
device = "cuda" # for GPU usage or "cpu" for CPU usage
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
model = AutoModelForCausalLM.from_pretrained(checkpoint, trust_remote_code=True).to(device)
inputs = tokenizer.encode("def print_hello_world():", return_tensors="pt").to(device)
outputs = model.generate(inputs)
print(tokenizer.decode(outputs[0]))
Fill-in-the-middle
Fill-in-the-middle uses special tokens to identify the prefix/middle/suffix part of the input and output:
input_text = "<fim-prefix>def print_hello_world():\n <fim-suffix>\n print('Hello world!')<fim-middle>"
inputs = tokenizer.encode(input_text, return_tensors="pt").to(device)
outputs = model.generate(inputs)
print(tokenizer.decode(outputs[0]))
Make sure to use <fim-prefix>, <fim-suffix>, <fim-middle> and not <fim_prefix>, <fim_suffix>, <fim_middle> as in StarCoder models.
Load other checkpoints
We upload the checkpoint of each experiment to a separate branch as well as the intermediate checkpoints as commits on the branches. You can load them with the revision flag:
model = AutoModelForCausalLM.from_pretrained(
"bigcode/santacoder",
revision="no-fim", # name of branch or commit hash
trust_remote_code=True
)
Attribution & Other Requirements
The pretraining dataset of the model was filtered for permissive licenses only. Nevertheless, the model can generate source code verbatim from the dataset. The code's license might require attribution and/or other specific requirements that must be respected. We provide a search index that let's you search through the pretraining data to identify where generated code came from and apply the proper attribution to your code.
Limitations
The model has been trained on source code in Python, Java, and JavaScript. The predominant language in source is English although other languages are also present. As such the model is capable to generate code snippets provided some context but the generated code is not guaranteed to work as intended. It can be inefficient, contain bugs or exploits.
Training
Model
- Architecture: GPT-2 model with multi-query attention and Fill-in-the-Middle objective
- Pretraining steps: 600K
- Pretraining tokens: 236 billion
- Precision: float16
Hardware
- GPUs: 96 Tesla V100
- Training time: 6.2 days
- Total FLOPS: 2.1 x 10e21
Software
- Orchestration: Megatron-LM
- Neural networks: PyTorch
- FP16 if applicable: apex
License
The model is licensed under the BigCode OpenRAIL-M v1 license agreement. You can find the full agreement here.
Citation
@article{allal2023santacoder,
title={SantaCoder: don't reach for the stars!},
author={Allal, Loubna Ben and Li, Raymond and Kocetkov, Denis and Mou, Chenghao and Akiki, Christopher and Ferrandis, Carlos Munoz and Muennighoff, Niklas and Mishra, Mayank and Gu, Alex and Dey, Manan and others},
journal={arXiv preprint arXiv:2301.03988},
year={2023}
}
- Downloads last month
- 6,602
Model tree for bigcode/santacoder
Dataset used to train bigcode/santacoder
Spaces using bigcode/santacoder 100
Papers for bigcode/santacoder
SantaCoder: don't reach for the stars!
Efficient Training of Language Models to Fill in the Middle
Fast Transformer Decoding: One Write-Head is All You Need
Evaluation results
- pass@1 on MultiPL HumanEval (Python)self-reported0.180
- pass@10 on MultiPL HumanEval (Python)self-reported0.290
- pass@100 on MultiPL HumanEval (Python)self-reported0.490
- pass@1 on MultiPL MBPP (Python)self-reported0.350
- pass@10 on MultiPL MBPP (Python)self-reported0.580
- pass@100 on MultiPL MBPP (Python)self-reported0.770
- pass@1 on MultiPL HumanEval (JavaScript)self-reported0.160
- pass@10 on MultiPL HumanEval (JavaScript)self-reported0.270

docker model run hf.co/bigcode/santacoder