Image-Text-to-Text
Transformers
Safetensors
English
qwen3_5
physics
science
reasoning
math
qwen3.5
conversational
Instructions to use FirstPrinciplesLabs/quark with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use FirstPrinciplesLabs/quark with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="FirstPrinciplesLabs/quark") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("FirstPrinciplesLabs/quark") model = AutoModelForMultimodalLM.from_pretrained("FirstPrinciplesLabs/quark", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.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(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use FirstPrinciplesLabs/quark with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "FirstPrinciplesLabs/quark" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "FirstPrinciplesLabs/quark", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/FirstPrinciplesLabs/quark
- SGLang
How to use FirstPrinciplesLabs/quark 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 "FirstPrinciplesLabs/quark" \ --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": "FirstPrinciplesLabs/quark", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'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 "FirstPrinciplesLabs/quark" \ --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": "FirstPrinciplesLabs/quark", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use FirstPrinciplesLabs/quark with Docker Model Runner:
docker model run hf.co/FirstPrinciplesLabs/quark
Add Transformers Python example to Usage
Browse files
README.md
CHANGED
|
@@ -145,6 +145,40 @@ MMLU-Pro, SuperGPQA and HLE (text-only) sets.
|
|
| 145 |
|
| 146 |
Quark runs anywhere Qwen3.5-9B does (Transformers, vLLM, SGLang). We recommend an output budget of 131,072 tokens for best performance.
|
| 147 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
```bash
|
| 149 |
vllm serve FirstPrinciplesLabs/quark \
|
| 150 |
--max-model-len 135168 --reasoning-parser qwen3
|
|
|
|
| 145 |
|
| 146 |
Quark runs anywhere Qwen3.5-9B does (Transformers, vLLM, SGLang). We recommend an output budget of 131,072 tokens for best performance.
|
| 147 |
|
| 148 |
+
With [Transformers](https://github.com/huggingface/transformers) (`pip install -U transformers accelerate`; the bf16
|
| 149 |
+
weights need about 20 GB of GPU memory):
|
| 150 |
+
|
| 151 |
+
```python
|
| 152 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 153 |
+
|
| 154 |
+
model_id = "FirstPrinciplesLabs/quark"
|
| 155 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 156 |
+
model = AutoModelForCausalLM.from_pretrained(model_id, dtype="auto", device_map="auto")
|
| 157 |
+
|
| 158 |
+
messages = [{"role": "user", "content": (
|
| 159 |
+
"A particle is in the ground state of a 1D infinite square well of width L. The well suddenly expands to "
|
| 160 |
+
"width 2L. What is the probability of finding the particle in the ground state of the new well?"
|
| 161 |
+
)}]
|
| 162 |
+
inputs = tokenizer.apply_chat_template(
|
| 163 |
+
messages, add_generation_prompt=True, enable_thinking=True, return_tensors="pt", return_dict=True
|
| 164 |
+
).to(model.device)
|
| 165 |
+
|
| 166 |
+
output = model.generate(
|
| 167 |
+
**inputs,
|
| 168 |
+
max_new_tokens=32768, # hard problems can need up to 131,072
|
| 169 |
+
do_sample=True, temperature=1.0, top_p=0.95, top_k=20,
|
| 170 |
+
)
|
| 171 |
+
text = tokenizer.decode(output[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)
|
| 172 |
+
|
| 173 |
+
thinking, finished, answer = text.partition("</think>")
|
| 174 |
+
if not finished:
|
| 175 |
+
print("Stopped while still thinking; raise max_new_tokens.")
|
| 176 |
+
print(answer.strip()) # expected: 32 / (9 pi^2), about 0.36
|
| 177 |
+
```
|
| 178 |
+
|
| 179 |
+
Transformers' `generate` has no presence penalty, so for long answers and for serving, we recommend vLLM, which
|
| 180 |
+
supports the full recommended sampling settings:
|
| 181 |
+
|
| 182 |
```bash
|
| 183 |
vllm serve FirstPrinciplesLabs/quark \
|
| 184 |
--max-model-len 135168 --reasoning-parser qwen3
|