Instructions to use tiny-random/spark-x2.6 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use tiny-random/spark-x2.6 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="tiny-random/spark-x2.6", 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("tiny-random/spark-x2.6", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use tiny-random/spark-x2.6 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "tiny-random/spark-x2.6" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "tiny-random/spark-x2.6", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/tiny-random/spark-x2.6
- SGLang
How to use tiny-random/spark-x2.6 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 "tiny-random/spark-x2.6" \ --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": "tiny-random/spark-x2.6", "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 "tiny-random/spark-x2.6" \ --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": "tiny-random/spark-x2.6", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use tiny-random/spark-x2.6 with Docker Model Runner:
docker model run hf.co/tiny-random/spark-x2.6
Upload folder using huggingface_hub
Browse files- README.md +4 -4
- config.json +1 -5
- model.safetensors +2 -2
README.md
CHANGED
|
@@ -11,7 +11,7 @@ Structural comparison with `XHToken/Spark-X2.6-4B`:
|
|
| 11 |
| Feature | Source | Tiny |
|
| 12 |
|---|---:|---:|
|
| 13 |
| Vocabulary / tied embeddings | 131,072 / yes | same |
|
| 14 |
-
| Layers | 36 |
|
| 15 |
| Hidden size / head dimension | 2,560 / 256 | 16 / 32 |
|
| 16 |
| Query / KV heads | 16 / 4 | 1 / 1 |
|
| 17 |
| MLP width | 10,240 | 64 |
|
|
@@ -70,8 +70,8 @@ folder.mkdir(parents=True, exist_ok=True)
|
|
| 70 |
raw = json.loads(Path(hf_hub_download(source_model_id, "config.json", revision=source_revision)).read_text())
|
| 71 |
raw.update(
|
| 72 |
hidden_size=16, head_dim=32, num_attention_heads=1, num_key_value_heads=1,
|
| 73 |
-
intermediate_size=64, num_hidden_layers=
|
| 74 |
-
layer_types=(["sliding_attention"] * 3 + ["full_attention"]) *
|
| 75 |
)
|
| 76 |
(folder / "config.json").write_text(json.dumps(raw, indent=2), encoding="utf-8")
|
| 77 |
for filename in ("configuration_spark.py", "modeling_spark.py"):
|
|
@@ -118,7 +118,7 @@ Spark2_5ForCausalLM(
|
|
| 118 |
(model): Spark2_5Model(
|
| 119 |
(embedding): Embedding(131072, 16, padding_idx=2)
|
| 120 |
(layers): ModuleList(
|
| 121 |
-
(0-
|
| 122 |
(self_attn): Spark2_5Attention(
|
| 123 |
(q_k_v_proj): Linear(in_features=16, out_features=96, bias=False)
|
| 124 |
(g_proj): Linear(in_features=16, out_features=1, bias=False)
|
|
|
|
| 11 |
| Feature | Source | Tiny |
|
| 12 |
|---|---:|---:|
|
| 13 |
| Vocabulary / tied embeddings | 131,072 / yes | same |
|
| 14 |
+
| Layers | 36 | 8; two 3-sliding + 1-full cycles |
|
| 15 |
| Hidden size / head dimension | 2,560 / 256 | 16 / 32 |
|
| 16 |
| Query / KV heads | 16 / 4 | 1 / 1 |
|
| 17 |
| MLP width | 10,240 | 64 |
|
|
|
|
| 70 |
raw = json.loads(Path(hf_hub_download(source_model_id, "config.json", revision=source_revision)).read_text())
|
| 71 |
raw.update(
|
| 72 |
hidden_size=16, head_dim=32, num_attention_heads=1, num_key_value_heads=1,
|
| 73 |
+
intermediate_size=64, num_hidden_layers=8,
|
| 74 |
+
layer_types=(["sliding_attention"] * 3 + ["full_attention"]) * 2,
|
| 75 |
)
|
| 76 |
(folder / "config.json").write_text(json.dumps(raw, indent=2), encoding="utf-8")
|
| 77 |
for filename in ("configuration_spark.py", "modeling_spark.py"):
|
|
|
|
| 118 |
(model): Spark2_5Model(
|
| 119 |
(embedding): Embedding(131072, 16, padding_idx=2)
|
| 120 |
(layers): ModuleList(
|
| 121 |
+
(0-7): 8 x Spark2_5DecoderLayer(
|
| 122 |
(self_attn): Spark2_5Attention(
|
| 123 |
(q_k_v_proj): Linear(in_features=16, out_features=96, bias=False)
|
| 124 |
(g_proj): Linear(in_features=16, out_features=1, bias=False)
|
config.json
CHANGED
|
@@ -27,17 +27,13 @@
|
|
| 27 |
"sliding_attention",
|
| 28 |
"sliding_attention",
|
| 29 |
"sliding_attention",
|
| 30 |
-
"full_attention",
|
| 31 |
-
"sliding_attention",
|
| 32 |
-
"sliding_attention",
|
| 33 |
-
"sliding_attention",
|
| 34 |
"full_attention"
|
| 35 |
],
|
| 36 |
"max_position_embeddings": 1048576,
|
| 37 |
"mlp_bias": false,
|
| 38 |
"model_type": "spark2_5",
|
| 39 |
"num_attention_heads": 1,
|
| 40 |
-
"num_hidden_layers":
|
| 41 |
"num_key_value_heads": 1,
|
| 42 |
"pad_token_id": 2,
|
| 43 |
"rms_norm_eps": 1e-06,
|
|
|
|
| 27 |
"sliding_attention",
|
| 28 |
"sliding_attention",
|
| 29 |
"sliding_attention",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
"full_attention"
|
| 31 |
],
|
| 32 |
"max_position_embeddings": 1048576,
|
| 33 |
"mlp_bias": false,
|
| 34 |
"model_type": "spark2_5",
|
| 35 |
"num_attention_heads": 1,
|
| 36 |
+
"num_hidden_layers": 8,
|
| 37 |
"num_key_value_heads": 1,
|
| 38 |
"pad_token_id": 2,
|
| 39 |
"rms_norm_eps": 1e-06,
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7bfcde4ade27abb88956789cbd2b32689868df8b70bf370dbeacc9dac793637f
|
| 3 |
+
size 4284048
|