Instructions to use amd/Instella-3B-Math-SFT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use amd/Instella-3B-Math-SFT with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="amd/Instella-3B-Math-SFT", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("amd/Instella-3B-Math-SFT", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use amd/Instella-3B-Math-SFT with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "amd/Instella-3B-Math-SFT" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "amd/Instella-3B-Math-SFT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/amd/Instella-3B-Math-SFT
- SGLang
How to use amd/Instella-3B-Math-SFT 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 "amd/Instella-3B-Math-SFT" \ --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": "amd/Instella-3B-Math-SFT", "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 "amd/Instella-3B-Math-SFT" \ --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": "amd/Instella-3B-Math-SFT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use amd/Instella-3B-Math-SFT with Docker Model Runner:
docker model run hf.co/amd/Instella-3B-Math-SFT
Update README.md
Browse files
README.md
CHANGED
|
@@ -38,6 +38,31 @@ Derived from [Instella-3B-Instruct](https://huggingface.co/amd/Instella-3B-Instr
|
|
| 38 |
<em><b>Figure 1:</b> Instella-Math Training Steps</em>
|
| 39 |
</div>
|
| 40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
# Supervised Finetuning (SFT)
|
| 42 |
|
| 43 |
We perform a two-stage supervised fine-tuning process to gradually enhance the reasoning capabilities of the Instella-3B-Instruct model. The first stage we use instruction tuning for mathematical coverage. The second stage enables the model to generate in-depth analyses and structured reasoning steps, which are crucial for tackling complex problems like Olympiad-level math questions.
|
|
|
|
| 38 |
<em><b>Figure 1:</b> Instella-Math Training Steps</em>
|
| 39 |
</div>
|
| 40 |
|
| 41 |
+
## Example Usage
|
| 42 |
+
```python
|
| 43 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 44 |
+
checkpoint = "amd/Instella-3B-Math"
|
| 45 |
+
|
| 46 |
+
tokenizer = AutoTokenizer.from_pretrained(checkpoint, trust_remote_code=True)
|
| 47 |
+
model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map="auto", trust_remote_code=True)
|
| 48 |
+
|
| 49 |
+
prompt = [{"role": "user", "content": "Natalia sold clips to 48 of her friends in April, and then she sold half as many clips in May. How many clips did Natalia sell altogether in April and May? Let's think step by step and output the final answer within \\boxed{}."}]
|
| 50 |
+
inputs = tokenizer.apply_chat_template(
|
| 51 |
+
prompt,
|
| 52 |
+
add_generation_prompt=True,
|
| 53 |
+
return_tensors='pt'
|
| 54 |
+
)
|
| 55 |
+
|
| 56 |
+
tokens = model.generate(
|
| 57 |
+
inputs.to(model.device),
|
| 58 |
+
max_new_tokens=1024,
|
| 59 |
+
temperature=0.8,
|
| 60 |
+
do_sample=True
|
| 61 |
+
)
|
| 62 |
+
|
| 63 |
+
print(tokenizer.decode(tokens[0], skip_special_tokens=False))
|
| 64 |
+
```
|
| 65 |
+
|
| 66 |
# Supervised Finetuning (SFT)
|
| 67 |
|
| 68 |
We perform a two-stage supervised fine-tuning process to gradually enhance the reasoning capabilities of the Instella-3B-Instruct model. The first stage we use instruction tuning for mathematical coverage. The second stage enables the model to generate in-depth analyses and structured reasoning steps, which are crucial for tackling complex problems like Olympiad-level math questions.
|