Run this model with HF Jobs
Run bigcode/starcoder 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/starcoder. Ask me which dataset to train on, then push the fine-tuned model to a new private 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/starcoder 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/starcoder. Ask me which benchmark to run, then save the scores and the per-example results to a new private 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/starcoder. Push it to a new private 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/starcoder with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use bigcode/starcoder with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="bigcode/starcoder")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("bigcode/starcoder") model = AutoModelForCausalLM.from_pretrained("bigcode/starcoder", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use bigcode/starcoder with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "bigcode/starcoder" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "bigcode/starcoder", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/bigcode/starcoder
- SGLang
How to use bigcode/starcoder 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/starcoder" \ --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/starcoder", "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/starcoder" \ --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/starcoder", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use bigcode/starcoder with Docker Model Runner:
docker model run hf.co/bigcode/starcoder
Inconsistent Results Between HF Inference API and StarCoder Playground for Code Completion Task
Hello,
I am currently facing an issue with the Hugging Face (HF) Inference API when trying to perform code completion tasks using the StarCoder model. Although I follow the provided examples and match my API call parameters to those in the StarCoder Playground, my requests often return an empty string, or, if I adjust the temperature parameter closer to zero, the output becomes nonsensical and impractical. This happens with prompts that return valid and meaningful completions on the StarCoder Playground and web inference API next to the model card. I also observe inconsistencies between the StarCoder Playground and the web inference API next to the model card.
Technical Details:
Here's how I structure my API calls:
def query(self, payload):
response = requests.post(API_URL, headers=headers, json=payload)
return response.json()
def _draw_sample(self, prompt: str, temperature=0.2, max_new_tokens=256, top_p=0.9, repetition_penalty=1.2) -> str:
# Define the payload with the modified prompt and additional parameters
payload = {
"inputs": prompt,
"parameters": {
"temperature": temperature,
"max_new_tokens": max_new_tokens,
"top_p": top_p,
"repetition_penalty": repetition_penalty,
"return_full_text": False,
"do_sample": True,
},
"options": {"use_cache": True}
}
response = self.query(payload)
logging.info(f"response from LLM is {response}")
# Extract the generated code from the response
return response
Prompt Details:
The prompt includes a docstring that describes the script's functionality and a brief explanation of the code completion task (e.g., 'Improve priority_v1 over priority_v0 from the previous iteration'), context functions, the function from the previous iteration, and finally, the function header and docstring for which StarCoder is expected to generate the body.
Any help understanding the reason for the discrepancy between the API and Playground results or alternative approaches to structuring my prompt and API requests would be greatly appreciated.
Thank you!
Attached below are screenshots showcasing the outputs on the Playground and the web inference tool next to the model card for comparison.
