🚀 Live Demo
Try the interactive Kaggle Notebook (no setup required): Qwen3.5 Trace-Inversion Demo

🧠 Qwen3.5-4B-Trace-Inversion
This repository contains a fully merged, standalone model based on Qwen/Qwen3.5-4B.
It was fine-tuned on the Trace-Inversion-1K-Preview dataset to master a specific technique called Trace Inversion.
🎯 What does this model do?
Instead of solving a problem from scratch, this model acts as a Reasoning Generator. You provide it with a problem and its known correct final answer, and it reconstructs the step-by-step logical reasoning (<think>...</think>) that connects the two.
This is highly useful for:
- Distilling reasoning capabilities from larger models (like DeepSeek V4 or Claude Opus) into smaller 4B architectures.
- Data Augmentation: Generating synthetic Chain-of-Thought traces for existing datasets.
- Behavioral Cloning: Teaching small models how to structure their thoughts before answering.
🚀 How to use
Since this is a full model, you can load and use it directly with the standard transformers library.
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "open-zzrl/Qwen3.5-4B-Trace-Inversion"
# 1. Load Model and Tokenizer
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
device_map="auto"
)
model.eval()
# 2. Prepare the prompt (Question + Known Answer)
problem = "How many trailing zeros are there in 100! (100 factorial)?"
known_answer = "24"
messages = [
{"role": "user", "content": f"Question: {problem}\n\nAnswer: {known_answer}"}
]
inputs = tokenizer.apply_chat_template(
messages,
tokenize=True,
add_generation_prompt=True,
return_tensors="pt"
).to(model.device)
# 3. Generate the reasoning
with torch.no_grad():
outputs = model.generate(
inputs,
max_new_tokens=2048,
temperature=0.6,
do_sample=True
)
# 4. Decode and print
generated_text = tokenizer.decode(outputs[0][inputs.shape[1]:], skip_special_tokens=True)
print(generated_text)
⚠️ Limitations & Caveats
- Do not evaluate on standard benchmarks (AIME, MATH-500, HumanEval). These benchmarks were part of the training data. The model will likely score artificially high, not because it learned to generalize, but because it memorized the traces.
- It is not a general-purpose solver. This model expects the answer to be provided in the prompt. If you ask it to solve a problem without giving it the answer, it will likely fail.
- 4B Parameter Limits. While the model successfully learned the
<think>formatting and algorithmic patterns, the 4B parameter size means it can still get confused on highly complex, multi-step recursive math (e.g., (f(f(f(f(x))))=0)). For harder tasks, consider fine-tuning a 7B or 8B model using the same dataset. - Qwen Native Tags. The dataset and this model use Qwen's native
<think>and</think>tags.
📊 Training Details
- Base Model:
Qwen/Qwen3.5-4B - Dataset:
open-zzrl/Trace-Inversion-1K-Preview(932 examples) - Epochs: 2
- Max Sequence Length: 8192
- Format: Fully merged 16-bit (BF16)