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")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("bigcode/starcoder") model = AutoModelForCausalLM.from_pretrained("bigcode/starcoder") - 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
How to train with long inputs (Training memory requirement)
Hi,
StarCoder supports input up to 8192 tokens, so I assume you also train the model with such long input. But when I was trying to fine-tune it, I found I cannot even use input with 2048 tokens.
Even with 4 A100 80G, and half precision enabled, deepspeed's ZERO3 enabled, param/optimizer offload opened, and gradient checkpointing enabled. I still got OOM with even batch_size_per_gpu set to 1. And I monitor the GPU usage, it seems the forward of 2048 tokens already take all the GPU memory. That means, the OOM happened even before the backward() is called
I wonder how could you train it with even longer inputs? Or any suggestions on training/fine-tuning with long inputs? Thank you!
We used tensor parallelism and pipeline parallelism when training with Megatron-LM to split the model on multiple GPUs (you can find details here). You can also use PEFT fine-tuning which requires much less memory and will allow you to fit a large context (example here)
Hello @loubnabnl with Tensor parallelism=4 and pipeline parallelism=4, we need 4*4 16GPUs right, correct me if i am wrong.
Even with peft-lora I am not able to finetune on 8K with 6 A100 40GB GPUs, even with qlora also i am not able to train starcoder model on 8K.
Any Suggestions? Am i missing anything? Please Suggest. Thank you!