import json, torchfrom transformers import AutoModelForCausalLM, AutoTokenizer model_id = "flintglass/PrismVerify-4B"tokenizer = AutoTokenizer.from_pretrained(model_id)model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16, device_map="auto") SYSTEM_PROMPT = ( 'You are PrismVerify, a precision groundedness and hallucination verification judge. ' 'Given a CONTEXT, optional QUESTION, and RESPONSE, verify every factual claim and numerical ' 'calculation in RESPONSE strictly against CONTEXT. Reply ONLY with a valid JSON object containing: ' '"reasoning" (concise step-by-step verification), "unsupported_spans" (list of exact verbatim ' 'contradicted or ungrounded phrases from RESPONSE, empty if faithful), "error_type" ("none", ' '"contradiction", "unsupported", or "both"), and "verdict" ("FAITHFUL" or "HALLUCINATED").') user_msg = """[CONTEXT]In Q3 2026, Meridian Robotics reported revenue of $142.8 million, up 18.4% YoY, while gross margin narrowed from 61.2% to 59.8%. [QUESTION]Summarize Meridian Robotics' Q3 2026 financial results. [RESPONSE]Meridian Robotics grew Q3 revenue by 18.4% to $142.8 million, expanded gross margin to 65.0%, and launched a $20M share buyback.""" messages = [ {"role": "system", "content": SYSTEM_PROMPT}, {"role": "user", "content": user_msg},]text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)inputs = tokenizer([text], return_tensors="pt").to(model.device) with torch.no_grad(): out = model.generate(**inputs, max_new_tokens=384, do_sample=False) reply = tokenizer.decode(out[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)print(json.dumps(json.loads(reply), indent=2))