Views
No views yet
1from transformers import AutoTokenizer, AutoModelForCausalLM
2from peft import PeftModel
3import torch
4
5# Load model
6base_model = AutoModelForCausalLM.from_pretrained(
7 "state-spaces/mamba-790m-hf",
8 trust_remote_code=True,
9 torch_dtype=torch.bfloat16,
10 device_map="auto"
11)
12
13model = PeftModel.from_pretrained(base_model, "NakshJain/mamba-790m-resoning")
14tokenizer = AutoTokenizer.from_pretrained("state-spaces/mamba-790m-hf", trust_remote_code=True)
15
16# Format: <user>question</user><think>reasoning</think><answer>
17prompt = "<user>What is 15 + 27?</user><think>Let me add: 15 + 27 = 42</think><answer>"
18
19inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
20outputs = model.generate(**inputs, max_new_tokens=100)
21response = tokenizer.decode(outputs[0], skip_special_tokens=True)
22
23print(response)
24# Output: 42<user>query</user><think>reasoning</think><answer>response</answer>in_proj, x_proj, dt_proj1@misc{mamba-reasoning-faithfulness-2024,
2 author = {Naksh Jain},
3 title = {Mamba-790M Reasoning Faithfulness Model},
4 year = {2024},
5 publisher = {HuggingFace},
6 url = {https://huggingface.co/NakshJain/mamba-790m-resoning}
7}