Text Generation
Transformers
PyTorch
code
gpt2
custom_code
Eval Results (legacy)
text-generation-inference
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
Update README.md
Browse files182 unmodified lines183184185186182 unmodified linesverified: false---# SantaCoder182 unmodified lines183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298182 unmodified linesverified: false---# SantaCoder# Table of Contents1. [Model Summary](#model-summary)2. [Use](#use)3. [Limitations](#limitations)4. [Training](#training)5. [Citation](#citation)# Model SummaryThe SantaCoder models are a series of 1B parameter models trained on Python, Java, and JavaScript. They were trained on datasets with different filter parameters and with architecture and objective variations. The main model uses multi-query attention, was trained using near-deduplication and commnent-to-code ratio as filtering criteria and using the Fill-in-the-Middle objective.- **Repository:** [bigcode/Megatron-LM](https://github.com/bigcode-project/Megatron-LM)- **Project Website:** [bigcode-project.org]www.bigcode-project.org)- **Paper:** [Coming soon]()- **Point of Contact:** [contact@bigcode-project.org](mailto: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 ||`dedup-alt-comments`| MQA | AR + FIM | Stronger near-deduplication and comment-to-code ratio |The `dedup-alt-comments` model is the best performing model and was trained twice as long as the others. This checkpoint is available here on the `main`# Use## Intended use**Feel free to share your generations in the Community tab!**## How to use### Generation```python# pip install -q transformersfrom transformers import AutoModelForCausalLM, AutoTokenizercheckpoint = "bigcode/santacoder"device = "cuda" # for GPU usage or "cpu" for CPU usagetokenizer = AutoTokenizer.from_pretrained(checkpoint)model = AutoModelForCausalLM.from_pretrained(checkpoint, trust_remote_code=True).to()inputs = tokenizer.encode("def print_hello_world():", return_tensors="pt").to(device)outputs = model.generate(inputs)print(tokenizer.decode(outputs[0]))```### Fill-in-the-middleFill-in-the-mid uses special tokens to identify the prefix/middle/suffic part of the input and output:```pythoninput_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]))```### Load other checkpointsWe upload the checkpoint of each experiment to a seperate branch as well as the intermediate checkpoints as commits on the branches. You can load them with the `revision` flag:```pythoncheckpoint = "bigcode/santacoder"revision = "no-fim" # name of branch or commit hashmodel = AutoModelForCausalLM.from_pretrained(checkpoint, revision=revision, trust_remote_code=True).to(device)```### AttributionThe pretraining dataset of the model was filtered for permissive licenses only. Nevertheless, the model can generate source code verbatim from the dataset which requires attribution. We provide a [search index](TODO) that let's you search through the pretraining data to identify where generated code came from and apply the proper attribution to your code.# LimitationsThe 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](https://github.com/bigcode-project/Megatron-LM)- **Neural networks:** [PyTorch](https://github.com/pytorch/pytorch)- **FP16 if applicable:** [apex](https://github.com/NVIDIA/apex)# Citation**TODO**
README.md+113-1