返回资讯中心
外部精选
软件工程
#开发者实时流

FirstPrinciples 发布 Quark:9B 可本地运行,专为物理和数学推理调优

来源标题:Quark: A 9B locally runnable reasoning model tuned for physics and math

FirstPrinciplesLabs 在 Hugging Face 发布 9B 模型 Quark,可本地运行,针对物理和数学推理做了调优。该模型基于 qwen3.5,采用 apache-2.0 许可,支持图文输入与对话,可通过 Transformers 直接调用。

Hacker News 最新otalp2026/11/12 · 5 天前30 分钟阅读

以下正文同步自 Hacker News 最新,版权归原站所有,已转换为易读排版。

Like 7

Follow

FirstPrinciples 38

Image-Text-to-Text

Transformers

Safetensors

English

qwen3_5

physics

science

reasoning

math

qwen3.5

conversational

License: apache-2.0

Model card Files Files and versions xet

Community

Deploy

Copy to bucket

Use this model 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 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 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

Browse Quantizations to use this model in llama.cpp, Ollama, LM Studio, or any compatible app.

Quark Intended use

Results HLE accuracy against model size

Q8_0 version

Throughput llama.cpp

Training data

Usage

Example

Limitations

License

Quark

Quark is a 9B reasoning model for physics, science and maths, built by FirstPrinciples. The base model is Qwen3.5-9B with additional post-training: supervised fine-tuning on our curated physics, maths and coding mix.

It outperforms the base model on a range of benchmarks, and reaches graduate-level science scores comparable to much larger open models. We also quantized the model weights to 8 bits (Q8_0) for llama.cpp; this Q8_0 version matches bf16 on every benchmark below. On the popular benchmark Hummanity's Last Exam (HLE, text-only) Quark is on the Pareto frontier of performance vs. model size: no model of its size or smaller scores higher.

Quark is the first in a series of small, powerful scientific reasoning models. You can run it locally (see Usage) or on Theo Platform, a research platform for complex problems, where you can use it alongside other frontier models, check its results with Python, Mathematica and Sage, and keep each session as a research graph you can revise one step at a time.

Intended use

Quark is built for researchers working on hard problems in physics, science and maths, where the reasoning matters as much as the answer:

Results

Accuracy (%), measured with EvalScope and vLLM (the Q8_0 version with llama.cpp): thinking mode, up to 131,072 output tokens, and following the Qwen3.5 model card's sampling settings. AIME 2025 is averaged over 16 samples per problem and GPQA Diamond over 8. HLE (text-only, 2,158 questions) is graded by Qwen3.5-27B as judge.

All were measured by us with the same setup.

Compared with other open models (scores as reported by each developer):

— = not reported. Sources: each model's official model card; Quark (bf16) and its Q8_0 version measured by us (see above)

¹ Not reported by Qwen; measured by Artificial Analysis (reasoning mode, 2,158 text-only HLE questions).

HLE (text-only) accuracy against total parameters, log scale. Quark is on the Pareto frontier: no model of its size or smaller scores higher. The next model up the frontier, Qwen3.8 27B, is roughly three times its size.

All 37 models of 7–10.5B parameters scored by Artificial Analysis. Quark leads K2 Horizon 7B by 4.5 points.

Quark is measured by us; every other model by Artificial Analysis on the same 2,158 questions with its own grader (data retrieved November 2026). Mixture-of-experts models are plotted at their total size, and models without a published parameter count aren't shown.

Q8_0 version

A Q8_0 version (model weights quantized to 8 bits) for llama.cpp (in GGUF format) is available at FirstPrinciplesLabs/quark_quantized_weight_only-Q8_0. Its accuracy is in the Results table: it matches Quark on all benchmarks. It is also on Ollama as FirstPrinciples/quark-q8 (see Usage).

Throughput

Tokens per second on an NVIDIA H200 and a MacBook Pro, for the original bf16 weights and the Q8_0 version.

llama.cpp

Throughput (token/s) for a single user with llama.cpp, by how much context is already filled.

On the MacBook Pro (M4, 16 GB), with the Q8_0 version serving several requests at once (llama-server --parallel N):

Training data

Quark was fine-tuned on our curated mix of about 200,000 physics, science, maths and coding problems, each with a worked solution written by Qwen3.8-Flash-Next. Solutions were filtered by rejection sampling, keeping only correct ones. Duplicate questions were removed, and so was any question that shares at least half of a benchmark question's word 13-grams (after lower-casing and keeping only letters and digits). We checked against the full GPQA Diamond, AIME 2025, MATH-500, MMLU-Pro, SuperGPQA and HLE (text-only) sets.

Usage

Quark runs anywhere Qwen3.5-9B does (Transformers, vLLM, SGLang). We recommend an output budget of 131,072 tokens for best performance.

With Transformers (pip install -U transformers accelerate; the bf16 weights need about 20 GB of GPU memory):

from transformers import AutoModelForCausalLM, AutoTokenizer

model_id = "FirstPrinciplesLabs/quark" tokenizer = AutoTokenizer.from_pretrained(model_id) model = AutoModelForCausalLM.from_pretrained(model_id, dtype="auto", device_map="auto")

messages = [{"role": "user", "content": ( "A particle is in the ground state of a 1D infinite square well of width L. The well suddenly expands to " "width 2L. What is the probability of finding the particle in the ground state of the new well?" )}] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, enable_thinking=True, return_tensors="pt", return_dict=True ).to(model.device)

output = model.generate( **inputs, max_new_tokens=32768, # hard problems can need up to 131,072 do_sample=True, temperature=1.0, top_p=0.95, top_k=20, ) text = tokenizer.decode(output[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)

thinking, finished, answer = text.partition("</think>") if not finished: print("Stopped while still thinking; raise max_new_tokens.") print(answer.strip()) # expected: 32 / (9 pi^2), about 0.36

To serve it with vLLM:

vllm serve FirstPrinciplesLabs/quark
--max-model-len 135168 --reasoning-parser qwen3

Or run it locally with Ollama (BF16 weights, with the recommended sampling settings and a 131,072-token context built in):

ollama run firstprinciples/quark

For the Q8_0 version with Ollama (about 10 GB; the same sampling settings and 131,072-token context built in):

ollama run FirstPrinciples/quark-q8

A 131,072-token context needs about 15 GB of GPU memory. On a 16 GB Mac, lower it inside the chat with /set parameter num_ctx 32768 (longer answers are then cut off).

llama-server -hf FirstPrinciplesLabs/quark_quantized_weight_only-Q8_0 --jinja -c 131072
--temp 1.0 --top-k 20 --top-p 0.95 --presence-penalty 1.5

Recommended sampling (from the Qwen3.5 model card):

Example

A hard problem from AIME 2025 (II, problem 15), in thinking mode with the recommended sampling settings:

Let f(x)=(x−18)(x−72)(x−98)(x−k)xf(x)=\dfrac{(x-18)(x-72)(x-98)(x-k)}{x}f(x)=x(x−18)(x−72)(x−98)(x−k)​. There exist exactly three positive real values of kkk such that fff has a minimum at exactly two real values of xxx. Find the sum of these three values of kkk.

How Quark solves it (summarised from its answer):

(x−18)(x−72)(x−98)(x−k)−mx=(x−u)2(x−v)2. (x-18)(x-72)(x-98)(x-k)-mx=(x-u)^2(x-v)^2 . (x−18)(x−72)(x−98)(x−k)−mx=(x−u)2(x−v)2.

(k2−376k−5120)2=8128512 k. (k^2-376k-5120)^2 = 8128512,k . (k2−376k−5120)2=8128512k.

Both models' full written answers (each follows several thousand tokens of reasoning, not shown):

We interpret “ fff has a minimum at exactly two real values of xxx” as meaning that the minimum value is attained at exactly two distinct xxx-values (the intended interpretation; otherwise fff has no global minimum on all real x≠0x\neq0x=0).

P(x)=(x−18)(x−72)(x−98)(x−k). P(x)=(x-18)(x-72)(x-98)(x-k). P(x)=(x−18)(x−72)(x−98)(x−k).

18+72+98=188, 18+72+98=188, 18+72+98=188,

18⋅72+18⋅98+72⋅98=10116, 18\cdot72+18\cdot98+72\cdot98=10116, 18⋅72+18⋅98+72⋅98=10116,

18⋅72⋅98=127008. 18\cdot72\cdot98=127008. 18⋅72⋅98=127008.

P(x)=x4−(k+188)x3+(10116+188k)x2−(127008+10116k)x+127008k. P(x)=x^4-(k+188)x^3+(10116+188k)x^2-(127008+10116k)x+127008k. P(x)=x4−(k+188)x3+(10116+188k)x2−(127008+10116k)x+127008k.

Suppose the minimum value is mmm, attained at two distinct xxx-values u≠vu\neq vu=v. Then f(x)−mf(x)-mf(x)−m has double zeros at uuu and vvv. Since

x(f(x)−m)=P(x)−mx, x(f(x)-m)=P(x)-mx, x(f(x)−m)=P(x)−mx,

P(x)−mx=(x−u)2(x−v)2. P(x)-mx=(x-u)

正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。

打开原文
去社区讨论 →