Text Generation
Transformers
Safetensors
starcoder2
text-generation-inference
4-bit precision
bitsandbytes
Instructions to use onekq-ai/starcoder2-7b-bnb-4bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use onekq-ai/starcoder2-7b-bnb-4bit with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="onekq-ai/starcoder2-7b-bnb-4bit")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("onekq-ai/starcoder2-7b-bnb-4bit") model = AutoModelForCausalLM.from_pretrained("onekq-ai/starcoder2-7b-bnb-4bit") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use onekq-ai/starcoder2-7b-bnb-4bit with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "onekq-ai/starcoder2-7b-bnb-4bit" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "onekq-ai/starcoder2-7b-bnb-4bit", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/onekq-ai/starcoder2-7b-bnb-4bit
- SGLang
How to use onekq-ai/starcoder2-7b-bnb-4bit 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 "onekq-ai/starcoder2-7b-bnb-4bit" \ --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": "onekq-ai/starcoder2-7b-bnb-4bit", "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 "onekq-ai/starcoder2-7b-bnb-4bit" \ --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": "onekq-ai/starcoder2-7b-bnb-4bit", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use onekq-ai/starcoder2-7b-bnb-4bit with Docker Model Runner:
docker model run hf.co/onekq-ai/starcoder2-7b-bnb-4bit
Update README.md
Browse files
README.md
CHANGED
|
@@ -10,7 +10,7 @@ Bitsandbytes quantization of https://huggingface.co/bigcode/starcoder2-7b.
|
|
| 10 |
See https://huggingface.co/blog/4bit-transformers-bitsandbytes for instructions.
|
| 11 |
|
| 12 |
```python
|
| 13 |
-
from transformers import AutoModelForCausalLM
|
| 14 |
from transformers import BitsAndBytesConfig
|
| 15 |
import torch
|
| 16 |
|
|
@@ -21,5 +21,8 @@ nf4_config = BitsAndBytesConfig(
|
|
| 21 |
bnb_4bit_compute_dtype=torch.bfloat16
|
| 22 |
)
|
| 23 |
model = AutoModelForCausalLM.from_pretrained("bigcode/starcoder2-7b", quantization_config=nf4_config)
|
|
|
|
|
|
|
| 24 |
model.push_to_hub("onekq-ai/starcoder2-7b-bnb-4bit")
|
|
|
|
| 25 |
```
|
|
|
|
| 10 |
See https://huggingface.co/blog/4bit-transformers-bitsandbytes for instructions.
|
| 11 |
|
| 12 |
```python
|
| 13 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 14 |
from transformers import BitsAndBytesConfig
|
| 15 |
import torch
|
| 16 |
|
|
|
|
| 21 |
bnb_4bit_compute_dtype=torch.bfloat16
|
| 22 |
)
|
| 23 |
model = AutoModelForCausalLM.from_pretrained("bigcode/starcoder2-7b", quantization_config=nf4_config)
|
| 24 |
+
tokenizer = AutoTokenizer.from_pretrained("bigcode/starcoder2-7b")
|
| 25 |
+
|
| 26 |
model.push_to_hub("onekq-ai/starcoder2-7b-bnb-4bit")
|
| 27 |
+
tokenizer.push_to_hub("onekq-ai/starcoder2-7b-bnb-4bit")
|
| 28 |
```
|