Views
No views yet
1import torch
2from transformers import AutoTokenizer
3
4# Load model (requires trust_remote_code=True)
5from src.hf_model import RecurrentAdapterModel
6
7model = RecurrentAdapterModel.from_pretrained(
8 "hanseungwook/recurrent-adapter-metamath-cot-r16",
9 torch_dtype=torch.bfloat16,
10 device_map="auto"
11)
12tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen3-8B")
13
14# Generate
15prompt = "What is 25 * 37?"
16inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
17
18with torch.no_grad():
19 outputs = model.generate(
20 **inputs,
21 max_new_tokens=256,
22 num_recurrence_steps=16,
23 temperature=0.7,
24 )
25
26print(tokenizer.decode(outputs[0], skip_special_tokens=True))1@misc{recurrent-adapters-2025,
2 author = {Han, Seungwook},
3 title = {Recurrent Adapters for Mathematical Reasoning},
4 year = {2025},
5 publisher = {HuggingFace},
6 howpublished = {\url{https://huggingface.co/hanseungwook/recurrent-adapter-metamath-cot-r16}}
7}