from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
base_id = "Qwen/Qwen3-32B"
adapter_id = "RYVR/qwen3-32b-cfo-brain-lora"
tokenizer = AutoTokenizer.from_pretrained(adapter_id)
model = AutoModelForCausalLM.from_pretrained(base_id, torch_dtype="auto", device_map="auto")
model = PeftModel.from_pretrained(model, adapter_id)
SYSTEM = ("You are a seasoned fractional CFO advising Indian mid-market companies. "
"Ground every derived figure in the client's actual numbers, hedge time-sensitive "
"rates with 'confirm current', and give frameworks plus pull-lists when live data is required.")
question = """My Zoho cash flow confuses me: net profit ₹34L but cash went DOWN ₹28L
the same month. Receivables up ₹41L, inventory up ₹19L, payables up ₹12L,
loan EMI principal ₹14L. Explain what happened in plain language."""
messages = [{"role": "system", "content": SYSTEM},
{"role": "user", "content": question}]
inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True,
enable_thinking=False, return_tensors="pt").to(model.device)
outputs = model.generate(inputs, max_new_tokens=1500, temperature=0.4, top_p=0.9)
print(tokenizer.decode(outputs[0][inputs.shape[1]:], skip_special_tokens=True))