Downloads · 30 days
6
11% of all-time downloads
Ali-Bhai/deberta-tool-hallucination-span-detector
deberta-tool-hallucination-span-detector is a token classification model from Ali-Bhai. Use it when you need labels on individual words, such as names. It is set up for transformers. The card lists the license as apache-2.0.
This is the final span-level model for the tool hallucination coursework. It predicts RAGTruth-style hallucinated character spans in assistant answers grounded on tool outputs.
Downloads · 30 days
6
11% of all-time downloads
All-time downloads
53
Public
Parameters
141M
592 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors565 MB · 94%
From the Hugging Face model README
This is the final span-level model for the tool hallucination coursework. It predicts RAGTruth-style hallucinated character spans in assistant answers grounded on tool outputs.
Input record fields:
query: user questioncontext: tool response or tool evidenceoutput: assistant answeravailable_tool_names: optional list of available toolsOutput:
outputThe model is a microsoft/deberta-v3-small token classifier. Because some answers are long, inference uses overlapping answer windows. Each window is placed first in the sequence, followed by question, tool responses, and available tool names. Only answer-window tokens are supervised during training.
The validation-selected decoding configuration is:
{
"threshold": 0.5,
"min_span_chars": 1,
"min_span_tokens": 1,
"merge_gap_chars": 1,
"strip_predicted_span_whitespace": true,
"drop_spans_without_alnum": true,
"score_name": "sum_non_O_probability"
}
{
"row_accuracy": 0.9516908212560387,
"row_macro_f1": 0.9553091397849462,
"binary_f1": 0.9561403508771931,
"exact_span_f1": 0.8207171314741037,
"overlap_span_f1_iou_0_01": 0.8685258964143425,
"overlap_span_f1_iou_0_50": 0.8366533864541832,
"char_span_precision": 0.971356003950896,
"char_span_recall": 0.9955169920462762,
"char_span_f1": 0.9832881016997572
}
from transformers import AutoTokenizer, AutoModelForTokenClassification
repo_id = "Ali-Bhai/deberta-tool-hallucination-span-detector"
tokenizer = AutoTokenizer.from_pretrained(repo_id, use_fast=True)
model = AutoModelForTokenClassification.from_pretrained(repo_id)
from transformers import AutoTokenizer, AutoModelForTokenClassification
from span_inference import predict_record
repo_id = "Ali-Bhai/deberta-tool-hallucination-span-detector"
tokenizer = AutoTokenizer.from_pretrained(repo_id, use_fast=True)
model = AutoModelForTokenClassification.from_pretrained(repo_id)
record = {
"query": "What did the tool return?",
"context": "... tool output ...",
"output": "... assistant answer ...",
"available_tool_names": [],
}
prediction = predict_record(record, model, tokenizer, device="cuda")
print(prediction["predicted_spans"])
The earlier row-level classifier is here: https://huggingface.co/Ali-Bhai/deberta-tool-hallucination-detector.