初始化项目,由ModelHub XC社区提供模型
Model: nehmeailabs-org/nehme-flashcheck-1b Source: Original Platform
This commit is contained in:
38
.gitattributes
vendored
Normal file
38
.gitattributes
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||
*.arrow filter=lfs diff=lfs merge=lfs -text
|
||||
*.bin filter=lfs diff=lfs merge=lfs -text
|
||||
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
||||
*.ftz filter=lfs diff=lfs merge=lfs -text
|
||||
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||
*.h5 filter=lfs diff=lfs merge=lfs -text
|
||||
*.joblib filter=lfs diff=lfs merge=lfs -text
|
||||
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
||||
*.model filter=lfs diff=lfs merge=lfs -text
|
||||
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
||||
*.npy filter=lfs diff=lfs merge=lfs -text
|
||||
*.npz filter=lfs diff=lfs merge=lfs -text
|
||||
*.onnx filter=lfs diff=lfs merge=lfs -text
|
||||
*.ot filter=lfs diff=lfs merge=lfs -text
|
||||
*.parquet filter=lfs diff=lfs merge=lfs -text
|
||||
*.pb filter=lfs diff=lfs merge=lfs -text
|
||||
*.pickle filter=lfs diff=lfs merge=lfs -text
|
||||
*.pkl filter=lfs diff=lfs merge=lfs -text
|
||||
*.pt filter=lfs diff=lfs merge=lfs -text
|
||||
*.pth filter=lfs diff=lfs merge=lfs -text
|
||||
*.rar filter=lfs diff=lfs merge=lfs -text
|
||||
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
||||
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar filter=lfs diff=lfs merge=lfs -text
|
||||
*.tflite filter=lfs diff=lfs merge=lfs -text
|
||||
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||
*.wasm filter=lfs diff=lfs merge=lfs -text
|
||||
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
*.zst filter=lfs diff=lfs merge=lfs -text
|
||||
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
||||
*.gguf filter=lfs diff=lfs merge=lfs -text
|
||||
*.json filter=lfs diff=lfs merge=lfs -text
|
||||
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
||||
130
README.md
Normal file
130
README.md
Normal file
@@ -0,0 +1,130 @@
|
||||
---
|
||||
license: gemma
|
||||
language:
|
||||
- en
|
||||
pipeline_tag: text-generation
|
||||
tags:
|
||||
- fact-checking
|
||||
- hallucination-detection
|
||||
- rag
|
||||
- compliance
|
||||
- guardrails
|
||||
- nli
|
||||
- gemma
|
||||
base_model: unsloth/gemma-3-1b-it-unsloth-bnb-4bit
|
||||
---
|
||||
|
||||
# FlashCheck-1B: The Enterprise Logic Engine
|
||||
|
||||
## Model Description
|
||||
|
||||
**FlashCheck-1B** is a Gemma 3 (1B) fine-tune specialized for **Contextual Policy Adherence** and **Hallucination Detection**.
|
||||
|
||||
It is designed to act as a fast verifier in RAG pipelines: given a **Document** and a **Claim**, it answers **"Yes"** if the claim is fully supported by the document, otherwise **"No"**.
|
||||
|
||||
- **Developer:** Nehme AI Labs
|
||||
- **Training Base:** `unsloth/gemma-3-1b-it-unsloth-bnb-4bit` (Gemma family)
|
||||
- **License/Terms:** Gemma (see Gemma terms associated with the base model)
|
||||
|
||||
## What’s in this repo
|
||||
|
||||
- **Transformers (standalone):** `config.json` + `model.safetensors` + tokenizer files
|
||||
- **GGUF (local inference):** `nehme-flashcheck-1b.Q8_0.gguf` (or in `gguf/` if you placed it there)
|
||||
|
||||
## Intended behavior
|
||||
|
||||
- Input: **Document** (premise) + **Claim** (hypothesis)
|
||||
- Output: **"Yes"** or **"No"** (short, deterministic; use greedy decoding)
|
||||
|
||||
## Usage
|
||||
|
||||
### 1) Python (Transformers)
|
||||
|
||||
```python
|
||||
import torch
|
||||
from transformers import AutoTokenizer, AutoModelForCausalLM
|
||||
|
||||
MODEL_ID = "nehmeailabs-org/nehme-flashcheck-1b"
|
||||
|
||||
SYSTEM_MESSAGE = (
|
||||
"You are a fact checking model developed by NehmeAILabs. Determine whether the provided claim is consistent with "
|
||||
"the corresponding document. Consistency in this context implies that all information presented in the claim is "
|
||||
"substantiated by the document. If not, it should be considered inconsistent. Please assess the claim's consistency "
|
||||
"with the document by responding with either \"Yes\" or \"No\"."
|
||||
)
|
||||
|
||||
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
|
||||
model = AutoModelForCausalLM.from_pretrained(
|
||||
MODEL_ID,
|
||||
device_map="auto",
|
||||
torch_dtype="auto",
|
||||
)
|
||||
model.eval()
|
||||
|
||||
document = "The user must not share API keys."
|
||||
claim = "The user message 'Here is the staging key sk-123' violates the policy."
|
||||
|
||||
user_prompt = f"Document: {document}\n\nClaim: {claim}"
|
||||
|
||||
messages = [
|
||||
{"role": "system", "content": SYSTEM_MESSAGE},
|
||||
{"role": "user", "content": user_prompt},
|
||||
]
|
||||
|
||||
try:
|
||||
input_ids = tokenizer.apply_chat_template(
|
||||
messages,
|
||||
add_generation_prompt=True,
|
||||
return_tensors="pt",
|
||||
)
|
||||
except Exception:
|
||||
plain = f"{SYSTEM_MESSAGE}\n\n{user_prompt}"
|
||||
input_ids = tokenizer(plain, return_tensors="pt").input_ids
|
||||
|
||||
input_ids = input_ids.to(model.device)
|
||||
|
||||
with torch.no_grad():
|
||||
out = model.generate(
|
||||
input_ids=input_ids,
|
||||
max_new_tokens=8,
|
||||
do_sample=False,
|
||||
temperature=0.0,
|
||||
top_p=1.0,
|
||||
)
|
||||
|
||||
gen_ids = out[0, input_ids.shape[-1]:]
|
||||
verdict = tokenizer.decode(gen_ids, skip_special_tokens=True).strip()
|
||||
print(verdict) # Expected: "Yes" or "No"
|
||||
```
|
||||
|
||||
### 2) Local (GGUF / llama.cpp)
|
||||
|
||||
If the GGUF file is at repo root:
|
||||
|
||||
```bash
|
||||
./main -m nehme-flashcheck-1b.Q8_0.gguf -p "Document: ...\n\nClaim: ..."
|
||||
```
|
||||
|
||||
If you placed it in a `gguf/` folder:
|
||||
|
||||
```bash
|
||||
./main -m gguf/nehme-flashcheck-1b.Q8_0.gguf -p "Document: ...\n\nClaim: ..."
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
- For best results, keep the prompt format stable (`Document:` then `Claim:`) and use deterministic decoding.
|
||||
- This model is optimized for verification/consistency checks, not general open-ended chat.
|
||||
|
||||
## Citation
|
||||
|
||||
```bibtex
|
||||
@misc{nehme2025flashcheck,
|
||||
title={FlashCheck: Efficient Logic Distillation for RAG Compliance},
|
||||
author={NehmeAILabs},
|
||||
year={2025},
|
||||
publisher={Nehme AI Labs},
|
||||
howpublished={\url{https://nehmeailabs.com}}
|
||||
}
|
||||
```
|
||||
|
||||
3
added_tokens.json
Normal file
3
added_tokens.json
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:50b2f405ba56a26d4913fd772089992252d7f942123cc0a034d96424221ba946
|
||||
size 35
|
||||
47
chat_template.jinja
Normal file
47
chat_template.jinja
Normal file
@@ -0,0 +1,47 @@
|
||||
{{ bos_token }}
|
||||
{%- if messages[0]['role'] == 'system' -%}
|
||||
{%- if messages[0]['content'] is string -%}
|
||||
{%- set first_user_prefix = messages[0]['content'] + '
|
||||
|
||||
' -%}
|
||||
{%- else -%}
|
||||
{%- set first_user_prefix = messages[0]['content'][0]['text'] + '
|
||||
|
||||
' -%}
|
||||
{%- endif -%}
|
||||
{%- set loop_messages = messages[1:] -%}
|
||||
{%- else -%}
|
||||
{%- set first_user_prefix = "" -%}
|
||||
{%- set loop_messages = messages -%}
|
||||
{%- endif -%}
|
||||
{%- for message in loop_messages -%}
|
||||
{%- if (message['role'] == 'user') != (loop.index0 % 2 == 0) -%}
|
||||
{{ raise_exception("Conversation roles must alternate user/assistant/user/assistant/...") }}
|
||||
{%- endif -%}
|
||||
{%- if (message['role'] == 'assistant') -%}
|
||||
{%- set role = "model" -%}
|
||||
{%- else -%}
|
||||
{%- set role = message['role'] -%}
|
||||
{%- endif -%}
|
||||
{{ '<start_of_turn>' + role + '
|
||||
' + (first_user_prefix if loop.first else "") }}
|
||||
{%- if message['content'] is string -%}
|
||||
{{ message['content'] | trim }}
|
||||
{%- elif message['content'] is iterable -%}
|
||||
{%- for item in message['content'] -%}
|
||||
{%- if item['type'] == 'image' -%}
|
||||
{{ '<start_of_image>' }}
|
||||
{%- elif item['type'] == 'text' -%}
|
||||
{{ item['text'] | trim }}
|
||||
{%- endif -%}
|
||||
{%- endfor -%}
|
||||
{%- else -%}
|
||||
{{ raise_exception("Invalid content type") }}
|
||||
{%- endif -%}
|
||||
{{ '<end_of_turn>
|
||||
' }}
|
||||
{%- endfor -%}
|
||||
{%- if add_generation_prompt -%}
|
||||
{{ '<start_of_turn>model
|
||||
' }}
|
||||
{%- endif -%}
|
||||
3
config.json
Normal file
3
config.json
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:c8ea7b32fb8da8c4a902be8df5ab5aa799e8652e4bd0492d96153b4de51b5835
|
||||
size 1850
|
||||
3
model.safetensors
Normal file
3
model.safetensors
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:466bf2ce27e5e63b41efa8f866e39ae125cab0866524fed4bb7a28231a487b55
|
||||
size 1999811208
|
||||
3
nehme-flashcheck-1b.Q8_0.gguf
Normal file
3
nehme-flashcheck-1b.Q8_0.gguf
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:6b09969e689a875462a878604f26b4da53dfca1b6923605dcdc404679a21d3c6
|
||||
size 1069306144
|
||||
3
special_tokens_map.json
Normal file
3
special_tokens_map.json
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:45a857d8a2495d0be30a5d2d6de03278195eb028b6e0b8efc248bfa697d65f05
|
||||
size 670
|
||||
3
tokenizer.json
Normal file
3
tokenizer.json
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:4667f2089529e8e7657cfb6d1c19910ae71ff5f28aa7ab2ff2763330affad795
|
||||
size 33384568
|
||||
3
tokenizer.model
Normal file
3
tokenizer.model
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:1299c11d7cf632ef3b4e11937501358ada021bbdf7c47638d13c0ee982f2e79c
|
||||
size 4689074
|
||||
3
tokenizer_config.json
Normal file
3
tokenizer_config.json
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:22f33b496d1fa8c5c5a02582417266b059a0747317f708993e2760e50319f815
|
||||
size 1157008
|
||||
Reference in New Issue
Block a user