open-zzrl/Trace-Inversion-1K-Preview
Viewer • Updated • 932 • 84 • 1
Try the interactive Kaggle Notebook (no setup required): Qwen3.5 Trace-Inversion Demo
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.
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:
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)
<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.<think> and </think> tags.Qwen/Qwen3.5-4Bopen-zzrl/Trace-Inversion-1K-Preview (932 examples)