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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
library_name: onnx
|
| 4 |
+
pipeline_tag: text-classification
|
| 5 |
+
tags:
|
| 6 |
+
- groundedness
|
| 7 |
+
- hallucination-detection
|
| 8 |
+
- cross-encoder
|
| 9 |
+
- onnx
|
| 10 |
+
- multilingual
|
| 11 |
+
language:
|
| 12 |
+
- bg
|
| 13 |
+
- hr
|
| 14 |
+
- cs
|
| 15 |
+
- da
|
| 16 |
+
- nl
|
| 17 |
+
- en
|
| 18 |
+
- et
|
| 19 |
+
- fi
|
| 20 |
+
- fr
|
| 21 |
+
- de
|
| 22 |
+
- el
|
| 23 |
+
- hu
|
| 24 |
+
- ga
|
| 25 |
+
- it
|
| 26 |
+
- lv
|
| 27 |
+
- lt
|
| 28 |
+
- mt
|
| 29 |
+
- pl
|
| 30 |
+
- pt
|
| 31 |
+
- ro
|
| 32 |
+
- sk
|
| 33 |
+
- sl
|
| 34 |
+
- es
|
| 35 |
+
- sv
|
| 36 |
+
- tr
|
| 37 |
+
- az
|
| 38 |
+
base_model: FacebookAI/xlm-roberta-base
|
| 39 |
+
---
|
| 40 |
+
|
| 41 |
+
# groundedness
|
| 42 |
+
|
| 43 |
+
Is a sentence of model output supported by the source passages it was supposed to rest on?
|
| 44 |
+
A cross-encoder over `(source, candidate)` pairs, two classes, 26 languages, exported to
|
| 45 |
+
ONNX fp16 and run on CPU. Built for [`flowx-border`](https://github.com/flowx-ai/border),
|
| 46 |
+
where it is the T3 `groundedness` detector.
|
| 47 |
+
|
| 48 |
+
**Read the two evaluations below as different questions, not as a range.** The corpus
|
| 49 |
+
figures are high and the hand-written ones are not, and the gap is the honest content of
|
| 50 |
+
this card.
|
| 51 |
+
|
| 52 |
+
## Two classes, not three
|
| 53 |
+
|
| 54 |
+
`grounded` and `not_grounded`. Earlier candidates for this detector predicted `supported`,
|
| 55 |
+
`unsupported` and `contradicted`, and the library collapses the last two into one action
|
| 56 |
+
anyway, so the three-way head optimised a boundary no caller ever sees. Across six such
|
| 57 |
+
candidates `unstated` and the conflict registers were anti-correlated at -0.98: they traded
|
| 58 |
+
points along it.
|
| 59 |
+
|
| 60 |
+
The trade that produced: measured at the trained length, the binary objective **cost 0.048
|
| 61 |
+
of accuracy** on hand-written probes against the best three-way candidate, 0.7143 to 0.6667.
|
| 62 |
+
It is published anyway, for the reason in the next section.
|
| 63 |
+
|
| 64 |
+
## Use it at a threshold of 0.78, not at argmax
|
| 65 |
+
|
| 66 |
+
grounded if p(grounded) >= 0.78
|
| 67 |
+
|
| 68 |
+
Swept on the validation split and only then applied to the hand-written probes. Every bar
|
| 69 |
+
from 0.78 up clears the probe described below while not-grounded recall *rises*, 0.9641 to
|
| 70 |
+
0.9699, so the bar costs nothing measurable on held-out data.
|
| 71 |
+
|
| 72 |
+
**The weakness travels with the number.** That validation curve is nearly flat across the
|
| 73 |
+
whole range, so validation does not pick 0.78. One probe does, and a threshold chosen by the
|
| 74 |
+
case it must catch is weaker evidence than one chosen by a distribution.
|
| 75 |
+
|
| 76 |
+
## What it is for: the case the other candidates got wrong
|
| 77 |
+
|
| 78 |
+
Against a source stating that withdrawals incur a fee for the first twelve months and are
|
| 79 |
+
free afterwards, the candidate *"Withdrawals are free from the day the account opens"* is a
|
| 80 |
+
temporal contradiction. Six earlier candidates called it **grounded at 0.9906 to 0.9995**.
|
| 81 |
+
This one reads 0.7681, so any bar from 0.78 reports it.
|
| 82 |
+
|
| 83 |
+
More usefully, it is the only one of seven that reads the source at all. Same candidate,
|
| 84 |
+
three sources:
|
| 85 |
+
|
| 86 |
+
| source | best three-way candidate | this model |
|
| 87 |
+
|---|---|---|
|
| 88 |
+
| the real source, which contradicts it | grounded 0.9991 | **not grounded 0.7681** |
|
| 89 |
+
| an unrelated passage in another language | grounded 0.9994 | **not grounded 0.0070** |
|
| 90 |
+
| a source that does state it outright | not grounded 0.0007 | **grounded 0.8365** |
|
| 91 |
+
|
| 92 |
+
The three-way candidate is inverted on this sentence and gives an unrelated Romanian
|
| 93 |
+
passage the same answer as the real source. Three different answers for one candidate is
|
| 94 |
+
what makes this a judgement about the source rather than about the sentence.
|
| 95 |
+
|
| 96 |
+
## Corpus evaluation, 2,062 held-out rows
|
| 97 |
+
|
| 98 |
+
Threshold 0.78, the shipped bar, at the trained length of 512 tokens.
|
| 99 |
+
|
| 100 |
+
| | |
|
| 101 |
+
|---|---|
|
| 102 |
+
| overall accuracy | 0.9471 |
|
| 103 |
+
| not-grounded recall | 0.9612 |
|
| 104 |
+
| pair accuracy | 0.8991 |
|
| 105 |
+
| per-language range | 0.887 (`pl`) to 1.000, over 26 languages |
|
| 106 |
+
| weakest three | `pl` 0.887, `en` 0.897, `az` 0.912 |
|
| 107 |
+
|
| 108 |
+
Pair accuracy is the number to prefer: the corpus is source-side pairs, one candidate
|
| 109 |
+
against two sources with opposite labels and the candidate byte-identical across the pair, so
|
| 110 |
+
a model that ignored the source scores near zero on it by construction.
|
| 111 |
+
|
| 112 |
+
**These figures describe a synthetic corpus and its own held-out split.** The generator wrote
|
| 113 |
+
both, so they measure generalisation within one generator's style. That is why the next
|
| 114 |
+
section exists and why it disagrees.
|
| 115 |
+
|
| 116 |
+
## Hand-written evaluation, 42 probes
|
| 117 |
+
|
| 118 |
+
Written by a person, not by any generator, across seven ways a summary goes wrong.
|
| 119 |
+
|
| 120 |
+
| configuration | accuracy |
|
| 121 |
+
|---|---|
|
| 122 |
+
| this model alone, at 0.78 | 0.6905 |
|
| 123 |
+
| this model plus the library's deterministic rule layer | **0.7381** |
|
| 124 |
+
|
| 125 |
+
**Roughly one call in four is wrong on this set, against one in twenty on the corpus split.**
|
| 126 |
+
Both numbers are real. The probe set is adversarial by construction, seven hard shapes in
|
| 127 |
+
equal proportion, which no real traffic is; the corpus split is generator-shaped, which no
|
| 128 |
+
real traffic is either. The truth for any given deployment is between them and closer to
|
| 129 |
+
whichever resembles that traffic.
|
| 130 |
+
|
| 131 |
+
The rule layer is `detectors/claim_conflict.py` in the library and needs no weights. Where a
|
| 132 |
+
candidate's content words all appear in its source except a numeral or an absolute
|
| 133 |
+
quantifier, it reports a conflict deterministically. On the 42 probes it fires 9 times and is
|
| 134 |
+
right 9 times.
|
| 135 |
+
|
| 136 |
+
## Known weakness: it errs toward caution
|
| 137 |
+
|
| 138 |
+
The failure mode is false `not_grounded` on claims that are genuinely supported. Eight of
|
| 139 |
+
thirteen probe failures are that direction, and the clearest case is a claim *weaker* than
|
| 140 |
+
its source: against a source saying withdrawals incur a fee for the first twelve months,
|
| 141 |
+
*"There is a handling fee for early withdrawals"* reads `not_grounded` at 0.8625.
|
| 142 |
+
|
| 143 |
+
For a guardrail that is the safer direction, since a false "not grounded" costs a reviewer's
|
| 144 |
+
attention and a false "grounded" puts an unsupported claim in front of a customer. It is
|
| 145 |
+
still a cost, and it is why the detector is **disabled in both policies that ship with the
|
| 146 |
+
library**. A caller who wants it enables it in one line and should measure it on their own
|
| 147 |
+
traffic first.
|
| 148 |
+
|
| 149 |
+
## What it needs
|
| 150 |
+
|
| 151 |
+
- The full 512-token window. Scores saturate by 256 and degrade below that; at 96 tokens
|
| 152 |
+
this model reads the probe above as grounded, which is the wrong answer arrived at by
|
| 153 |
+
truncation rather than by judgement.
|
| 154 |
+
- Sources. With none supplied the library records that the check could not run rather than
|
| 155 |
+
reporting a clean scan.
|
| 156 |
+
- Pair order `(source, candidate)`. Reversed, the head answers a different question
|
| 157 |
+
confidently.
|
| 158 |
+
|
| 159 |
+
## Not evaluated
|
| 160 |
+
|
| 161 |
+
Per-language figures rest on roughly 80 rows each, so one item moves a language by more than
|
| 162 |
+
a point. The corpus contains no case where a qualifier is dropped from a conditional
|
| 163 |
+
statement expressed in words rather than digits, and no unit conversions such as `24 months`
|
| 164 |
+
against `two years`; both are known gaps rather than measured strengths. Nothing here is
|
| 165 |
+
evaluated against human-annotated groundedness data, because none exists for these 26
|
| 166 |
+
languages.
|
| 167 |
+
|
| 168 |
+
## Licence
|
| 169 |
+
|
| 170 |
+
Apache-2.0. Trained on synthetic data generated for this purpose.
|