Run this model with HF Jobs
Run CloudGoat/Samothrace-4B-Preview 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/CloudGoat/Samothrace-4B-Preview. 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/CloudGoat/Samothrace-4B-Preview 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/CloudGoat/Samothrace-4B-Preview. 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/CloudGoat/Samothrace-4B-Preview. 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 CloudGoat/Samothrace-4B-Preview with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use CloudGoat/Samothrace-4B-Preview with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="CloudGoat/Samothrace-4B-Preview")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("CloudGoat/Samothrace-4B-Preview", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use CloudGoat/Samothrace-4B-Preview with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "CloudGoat/Samothrace-4B-Preview" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "CloudGoat/Samothrace-4B-Preview", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/CloudGoat/Samothrace-4B-Preview
- SGLang
How to use CloudGoat/Samothrace-4B-Preview 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 "CloudGoat/Samothrace-4B-Preview" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "CloudGoat/Samothrace-4B-Preview", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "CloudGoat/Samothrace-4B-Preview" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "CloudGoat/Samothrace-4B-Preview", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use CloudGoat/Samothrace-4B-Preview with Docker Model Runner:
docker model run hf.co/CloudGoat/Samothrace-4B-Preview
|
Download README.md from CloudGoat/Samothrace-4B-Preview: direct link, hf CLI and curl.
- Browser
- Download file 4.13 kB
-
https://huggingface.co/CloudGoat/Samothrace-4B-Preview/resolve/main/README.md
- Command line
-
hf download hf://CloudGoat/Samothrace-4B-Preview/README.md
-
curl -L -o README.md https://huggingface.co/CloudGoat/Samothrace-4B-Preview/resolve/main/README.md
4.13 kB
| license: apache-2.0 | |
| base_model: Qwen/Qwen3.5-4B | |
| library_name: transformers | |
| pipeline_tag: text-generation | |
| tags: | |
| - looped-transformer | |
| - recurrent-depth | |
| - lora | |
| - reasoning | |
| - qwen3.5 | |
| datasets: | |
| - Yang-Zhou/DAPO-Math-17k-Qwen3-235B-A22B-Thinking-2507-rejection-distill | |
| - zake7749/Qwen3.5-27B-DeepCoder-SFT | |
| - ZhuofengLi/hardtests-sft-qwen3.5-27b | |
| - nvidia/Nemotron-SFT-Agentic-v2 | |
| # Samothrace-4B-Preview | |
| Samothrace-4B-Preview is **Qwen3.5-4B with its middle layers looped**. Layers 8–19 (three blocks of 3× Gated DeltaNet + 1× full attention) run **twice (K=2)**; layers 0–7 and 20–31 run once. The second pass uses its own LoRA (r=16) and a learned per-channel gate: | |
| ``` | |
| h ← h + a ⊙ (Core(h; W + ΔW₂) − h) a ∈ R^2560, initialised to 0 | |
| ``` | |
| With `a = 0` the model is bit-identical to Qwen3.5-4B, so the loop starts from the pretrained model and only learns how much of the second pass to mix in. The repo holds only the trainable part (11.4M parameters, fp32): the base weights are pulled from `Qwen/Qwen3.5-4B`. | |
| ## Results | |
|  | |
| | | K=1 (= base Qwen3.5-4B) | **K=2 (Samothrace-4B-Preview)** | K=3 | | |
| |---|---|---|---| | |
| | MATH-500 (n=144) | 23.6% | **42.4%** | 39.6% | | |
| | HumanEval (n=164, pass@1) | 85.4% | **87.2%** | 86.0% | | |
| | Mean generated tokens, MATH-500 | 2,347 | 1,980 | 2,011 | | |
| | Mean generated tokens, HumanEval | 1,166 | 518 | 553 | | |
| Setup: greedy decoding, thinking mode, 2,048-token thinking budget with budget forcing (then up to 384 answer tokens), the same problems for every K. MATH-500 is a random 144-problem subset (the run hit its compute budget); HumanEval is complete. K=3 was trained jointly (same run, separate LoRA) and did not beat K=2, so K=2 is the released setting. | |
| **Read with care:** K=1 is the untouched base model, so the K=1→K=2 gain mixes the effect of SFT (much shorter, less truncated thinking) with the effect of the loop. A same-budget non-looped LoRA control has not been run yet. The 2,048-token thinking cap truncates most MATH-500 solutions for every K, so absolute numbers sit well below Qwen3.5-4B's full-budget scores. | |
| ## Training | |
| - SFT, 10.0M tokens (3,418 samples, ≤ 6,144 tokens): math 3.0M (DAPO-Math Qwen3-235B-Thinking rejection distill), code 3.5M (Qwen3.5-27B DeepCoder SFT, hardtests Qwen3.5-27B), agent 3.5M (Nemotron-SFT-Agentic-v2, multi-step tool calling and interactive agent). | |
| - K sampled per sample (K=2 35%, K=3 65%); shortcut-consistency KL(p_K3 ‖ p_K2) on 20% of K=3 samples. | |
| - AdamW, LoRA lr 2e-4, gate lr 3e-3, cosine schedule, fp16 with loss scaling. 7.5 h on Kaggle 2× T4 (DDP), query-chunked attention and per-layer activation checkpointing; 0 OOM skips. Final mean |a| = 0.092. | |
| Held-out SFT-distribution loss (samples not used in training), K=1 / K=2 / K=3: math 0.297 / 0.248 / 0.246, code (DeepCoder) 0.390 / 0.299 / 0.292, code (hardtests) 0.883 / 0.676 / 0.657, agent tool-calling 0.704 / 0.581 / 0.574, interactive agent 0.671 / 0.469 / 0.460. | |
| ## Usage | |
| Requires `transformers` with Qwen3.5 support. `flash-linear-attention` is recommended on GPU. | |
| ```python | |
| from huggingface_hub import snapshot_download | |
| import sys | |
| path = snapshot_download("CloudGoat/Samothrace-4B-Preview") | |
| sys.path.insert(0, path) | |
| from samothrace_inference import load_samothrace, generate | |
| model, tok = load_samothrace(path) # downloads Qwen/Qwen3.5-4B, applies the K=2 loop | |
| print(generate(model, tok, "Find all real x with x^2 - 5x + 6 = 0.", max_new_tokens=4096)) | |
| ``` | |
| Files: `modeling_samothrace.py` (looped model, per-step LoRA, loop-aware KV / DeltaNet cache), `samothrace_inference.py` (loader + simple decoding), `samothrace_k2_adapter.safetensors`, `samothrace_config.json`. | |
| Decoding costs about 1.4× a plain Qwen3.5-4B forward per token (44 of 32 layers' worth of compute), and the loop adds its own KV / recurrent-state slots for the second pass. | |
| ## Limitations | |
| - Research release; no safety tuning beyond the base model. | |
| - Evaluated on small subsets with a short thinking budget; no AIME / LiveCodeBench / BFCL numbers yet. | |
| - RL (GRPO) stage not yet applied. | |