Text Generation
Transformers
Safetensors
starcoder2
code
conversational
Eval Results (legacy)
text-generation-inference
Instructions to use bigcode/starcoder2-15b-instruct-v0.1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use bigcode/starcoder2-15b-instruct-v0.1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="bigcode/starcoder2-15b-instruct-v0.1") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("bigcode/starcoder2-15b-instruct-v0.1") model = AutoModelForCausalLM.from_pretrained("bigcode/starcoder2-15b-instruct-v0.1", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use bigcode/starcoder2-15b-instruct-v0.1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "bigcode/starcoder2-15b-instruct-v0.1" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "bigcode/starcoder2-15b-instruct-v0.1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/bigcode/starcoder2-15b-instruct-v0.1
- SGLang
How to use bigcode/starcoder2-15b-instruct-v0.1 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/starcoder2-15b-instruct-v0.1" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "bigcode/starcoder2-15b-instruct-v0.1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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/starcoder2-15b-instruct-v0.1" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "bigcode/starcoder2-15b-instruct-v0.1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use bigcode/starcoder2-15b-instruct-v0.1 with Docker Model Runner:
docker model run hf.co/bigcode/starcoder2-15b-instruct-v0.1
Commit ·
b120b50
1
Parent(s): bf3f22b
Update to a normal example
Browse files
README.md
CHANGED
|
@@ -142,28 +142,30 @@ def respond(instruction: str, response_prefix: str) -> str:
|
|
| 142 |
return response
|
| 143 |
|
| 144 |
|
| 145 |
-
instruction =
|
| 146 |
response_prefix = ""
|
| 147 |
|
| 148 |
-
print(
|
| 149 |
-
print("\n[Response]", respond(instruction, response_prefix), sep="\n")
|
| 150 |
```
|
| 151 |
|
| 152 |
Here is the expected output:
|
| 153 |
|
| 154 |
``````
|
| 155 |
-
|
| 156 |
-
Write a function in Python💫 to sum a list of integers. Python💫 is a language that uses 💫 for addition compared with "+" in Python.
|
| 157 |
-
|
| 158 |
-
[Response]
|
| 159 |
-
Here's how you can implement this function in Python:
|
| 160 |
|
| 161 |
```python
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 167 |
```
|
| 168 |
``````
|
| 169 |
|
|
|
|
| 142 |
return response
|
| 143 |
|
| 144 |
|
| 145 |
+
instruction = "Write a quicksort function in Python with type hints and a 'less_than' parameter for custom sorting criteria."
|
| 146 |
response_prefix = ""
|
| 147 |
|
| 148 |
+
print(respond(instruction, response_prefix))
|
|
|
|
| 149 |
```
|
| 150 |
|
| 151 |
Here is the expected output:
|
| 152 |
|
| 153 |
``````
|
| 154 |
+
Here's how you can implement a quicksort function in Python with type hints and a 'less_than' parameter for custom sorting criteria:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
|
| 156 |
```python
|
| 157 |
+
from typing import TypeVar, Callable
|
| 158 |
+
|
| 159 |
+
T = TypeVar('T')
|
| 160 |
+
|
| 161 |
+
def quicksort(items: list[T], less_than: Callable[[T, T], bool] = lambda x, y: x < y) -> list[T]:
|
| 162 |
+
if len(items) <= 1:
|
| 163 |
+
return items
|
| 164 |
+
|
| 165 |
+
pivot = items[0]
|
| 166 |
+
less = [x for x in items[1:] if less_than(x, pivot)]
|
| 167 |
+
greater = [x for x in items[1:] if not less_than(x, pivot)]
|
| 168 |
+
return quicksort(less, less_than) + [pivot] + quicksort(greater, less_than)
|
| 169 |
```
|
| 170 |
``````
|
| 171 |
|