Text Generation
Transformers
Safetensors
qwen3_5_moe
image-text-to-text
darwin
darwin-v9
darwin-jgos
vidraft
final-bench
qwen
qwen3.5
Mixture of Experts
mixture-of-experts
sparse-moe
397b
a17b
hybrid-attention
linear-attention
long-context
262k-context
reasoning
reasoning-model
thinking
chain-of-thought
cot
math
science
stem
code
agentic
tool-calling
function-calling
ztc
zero-token-confidence
confidence-estimation
uncertainty-quantification
hallucination-detection
calibration
self-verification
selective-prediction
pre-action-gating
agent-safety
llm-router
guardrails
gpqa
gpqa-diamond
mmlu-pro
benchmark
Eval Results
greedy
korean
english
bilingual
multilingual-llm
vllm
sglang
openai-compatible
multi-gpu
h100
conversational
Eval Results (legacy)
compressed-tensors
Instructions to use FINAL-Bench/Darwin-397B-ZTC with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use FINAL-Bench/Darwin-397B-ZTC with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="FINAL-Bench/Darwin-397B-ZTC") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("FINAL-Bench/Darwin-397B-ZTC") model = AutoModelForMultimodalLM.from_pretrained("FINAL-Bench/Darwin-397B-ZTC", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use FINAL-Bench/Darwin-397B-ZTC with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "FINAL-Bench/Darwin-397B-ZTC" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "FINAL-Bench/Darwin-397B-ZTC", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/FINAL-Bench/Darwin-397B-ZTC
- SGLang
How to use FINAL-Bench/Darwin-397B-ZTC with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "FINAL-Bench/Darwin-397B-ZTC" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "FINAL-Bench/Darwin-397B-ZTC", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "FINAL-Bench/Darwin-397B-ZTC" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "FINAL-Bench/Darwin-397B-ZTC", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use FINAL-Bench/Darwin-397B-ZTC with Docker Model Runner:
docker model run hf.co/FINAL-Bench/Darwin-397B-ZTC
ZTC usage example
Browse files- ztc/usage.py +55 -0
ztc/usage.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Zero-Token Confidence (ZTC) — usage
|
| 2 |
+
#
|
| 3 |
+
# ZTC reads the model's own internal state ONCE, before generation, and returns
|
| 4 |
+
# the probability that the answer the model is about to produce will be correct.
|
| 5 |
+
# No extra tokens are generated. No second model is required.
|
| 6 |
+
#
|
| 7 |
+
# probe file : ztc/ztc_probe_darwin397b.npz (45 KB)
|
| 8 |
+
# input : final-layer hidden state of the last prompt token (4096-dim)
|
| 9 |
+
# output : score, and a calibrated probability in [0, 1]
|
| 10 |
+
#
|
| 11 |
+
# Reported performance on this model (PubMedQA, 539 items, 146 incorrect):
|
| 12 |
+
# self-reported confidence AUROC 0.7646
|
| 13 |
+
# ZTC AUROC 0.8801 (permutation null z = 13.31)
|
| 14 |
+
|
| 15 |
+
import numpy as np
|
| 16 |
+
import torch
|
| 17 |
+
from transformers import AutoModel, AutoTokenizer
|
| 18 |
+
|
| 19 |
+
MODEL = "FINAL-Bench/Darwin-397B-ZTC"
|
| 20 |
+
PROBE = "ztc/ztc_probe_darwin397b.npz"
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
class ZTC:
|
| 24 |
+
def __init__(self, path=PROBE):
|
| 25 |
+
z = np.load(path)
|
| 26 |
+
self.w = z["w"].astype(np.float32)
|
| 27 |
+
self.mu = z["mu"].astype(np.float32)
|
| 28 |
+
self.sd = z["sd"].astype(np.float32)
|
| 29 |
+
self.s_mean = float(z["s_mean"]); self.s_std = float(z["s_std"])
|
| 30 |
+
self.A = float(z["cal_A"]); self.B = float(z["cal_B"])
|
| 31 |
+
|
| 32 |
+
def score(self, hidden):
|
| 33 |
+
"""hidden: (4096,) or (batch, 4096) final-layer state of the last prompt token."""
|
| 34 |
+
h = np.asarray(hidden, dtype=np.float32)
|
| 35 |
+
s = ((h - self.mu) / self.sd) @ self.w
|
| 36 |
+
p = 1.0 / (1.0 + np.exp(-(self.A * (s - self.s_mean) / self.s_std + self.B)))
|
| 37 |
+
return s, p
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
# --- one forward pass, zero generated tokens -------------------------------
|
| 41 |
+
tok = AutoTokenizer.from_pretrained(MODEL)
|
| 42 |
+
model = AutoModel.from_pretrained(MODEL, dtype=torch.bfloat16, device_map="auto").eval()
|
| 43 |
+
ztc = ZTC()
|
| 44 |
+
|
| 45 |
+
prompt = "Question: ...\nAnswer:"
|
| 46 |
+
b = tok(prompt, return_tensors="pt").to(next(model.parameters()).device)
|
| 47 |
+
with torch.no_grad():
|
| 48 |
+
h = model(**b).last_hidden_state[0, -1].float().cpu().numpy()
|
| 49 |
+
|
| 50 |
+
s, p = ztc.score(h)
|
| 51 |
+
print("ZTC score %.3f -> P(correct) = %.3f" % (s, p))
|
| 52 |
+
|
| 53 |
+
# Gate the action, not the answer:
|
| 54 |
+
# if p < THRESHOLD: do not call the tool / escalate / answer "I don't know"
|
| 55 |
+
# else: generate as usual
|