Run this model with HF Jobs
Run XHToken/Spark-X2.6-4B on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/XHToken/Spark-X2.6-4B. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/XHToken/Spark-X2.6-4B on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/XHToken/Spark-X2.6-4B. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/XHToken/Spark-X2.6-4B. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use XHToken/Spark-X2.6-4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use XHToken/Spark-X2.6-4B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="XHToken/Spark-X2.6-4B", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("XHToken/Spark-X2.6-4B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use XHToken/Spark-X2.6-4B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "XHToken/Spark-X2.6-4B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "XHToken/Spark-X2.6-4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/XHToken/Spark-X2.6-4B
- SGLang
How to use XHToken/Spark-X2.6-4B 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 "XHToken/Spark-X2.6-4B" \ --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": "XHToken/Spark-X2.6-4B", "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 "XHToken/Spark-X2.6-4B" \ --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": "XHToken/Spark-X2.6-4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use XHToken/Spark-X2.6-4B with Docker Model Runner:
docker model run hf.co/XHToken/Spark-X2.6-4B
Spark-X2.6-4B: Advancing the Frontier of On-Device Agents for Real-World Tasks
Thinking budget warning for short extraction tasks
For IDs, labels, and short JSON fields, turn thinking Off by passing
"chat_template_kwargs": {"enable_thinking": false}. If a field needs a reasoning step, try Low with"chat_template_kwargs": {"enable_thinking": true, "reasoning_effort": "low"}. Reasoning and the final answer share the output allowance. Even Low can reach the generation limit with empty final content. Check that the answer is present and validate the extracted value before using it. Extraction FAQ and LM Studio settings
Spark FAQ · Local runtimes · Structured extraction with Spark-X2.6-4B
This repository contains model weights and configuration files for the post-trained model in the Hugging Face Transformers format.
Introduction
A little over a month has passed since Spark-X2.5. In the rapidly evolving world of AI agents, that is enough time to rethink, refine, and move the frontier forward. Building on the Spark-X2.5-4B, we introduce Spark-X2.6-4B, the latest generation of our compact, general-purpose language models for on-device deployment.
Spark-X2.6-4B retains exactly the same architecture as Spark-X2.5-4B, achieving its capability gains through improved post-training. It delivers substantial improvements in coding, agent, long-context, multilingual, reasoning, etc. These advances enable more capable and practical on-device AI for developers and users tackling real-world tasks.
Technical Highlights:
- Stronger Coding, Agentic, and Long-Context Capabilities: The models deliver substantial improvements in agentic workflows involving complex tool use, multi-step planning, and software engineering. They achieve state-of-the-art performance among similarly sized open-source models, matching or even surpassing models with approximately 9B parameters.
- Controllable Thinking Budget: The models provide three configurable thinking levels—none, low, high—allowing applications to balance reasoning quality, latency, and inference cost dynamically.
Benchmarks
We evaluate our models and compare them with leading on-device models of similar size across a broad range of tasks, including agent, code, math, general and knowledge. Spark-X2.6-4B achieves best-in-class performance among models of comparable size, while matching or exceeding the performance of larger 9B models on several benchmarks.
Edge Inference
Spark-X2.6-4B delivers inference efficiency on par with or better than comparable on-device models, including Qwen3.5-4B and Gemma-E4B. It combines this efficiency with stronger capabilities, making it a practical choice for responsive, resource-conscious on-device AI.
Reasoning Effort Comparison
We compare high and low reasoning effort across agent, code, math, long-context, and general knowledge tasks. When switching from high to low, Spark-X2.6-1.7B average score decreases by 4.0 points, while its average output length drops by 37.3%. For Spark-X2.6-4B, the average score decreases by 1.7 points, while average output length drops by 22.0%. This flexibility allows developers to balance task performance and generation efficiency according to their application needs.
Choosing reasoning effort for a coding agent
For a short, well-specified action such as reading a named file, start with low and verify the returned tool name and arguments. For a multi-step change or an incorrect/incomplete result, retry the same input at high (the template default). Treat output length and task completion as separate measurements. A hard token budget can cut off the final answer.
Cline in VS Code with a local llama.cpp server. With a compatible build, start the server with llama-server -m MODEL.gguf --alias spark --jinja --reasoning-effort low --host 127.0.0.1 --port 8080. In Cline settings select OpenAI Compatible, set the base URL to http://127.0.0.1:8080/v1, use model ID spark, and match the context window to the server. If the server requires authentication, use its configured key. Setting the default on the server also works for clients without a per-request effort control. Cline provider settings · Cline user's report
For direct API clients, send "chat_template_kwargs": {"reasoning_effort": "low"} in the chat-completions JSON body; use "high" for the comparison. In llama.cpp, POST the same messages and template kwargs to /apply-template and inspect the rendered thinking_effort=low or thinking_effort=high marker. Then inspect the actual response: finish_reason, visible content, and tool_calls. For machine-readable output, parse the visible content with your expected schema before accepting it.
On the official 4B Q4_K_M with llama.cpp eae11d221, a one-file tool-selection probe returned one correct read_file("src/App.vue") call at both settings (40 generated tokens each). In a separate strict-JSON probe, low used 32 tokens but returned an extra closing tag and a second object; high returned one valid object in 37 tokens. These are endpoint probes with one sample per setting. Check a representative task in your own extension before adopting a default.
Cline client check. Cline CLI 3.0.76, using its OpenAI-compatible provider with --thinking low, reached the local 4B Q4_K_M server and returned 42 for 16 + 26. Even with a short system instruction, the plan-mode request used 4,106 input tokens and 15 output tokens. A 150-second client timeout interrupted the first CPU run; a 720-second timeout allowed the repeat to complete in 624 seconds. When an IDE agent appears stuck, inspect the server's prompt-processing log before changing reasoning effort. A long tool description or project context can consume time before generation starts.
Quickstart
Transformers
Install the required version with pip install transformers==4.57.1.
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "XHToken/Spark-X2.6-4B"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
trust_remote_code=True,
torch_dtype="auto",
device_map="auto",
)
messages = [{"role": "user", "content": "What is the capital of Anhui Province?"}]
inputs = tokenizer.apply_chat_template(
messages,
tokenize=True,
add_generation_prompt=True,
enable_thinking=True,
return_dict=True,
return_tensors="pt",
).to(model.device)
outputs = model.generate(
**inputs,
max_new_tokens=131072,
do_sample=True,
temperature=1.0,
top_p=0.95,
top_k=0,
)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True))
SGLang
The examples below serve a local Spark-X2.6-4B checkpoint. Set MODEL_PATH to its absolute path before starting a container:
export MODEL_PATH=/absolute/path/to/Spark-X2.6-4B
Install SGLang
Use the pre-built image that tracks the Spark-X2.6 runtime:
For NVIDIA GPUs:
docker pull lmsysorg/sglang:nightly-dev-cu13-20260827-20621aa1
For Ascend NPUs:
# A3 daily build
export SGLANG_IMAGE=quay.io/ascend/sglang:main-cann9.0.0-a3
# A2 daily build (use this instead on A2 hardware)
export SGLANG_IMAGE=quay.io/ascend/sglang:main-cann9.0.0-910b
docker pull "$SGLANG_IMAGE"
Run Inference
The following commands start an OpenAI-compatible API server configured for a maximum context length of 1,048,576 tokens. This setting requires sufficient device memory; reduce --context-length when necessary.
Server
NVIDIA GPU:
docker run --rm -it \
--gpus '"device=0"' \
--ipc=host \
-p 30000:30000 \
-v "$MODEL_PATH:/root/Spark-X2.6-4B:ro" \
lmsysorg/sglang:nightly-dev-cu13-20260827-20621aa1 \
python -m sglang.launch_server \
--model-path /root/Spark-X2.6-4B \
--served-model-name spark2.6 \
--tool-call-parser spark25 \
--reasoning-parser qwen3 \
--tp-size 1 \
--mem-fraction-static 0.8 \
--context-length 1048576 \
--chat-template /root/Spark-X2.6-4B/chat_template.jinja \
--host 0.0.0.0 \
--port 30000
Ascend NPU:
docker run -it --rm -e ASCEND_USE_FIA=1 --network=host --ipc=host --shm-size=16g \
--device=/dev/davinci0 --device=/dev/davinci1 --device=/dev/davinci2 --device=/dev/davinci3 \
--device=/dev/davinci4 --device=/dev/davinci5 --device=/dev/davinci6 --device=/dev/davinci7 \
--device=/dev/davinci8 --device=/dev/davinci9 --device=/dev/davinci10 --device=/dev/davinci11 \
--device=/dev/davinci12 --device=/dev/davinci13 --device=/dev/davinci14 --device=/dev/davinci15 \
--device=/dev/davinci_manager \
--device=/dev/devmm_svm \
--device=/dev/hisi_hdc \
--volume /usr/local/sbin:/usr/local/sbin \
--volume /usr/local/Ascend/driver:/usr/local/Ascend/driver \
--volume /usr/local/Ascend/firmware:/usr/local/Ascend/firmware \
--volume /etc/ascend_install.info:/etc/ascend_install.info \
--volume /var/queue_schedule:/var/queue_schedule \
--volume ~/.cache/:/root/.cache/ \
--volume "$MODEL_PATH:/root/Spark-X2.6-4B:ro" \
--entrypoint=python \
"$SGLANG_IMAGE" \
-m sglang.launch_server \
--model-path /root/Spark-X2.6-4B \
--served-model-name spark2.6 \
--tool-call-parser spark25 \
--reasoning-parser qwen3 \
--tp-size 1 \
--mem-fraction-static 0.8 \
--context-length 1048576 \
--chat-template /root/Spark-X2.6-4B/chat_template.jinja \
--host 0.0.0.0 \
--port 30000
Client
Thinking is enabled by default by both the chat template and the Qwen3 reasoning parser, default reasoning_effort set to "high". You can configure thinking behavior for each request through chat_template_kwargs: set reasoning_effort to "low" or "high", such as "chat_template_kwargs": {"reasoning_effort": "low"}, or set "chat_template_kwargs": {"enable_thinking": false} to disable thinking.
curl -s http://localhost:30000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "spark2.6",
"messages": [
{
"role": "user",
"content": "安徽的省会在哪里?"
}
],
"chat_template_kwargs": {"reasoning_effort": "low"},
"max_tokens": 131072,
"temperature": 1,
"top_k": -1,
"top_p": 0.95,
"repetition_penalty": 1,
"presence_penalty": 0,
"frequency_penalty": 0
}'
vLLM
Deploy vLLM
vLLM provides an official Docker image for NVIDIA GPU deployment:
docker run --rm --gpus all \
--ipc=host \
-p 30000:30000 \
-v "$MODEL_PATH:/models/Spark-X2.6-4B:ro" \
vllm/vllm-openai:latest \
--model /models/Spark-X2.6-4B \
--port 30000 \
--trust-remote-code \
--served-model-name spark25 \
--tensor-parallel-size 1 \
--gpu-memory-utilization 0.7 \
--enable-prefix-caching \
--chat-template /models/Spark-X2.6-4B/chat_template.jinja
For Ascend NPUs, choose an official image for the fastest setup.
Ascend A2:
export IMAGE=quay.io/ascend/vllm-ascend:nightly-main
docker pull "$IMAGE"
export DEVICE=/dev/davinci0
export MODEL_CACHE="${HOME}/.cache"
mkdir -p "$MODEL_CACHE"
docker run --rm \
--name vllm-ascend \
--shm-size=1g \
--device "$DEVICE" \
--device /dev/davinci_manager \
--device /dev/devmm_svm \
--device /dev/hisi_hdc \
-v /usr/local/dcmi:/usr/local/dcmi \
-v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi \
-v /usr/local/Ascend/driver/lib64/:/usr/local/Ascend/driver/lib64/ \
-v /usr/local/Ascend/driver/version.info:/usr/local/Ascend/driver/version.info \
-v /etc/ascend_install.info:/etc/ascend_install.info \
-v "$MODEL_CACHE:/root/.cache" \
-p 8000:8000 \
-it "$IMAGE" bash
Ascend A3:
export IMAGE=quay.io/ascend/vllm-ascend:nightly-main-a3
docker pull "$IMAGE"
export DEVICE0=/dev/davinci0
export DEVICE1=/dev/davinci1
export MODEL_CACHE="${HOME}/.cache"
mkdir -p "$MODEL_CACHE"
docker run --rm \
--name vllm-ascend \
--shm-size=1g \
--device "$DEVICE0" \
--device "$DEVICE1" \
--device /dev/davinci_manager \
--device /dev/devmm_svm \
--device /dev/hisi_hdc \
-v /usr/local/dcmi:/usr/local/dcmi \
-v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi \
-v /usr/local/Ascend/driver/lib64/:/usr/local/Ascend/driver/lib64/ \
-v /usr/local/Ascend/driver/version.info:/usr/local/Ascend/driver/version.info \
-v /etc/ascend_install.info:/etc/ascend_install.info \
-v "$MODEL_CACHE:/root/.cache" \
-p 8000:8000 \
-it "$IMAGE" bash
Ascend 950DT:
export IMAGE=quay.io/ascend/vllm-ascend:nightly-main-a5
docker pull "$IMAGE"
export MODEL_CACHE="${HOME}/.cache"
mkdir -p "$MODEL_CACHE"
docker run --rm \
--name vllm-ascend \
--net=host \
--shm-size=1g \
--device /dev/davinci0 \
--device /dev/davinci_manager \
--device /dev/devmm_svm \
--device /dev/hisi_hdc \
-v /usr/local/dcmi:/usr/local/dcmi \
-v /usr/local/Ascend/driver/tools/hccn_tool:/usr/local/Ascend/driver/tools/hccn_tool \
-v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi \
-v /usr/local/Ascend/driver/lib64/:/usr/local/Ascend/driver/lib64/ \
-v /usr/local/Ascend/driver/version.info:/usr/local/Ascend/driver/version.info \
-v /etc/ascend_install.info:/etc/ascend_install.info \
-v "$MODEL_CACHE:/root/.cache" \
-it "$IMAGE" bash
Install the Spark plugin inside the container:
pip install uv
uv venv ~/spark2_6
source ~/spark2_6/bin/activate
git clone https://github.com/XHToken/Spark-plugin.git
cd ./Spark-plugin
uv pip install .
Server
vllm serve "/models/Spark-X2.6-4B" \
--port "30000" \
--trust-remote-code \
--served-model-name spark25 \
--tensor-parallel-size 1 \
--gpu-memory-utilization 0.7 \
--enable-prefix-caching \
--chat-template /models/Spark-X2.6-4B/chat_template.jinja
Client
curl -s http://127.0.0.1:30000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "spark25",
"messages": [{"role": "user", "content": "What is the capital of Anhui Province?"}],
"temperature": 1.0,
"top_k": -1,
"top_p": 0.95
}'
MLX
Spark-MLX-LLM runs the original Spark-X2.6 Hugging Face checkpoints locally. It supports Apple silicon GPU, Linux CPU, and NVIDIA CUDA on Linux. No GGUF conversion is required.
Installation
git clone https://github.com/XHToken/Spark-MLX-LLM.git
cd Spark-MLX-LLM
python3 -m venv .venv
source .venv/bin/activate
# Apple silicon
python -m pip install -e .
# Linux CPU
python -m pip install -e '.[cpu]'
# Linux with CUDA 12
python -m pip install -e '.[cuda12]'
# Linux with CUDA 13
python -m pip install -e '.[cuda13]'
Run Inference
spark-mlx-generate \
--device gpu \
--dtype bfloat16 \
--model XHToken/Spark-X2.6-4B \
--prompt "What is the capital of Anhui Province?" \
--max-tokens 512 \
--temp 0
llama.cpp
Native
spark2_5support requires llama.cppb10828or later.
Run the model in the CLI:
llama cli -m /path/to/Spark-X2.6-4B-GGUF
Launch the OpenAI-compatible API server:
llama serve -m /path/to/Spark-X2.6-4B-GGUF
Ollama
Download and install Ollama from ollama.com (v0.34.1 or later).
Run the model:
ollama run SparkLLM/Spark-X2.6-4B
LM Studio
Download and install LM Studio from lmstudio.ai (0.4.0 or later).
Search for "Spark-X2.6" in LM Studio and download the model.
Load the model and start chatting.
Run with the lms cli
# List available models
lms ls
# Run chat with Spark-X2.6
lms chat spark-x2.6
Unsloth
The latest Unsloth Studio supports native Spark-X2.6 GGUF inference.
WebGPU (Community)
Run Spark-X2.6-4B locally in your browser with the community WebGPU demo contributed by Mohd Mahmodi.
- Open the WebGPU demo in a WebGPU-compatible browser.
- Download the model through the demo and start chatting. Inference runs on your local GPU.
ONNX model files · Source code and validation
This community implementation uses the official Spark-X2.6-4B-INT4 weights and requires no local installation. Tested by the contributor on Windows with an NVIDIA GPU.
cortiq CUDA (community long-context deployment)
For a long-context trial on an NVIDIA A40, try the community-maintained 4-bit Turbo CMF conversion. Its author measured cortiq 0.8.67 with a 64,000-token prompt: 42.3 s to first token, 100.7 tokens/s decoding over 500 tokens, and 3.9 GB on the card while decoding. On the same A40 the Vulkan path took 60.3 s to first token and decoded at 85.9 tokens/s. Turbo uses a far-field representation beyond 8,192 tokens. Evaluate retrieval and answer quality on representative inputs when choosing this experimental backend.
The author's setup uses an NVIDIA driver and CUDA 12.x runtime libraries including NVRTC and cuBLAS. To reproduce the reported release:
cargo install cortiq-cli --version 0.8.67 --features cuda
hf download infosave/Spark-X2.6-4B-turbo-CUDA-cmf spark-x2.6-4b-q4tp-turbo.cmf --local-dir .
CMF_GPU=cuda CMF_MAX_SEQ=131072 cortiq serve spark-x2.6-4b-q4tp-turbo.cmf --port 8080 --host 127.0.0.1
Author's measurements and limits · CUDA setup guide
Community GGUF options
For a compact 4B build to try in llama.cpp, peculiar-ragdoll's Sharp-Spark X2.6 conversions include Q4_K_XL, Q5_K_XL and Q6_K_XL (2.68 / 3.25 / 3.61 GB respectively, decimal file sizes). The author supplies an importance matrix and a modified chat template. Start with Q4_K_XL when weight storage is the constraint; follow the conversion's own setup notes and keep its template for comparisons.
We loaded the pinned Q4_K_XL on a CPU runner with llama.cpp b11277. At low reasoning effort it returned the requested quantity as valid JSON and answered a formula-supplied geometric-series question with the correct value, 25 (45 and 39 generated tokens respectively, one run each). On an open-ended version of the returns question, it reached a 768-token output cap with no visible final answer. For agent workloads, test completion and tool arguments at your actual output limit before choosing a build. The official GGUF files provide a baseline.
For an alternative quantization layout, AtomicChat's X2.6 imatrix GGUF collection includes IQ3_S through Q8_0 and links its calibration corpus. The AD-Q5_K_M file is 3.15 GB. We verified that file's checksum and ran the community's two-turn math-to-Lisp task on b11277. At a 1,024-token limit, neither default nor low effort produced a visible final answer on either turn (one seed). Use the original prompts and replay results to check that your chosen build completes the kinds of tasks you need.
Fine-Tuning
We recommend using Llama-Factory to fine-tune the model.
Community showcase
Bilingual legal and financial diagnostics — lostlight520. The author ran the BF16 model on a Colab NVIDIA L4 using Transformers. Six problem families, each asked in Chinese and English, included outdated legal premises, financing costs and cash-flow calculations. All 12 runs passed the author's required/forbidden-keyword rule (6/6 legal and 6/6 financial); 10/12 reached the 4,096-new-token ceiling. The report documents the scoring rule, runtime and limitations of the available traces. Author's diagnostic report
Emergency-management questions and document delivery — GUS23666. On a Windows 11 RTX 4060 Laptop setup with Loomy and high thinking effort, the author compared the same 24 Chinese questions in two rounds. Grading both the answer and its explanation gave 23/24 (95.83%) with the questions alone and 20/24 (83.33%) with reference materials. When only the core conclusion or value counted, both rounds scored 23/24. A separate document workflow produced seven text extracts before the connection closed during final assembly; the PDF remained unfinished. Author's test report · Questions, reference answers and saved outputs
License
The Spark-X2.6 model series is licensed under the Apache 2.0 License.
Citation
If you find our work helpful, feel free to give us a cite.
@misc{sparkx2.6,
title = {Spark-X2.6-4B&1.7B: Advancing the Frontier of On-Device Agents for Real-World Tasks},
author = {SparkLLM Team},
year = {2026}
}
- Downloads last month
- 29,191
Model tree for XHToken/Spark-X2.6-4B
Base model
XHToken/Spark-X2.6-4B-Base