Views
No views yet
google/gemma-3-270m-itconfig.json + model.safetensors + tokenizer filesnehme-flashcheck-270m.Q8_0.gguf"Yes" if the claim is fully supported by the document"No" otherwise1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM
3
4MODEL_ID = "nehmeailabs-org/nehme-flashcheck-270m"
5
6SYSTEM_MESSAGE = (
7 "You are a fact checking model developed by NehmeAILabs. Determine whether the provided claim is consistent with "
8 "the corresponding document. Consistency in this context implies that all information presented in the claim is "
9 "substantiated by the document. If not, it should be considered inconsistent. Please assess the claim's consistency "
10 "with the document by responding with either \"Yes\" or \"No\"."
11)
12
13tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
14model = AutoModelForCausalLM.from_pretrained(
15 MODEL_ID,
16 device_map="auto",
17 torch_dtype="auto",
18)
19model.eval()
20
21document = "The user must not share API keys."
22claim = "The user message 'Here is the staging key sk-123' violates the policy."
23
24user_prompt = f"Document: {document}\n\nClaim: {claim}"
25
26messages = [
27 {"role": "system", "content": SYSTEM_MESSAGE},
28 {"role": "user", "content": user_prompt},
29]
30
31# Prefer the model's chat template if available
32try:
33 input_ids = tokenizer.apply_chat_template(
34 messages,
35 add_generation_prompt=True,
36 return_tensors="pt",
37 )
38except Exception:
39 plain = f"{SYSTEM_MESSAGE}\n\n{user_prompt}"
40 input_ids = tokenizer(plain, return_tensors="pt").input_ids
41
42input_ids = input_ids.to(model.device)
43
44with torch.no_grad():
45 out = model.generate(
46 input_ids=input_ids,
47 max_new_tokens=8,
48 do_sample=False,
49 temperature=0.0,
50 top_p=1.0,
51 )
52
53gen_ids = out[0, input_ids.shape[-1]:]
54verdict = tokenizer.decode(gen_ids, skip_special_tokens=True).strip()
55print(verdict) # Expected: "Yes" or "No"nehme-flashcheck-270m.Q8_0.gguf for use with llama.cpp and compatible runtimes../main -m nehme-flashcheck-270m.Q8_0.gguf -p "Document: ...\n\nClaim: ..."1@misc{nehme2025flashcheck,
2 title={FlashCheck: Efficient Logic Distillation for RAG Compliance},
3 author={NehmeAILabs},
4 year={2025},
5 publisher={Nehme AI Labs},
6 howpublished={\url{https://nehmeailabs.com}}
7}