Instructions to use duyntnet/starcoder2-7b-imatrix-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use duyntnet/starcoder2-7b-imatrix-GGUF with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="duyntnet/starcoder2-7b-imatrix-GGUF")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("duyntnet/starcoder2-7b-imatrix-GGUF", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use duyntnet/starcoder2-7b-imatrix-GGUF with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf duyntnet/starcoder2-7b-imatrix-GGUF:Q4_K_M # Run inference directly in the terminal: llama cli -hf duyntnet/starcoder2-7b-imatrix-GGUF:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf duyntnet/starcoder2-7b-imatrix-GGUF:Q4_K_M # Run inference directly in the terminal: llama cli -hf duyntnet/starcoder2-7b-imatrix-GGUF:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf duyntnet/starcoder2-7b-imatrix-GGUF:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf duyntnet/starcoder2-7b-imatrix-GGUF:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf duyntnet/starcoder2-7b-imatrix-GGUF:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf duyntnet/starcoder2-7b-imatrix-GGUF:Q4_K_M
Use Docker
docker model run hf.co/duyntnet/starcoder2-7b-imatrix-GGUF:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use duyntnet/starcoder2-7b-imatrix-GGUF with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "duyntnet/starcoder2-7b-imatrix-GGUF" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "duyntnet/starcoder2-7b-imatrix-GGUF", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/duyntnet/starcoder2-7b-imatrix-GGUF:Q4_K_M
- SGLang
How to use duyntnet/starcoder2-7b-imatrix-GGUF 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 "duyntnet/starcoder2-7b-imatrix-GGUF" \ --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": "duyntnet/starcoder2-7b-imatrix-GGUF", "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 "duyntnet/starcoder2-7b-imatrix-GGUF" \ --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": "duyntnet/starcoder2-7b-imatrix-GGUF", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Ollama
How to use duyntnet/starcoder2-7b-imatrix-GGUF with Ollama:
ollama run hf.co/duyntnet/starcoder2-7b-imatrix-GGUF:Q4_K_M
- Unsloth Studio
How to use duyntnet/starcoder2-7b-imatrix-GGUF with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for duyntnet/starcoder2-7b-imatrix-GGUF to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for duyntnet/starcoder2-7b-imatrix-GGUF to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for duyntnet/starcoder2-7b-imatrix-GGUF to start chatting
- Docker Model Runner
How to use duyntnet/starcoder2-7b-imatrix-GGUF with Docker Model Runner:
docker model run hf.co/duyntnet/starcoder2-7b-imatrix-GGUF:Q4_K_M
- Lemonade
How to use duyntnet/starcoder2-7b-imatrix-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull duyntnet/starcoder2-7b-imatrix-GGUF:Q4_K_M
Run and chat with the model
lemonade run user.starcoder2-7b-imatrix-GGUF-Q4_K_M
List all available models
lemonade list
- Atomic Chat
Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: other
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
pipeline_tag: text-generation
|
| 6 |
+
inference: false
|
| 7 |
+
tags:
|
| 8 |
+
- transformers
|
| 9 |
+
- gguf
|
| 10 |
+
- imatrix
|
| 11 |
+
- starcoder2-7b
|
| 12 |
+
---
|
| 13 |
+
Quantizations of https://huggingface.co/bigcode/starcoder2-7b
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
# From original readme
|
| 17 |
+
|
| 18 |
+
### Generation
|
| 19 |
+
Here are some examples to get started with the model. You can find a script for fine-tuning in StarCoder2's [GitHub repository](https://github.com/bigcode-project/starcoder2).
|
| 20 |
+
|
| 21 |
+
First, make sure to install `transformers` from source:
|
| 22 |
+
```bash
|
| 23 |
+
pip install git+https://github.com/huggingface/transformers.git
|
| 24 |
+
```
|
| 25 |
+
|
| 26 |
+
#### Running the model on CPU/GPU/multi GPU
|
| 27 |
+
* _Using full precision_
|
| 28 |
+
```python
|
| 29 |
+
# pip install git+https://github.com/huggingface/transformers.git # TODO: merge PR to main
|
| 30 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 31 |
+
|
| 32 |
+
checkpoint = "bigcode/starcoder2-7b"
|
| 33 |
+
device = "cuda" # for GPU usage or "cpu" for CPU usage
|
| 34 |
+
|
| 35 |
+
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
|
| 36 |
+
# for multiple GPUs install accelerate and do `model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map="auto")`
|
| 37 |
+
model = AutoModelForCausalLM.from_pretrained(checkpoint).to(device)
|
| 38 |
+
|
| 39 |
+
inputs = tokenizer.encode("def print_hello_world():", return_tensors="pt").to(device)
|
| 40 |
+
outputs = model.generate(inputs)
|
| 41 |
+
print(tokenizer.decode(outputs[0]))
|
| 42 |
+
```
|
| 43 |
+
```bash
|
| 44 |
+
>>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB")
|
| 45 |
+
Memory footprint: 29232.57 MB
|
| 46 |
+
```
|
| 47 |
+
* _Using `torch.bfloat16`_
|
| 48 |
+
```python
|
| 49 |
+
# pip install accelerate
|
| 50 |
+
import torch
|
| 51 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 52 |
+
|
| 53 |
+
checkpoint = "bigcode/starcoder2-7b"
|
| 54 |
+
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
|
| 55 |
+
|
| 56 |
+
# for fp16 use `torch_dtype=torch.float16` instead
|
| 57 |
+
model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map="auto", torch_dtype=torch.bfloat16)
|
| 58 |
+
|
| 59 |
+
inputs = tokenizer.encode("def print_hello_world():", return_tensors="pt").to("cuda")
|
| 60 |
+
outputs = model.generate(inputs)
|
| 61 |
+
print(tokenizer.decode(outputs[0]))
|
| 62 |
+
```
|
| 63 |
+
```bash
|
| 64 |
+
>>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB")
|
| 65 |
+
Memory footprint: 14616.29 MB
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
+
#### Quantized Versions through `bitsandbytes`
|
| 69 |
+
* _Using 8-bit precision (int8)_
|
| 70 |
+
|
| 71 |
+
```python
|
| 72 |
+
# pip install bitsandbytes accelerate
|
| 73 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
|
| 74 |
+
|
| 75 |
+
# to use 4bit use `load_in_4bit=True` instead
|
| 76 |
+
quantization_config = BitsAndBytesConfig(load_in_8bit=True)
|
| 77 |
+
|
| 78 |
+
checkpoint = "bigcode/starcoder2-7b"
|
| 79 |
+
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
|
| 80 |
+
model = AutoModelForCausalLM.from_pretrained(checkpoint, quantization_config=quantization_config)
|
| 81 |
+
|
| 82 |
+
inputs = tokenizer.encode("def print_hello_world():", return_tensors="pt").to("cuda")
|
| 83 |
+
outputs = model.generate(inputs)
|
| 84 |
+
print(tokenizer.decode(outputs[0]))
|
| 85 |
+
```
|
| 86 |
+
```bash
|
| 87 |
+
>>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB")
|
| 88 |
+
# load_in_8bit
|
| 89 |
+
Memory footprint: 7670.52 MB
|
| 90 |
+
# load_in_4bit
|
| 91 |
+
>>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB")
|
| 92 |
+
Memory footprint: 4197.64 MB
|
| 93 |
+
```
|