1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM
3from src.demo import build_chat_prompt, generate_with_hf, correctness_prob
4
5GNOSIS_MODEL_ID = "AmirhoseinGH/Gnosis-Qwen3-8B"
6
7tokenizer = AutoTokenizer.from_pretrained(GNOSIS_MODEL_ID, trust_remote_code=True)
8model = AutoModelForCausalLM.from_pretrained(
9 GNOSIS_MODEL_ID, torch_dtype=torch.bfloat16, trust_remote_code=True
10).cuda().eval()
11
12prompt = build_chat_prompt(
13 tokenizer,
14 question="How many r's are in strawberry?",
15 system_prompt="Please reason step by step, and put your final answer within \\boxed{}.",
16)
17
18answer = generate_with_hf(model, tokenizer, prompt, torch.device("cuda"), max_new_tokens=2048)
19p_correct = correctness_prob(model, tokenizer, prompt + answer, torch.device("cuda"))
20
21print("Answer:
22", answer)
23print("Gnosis correctness probability:", f"{p_correct:.4f}")
1@article{ghasemabadi2025llms,
2 title={Can LLMs Predict Their Own Failures? Self-Awareness via Internal Circuits},
3 author={Ghasemabadi, Amirhosein and Niu, Di},
4 journal={arXiv preprint arXiv:2512.20578},
5 year={2025}
6}