Views
No views yet
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-4B-Thinking-2507"
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@misc{ghasemabadi2024llmspredictfailures,
2 title={Can LLMs Predict Their Own Failures? Self-Awareness via Internal Circuits},
3 author={Amirhosein Ghasemabadi and Di Niu},
4 year={2024},
5 eprint={2512.20578},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL},
8 url={https://arxiv.org/abs/2512.20578},
9}