Samothrace-4B-Preview
looping Qwen3.5-4B layers for better problem solving
2 min readupdated
Samothrace-4B-Preview is an experimental language model based on Qwen/Qwen3.5-4B in which the middle layers (from 8 to 19) are executed twice using a small LoRA adaptation (a small add-on over the base model) and a learnable gate. The second pass allows the model to "think" longer and more accurately within the same parameters, showing noticeable gains in math and code generation while reducing generation length. The model was created by researcher CloudGoat and targets developers and researchers interested in LLM architectural experiments.
Key features
- Loop architecture: Layers 8–19 run twice (K=2) with their own LoRA (r=16) and a learnable per-channel gate.
- Metric growth: Significant gains on MATH-500 (42.4% vs 23.6% for base) and HumanEval (87.2% vs 85.4%).
- Generation efficiency: The average number of generated tokens per task decreased thanks to a more focused thinking process.
- Ready-to-use loading code: The repository contains a custom inference implementation and the weights of the learnable part (11.4M parameters).
What you can do
- Reasoning testing: Run the model to solve complex math problems and write code using the custom inference script.
- Architecture research: Examine the
modeling_samothrace.pyandsamothrace_inference.pyfiles to integrate looped layers into your own projects. - Pipeline integration: Apply the model in tasks requiring multi-step tool calls and logical analysis.
Example
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)
print(generate(model, tok, "Find all real x with x^2 - 5x + 6 = 0.", max_new_tokens=4096))
Read more
Details• Benchmarks: MATH-500 — 42.4% (vs 23.6% for base), HumanEval — 87.2% (vs 85.4%).
• Hardware and VRAM: Requires
transformers with Qwen3.5 support; flash-linear-attention is recommended on GPU.• Limitations: Research release without additional safety tuning; inference cost is about 1.4x higher per token compared to the base model.
• Training: SFT on 10M tokens (math, code, agents) for 7.5 hours on Kaggle 2× T4.










Comments