Instructions to use MathAndMagic/polaris-small with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MathAndMagic/polaris-small with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="MathAndMagic/polaris-small") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("MathAndMagic/polaris-small") model = AutoModelForCausalLM.from_pretrained("MathAndMagic/polaris-small", 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=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use MathAndMagic/polaris-small with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "MathAndMagic/polaris-small" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MathAndMagic/polaris-small", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/MathAndMagic/polaris-small
- SGLang
How to use MathAndMagic/polaris-small 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 "MathAndMagic/polaris-small" \ --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": "MathAndMagic/polaris-small", "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 "MathAndMagic/polaris-small" \ --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": "MathAndMagic/polaris-small", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use MathAndMagic/polaris-small with Docker Model Runner:
docker model run hf.co/MathAndMagic/polaris-small
Update README.md
Browse files
README.md
CHANGED
|
@@ -90,6 +90,43 @@ For now, the model is only capable of calling one function at a time.
|
|
| 90 |
<|fn_start|>{"name": "generate_password", "arguments": {"length": 42}}<|fn_end|>
|
| 91 |
```
|
| 92 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
### Model Description
|
| 95 |
|
|
|
|
| 90 |
<|fn_start|>{"name": "generate_password", "arguments": {"length": 42}}<|fn_end|>
|
| 91 |
```
|
| 92 |
|
| 93 |
+
## Function Call Response
|
| 94 |
+
|
| 95 |
+
The model expects the function call response to be provided right after the function call request from a role `fn`:
|
| 96 |
+
|
| 97 |
+
```
|
| 98 |
+
<|im_start|>fn
|
| 99 |
+
{"result": "87cc47fbc865a290d7c7de4be3c893175c51a566b3"}<|im_end|>
|
| 100 |
+
```
|
| 101 |
+
|
| 102 |
+
There are no specific requirements on the response format. Feel free to respond with anything you want.
|
| 103 |
+
|
| 104 |
+
## Example Conversation
|
| 105 |
+
|
| 106 |
+
> Newlines after the `<|im_end|>` are included here only for ease of reading. In the actual chat template, we don't use newlines in this position.
|
| 107 |
+
|
| 108 |
+
```
|
| 109 |
+
<|im_start|>system
|
| 110 |
+
## Configuration
|
| 111 |
+
|
| 112 |
+
Functions: enabled
|
| 113 |
+
|
| 114 |
+
## Available Functions
|
| 115 |
+
|
| 116 |
+
{"name": "generate_password", "description": "Generate a random password", "parameters": {"type": "object", "properties": {"length": {"type": "integer", "description": "The length of the password"}}, "required": ["length"]}}
|
| 117 |
+
|
| 118 |
+
---
|
| 119 |
+
|
| 120 |
+
You are a helpful assistant.<|im_end|>
|
| 121 |
+
<|im_start|>user
|
| 122 |
+
Generate a password, 42 characters long<|im_end|>
|
| 123 |
+
<|im_start|>assistant
|
| 124 |
+
<|fn_start|>{"name": "generate_password", "arguments": {"length": 42}}<|fn_end|><|im_end|>
|
| 125 |
+
<|im_start|>fn
|
| 126 |
+
{"result": "87cc47fbc865a290d7c7de4be3c893175c51a566b3"}<|im_end|>
|
| 127 |
+
<|im_start|>assistant
|
| 128 |
+
Here is your random password: 87cc47fbc865a290d7c7de4be3c893175c51a566b3. Please make sure to save it in a secure place.<|im_end|>
|
| 129 |
+
```
|
| 130 |
|
| 131 |
### Model Description
|
| 132 |
|