citebound 0.2.0__tar.gz → 0.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {citebound-0.2.0 → citebound-0.2.1}/PKG-INFO +4 -4
- {citebound-0.2.0 → citebound-0.2.1}/README.md +3 -3
- {citebound-0.2.0 → citebound-0.2.1}/pyproject.toml +1 -1
- {citebound-0.2.0 → citebound-0.2.1}/src/citebound/__init__.py +1 -1
- {citebound-0.2.0 → citebound-0.2.1}/src/citebound/grounding.py +105 -1
- {citebound-0.2.0 → citebound-0.2.1}/src/citebound.egg-info/PKG-INFO +4 -4
- {citebound-0.2.0 → citebound-0.2.1}/src/citebound.egg-info/SOURCES.txt +1 -0
- citebound-0.2.1/tests/test_evidence_commentary.py +187 -0
- {citebound-0.2.0 → citebound-0.2.1}/LICENSE +0 -0
- {citebound-0.2.0 → citebound-0.2.1}/setup.cfg +0 -0
- {citebound-0.2.0 → citebound-0.2.1}/src/citebound/citations.py +0 -0
- {citebound-0.2.0 → citebound-0.2.1}/src/citebound/cli.py +0 -0
- {citebound-0.2.0 → citebound-0.2.1}/src/citebound/passages.py +0 -0
- {citebound-0.2.0 → citebound-0.2.1}/src/citebound/polarity.py +0 -0
- {citebound-0.2.0 → citebound-0.2.1}/src/citebound/provenance.py +0 -0
- {citebound-0.2.0 → citebound-0.2.1}/src/citebound/py.typed +0 -0
- {citebound-0.2.0 → citebound-0.2.1}/src/citebound/refusal.py +0 -0
- {citebound-0.2.0 → citebound-0.2.1}/src/citebound/units.py +0 -0
- {citebound-0.2.0 → citebound-0.2.1}/src/citebound.egg-info/dependency_links.txt +0 -0
- {citebound-0.2.0 → citebound-0.2.1}/src/citebound.egg-info/entry_points.txt +0 -0
- {citebound-0.2.0 → citebound-0.2.1}/src/citebound.egg-info/requires.txt +0 -0
- {citebound-0.2.0 → citebound-0.2.1}/src/citebound.egg-info/top_level.txt +0 -0
- {citebound-0.2.0 → citebound-0.2.1}/tests/test_benchmark.py +0 -0
- {citebound-0.2.0 → citebound-0.2.1}/tests/test_citations.py +0 -0
- {citebound-0.2.0 → citebound-0.2.1}/tests/test_cli.py +0 -0
- {citebound-0.2.0 → citebound-0.2.1}/tests/test_grounding.py +0 -0
- {citebound-0.2.0 → citebound-0.2.1}/tests/test_passages_and_provenance.py +0 -0
- {citebound-0.2.0 → citebound-0.2.1}/tests/test_polarity.py +0 -0
- {citebound-0.2.0 → citebound-0.2.1}/tests/test_readme_claims.py +0 -0
- {citebound-0.2.0 → citebound-0.2.1}/tests/test_units.py +0 -0
- {citebound-0.2.0 → citebound-0.2.1}/tests/test_verdict_invariants.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: citebound
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: Bind every claim an LLM makes to the passage it cites. Deterministic, dependency-free verification for RAG and agent answers: every number and citation checked against the retrieved context, wrong citations repaired, unsupported sentences stripped, ungroundable answers refused. No model call, no API key.
|
|
5
5
|
License-Expression: Apache-2.0
|
|
6
6
|
Project-URL: Homepage, https://github.com/92kareeem/citebound
|
|
@@ -311,15 +311,15 @@ verification tools publish either figure; the second one is the one that matters
|
|
|
311
311
|
|
|
312
312
|
| Metric | Hand-written, 52 pairs | **Derived from RAGTruth, 134 pairs** |
|
|
313
313
|
|---|---|---|
|
|
314
|
-
| Pair accuracy | 60% (31 of 52) | **
|
|
314
|
+
| Pair accuracy | 60% (31 of 52) | **24% (32 of 134)** |
|
|
315
315
|
| Wrong claims caught | 34 of 51 | 39 of 134 |
|
|
316
|
-
| Right claims dropped | 5 of 53 |
|
|
316
|
+
| Right claims dropped | 5 of 53 | 20 of 134 |
|
|
317
317
|
|
|
318
318
|
The hand-written set mutates one operator or one unit at a time, so it says
|
|
319
319
|
which specific failures the gate can see. The derived set is built from
|
|
320
320
|
[RAGTruth](https://arxiv.org/abs/2401.00396)'s human-labelled hallucination
|
|
321
321
|
spans: every sentence was written by a production model and judged by somebody
|
|
322
|
-
other than us, so it says how much of the real problem that reaches. **Read
|
|
322
|
+
other than us, so it says how much of the real problem that reaches. **Read 24%
|
|
323
323
|
as the share of real hallucinations a deterministic layer catches on its own,
|
|
324
324
|
never as a detection rate.**
|
|
325
325
|
|
|
@@ -275,15 +275,15 @@ verification tools publish either figure; the second one is the one that matters
|
|
|
275
275
|
|
|
276
276
|
| Metric | Hand-written, 52 pairs | **Derived from RAGTruth, 134 pairs** |
|
|
277
277
|
|---|---|---|
|
|
278
|
-
| Pair accuracy | 60% (31 of 52) | **
|
|
278
|
+
| Pair accuracy | 60% (31 of 52) | **24% (32 of 134)** |
|
|
279
279
|
| Wrong claims caught | 34 of 51 | 39 of 134 |
|
|
280
|
-
| Right claims dropped | 5 of 53 |
|
|
280
|
+
| Right claims dropped | 5 of 53 | 20 of 134 |
|
|
281
281
|
|
|
282
282
|
The hand-written set mutates one operator or one unit at a time, so it says
|
|
283
283
|
which specific failures the gate can see. The derived set is built from
|
|
284
284
|
[RAGTruth](https://arxiv.org/abs/2401.00396)'s human-labelled hallucination
|
|
285
285
|
spans: every sentence was written by a production model and judged by somebody
|
|
286
|
-
other than us, so it says how much of the real problem that reaches. **Read
|
|
286
|
+
other than us, so it says how much of the real problem that reaches. **Read 24%
|
|
287
287
|
as the share of real hallucinations a deterministic layer catches on its own,
|
|
288
288
|
never as a detection rate.**
|
|
289
289
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "citebound"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.1"
|
|
4
4
|
description = "Bind every claim an LLM makes to the passage it cites. Deterministic, dependency-free verification for RAG and agent answers: every number and citation checked against the retrieved context, wrong citations repaired, unsupported sentences stripped, ungroundable answers refused. No model call, no API key."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.10"
|
|
@@ -23,7 +23,7 @@ from .passages import Passage, from_langchain, from_llamaindex, passages_from_te
|
|
|
23
23
|
from .provenance import HASH_RECIPE, check_provenance, document_sha256, provenance_hash
|
|
24
24
|
from .refusal import REFUSAL_SENTINEL, RefusalReason, is_refusal, refusal_text
|
|
25
25
|
|
|
26
|
-
__version__ = "0.2.
|
|
26
|
+
__version__ = "0.2.1"
|
|
27
27
|
|
|
28
28
|
__all__ = [
|
|
29
29
|
"HASH_RECIPE",
|
|
@@ -28,6 +28,23 @@ makes sure every citation points where it says it does. In particular:
|
|
|
28
28
|
**every number in a claim must appear in a passage that claim cites.** For a
|
|
29
29
|
system answering questions about refund windows, notice periods and limits,
|
|
30
30
|
a plausible-but-wrong number is the most damaging thing it can say.
|
|
31
|
+
|
|
32
|
+
One sentence shape is an explicit exception to "every claim needs lexical
|
|
33
|
+
support": a blanket statement that no answer is available, such as "unable to
|
|
34
|
+
answer based on given passages", or a bare pointer to citations with no
|
|
35
|
+
assertion at all, such as "(Passages 1, 2, 3)". Neither names anything
|
|
36
|
+
specific the evidence supposedly lacks, so neither can be a false claim about
|
|
37
|
+
evidence coverage; stripping them punishes a model for honestly admitting it
|
|
38
|
+
has nothing to add. This gate accepts such a sentence outright rather than
|
|
39
|
+
discarding it the way a true lead-in is discarded, so the reader still sees
|
|
40
|
+
it. A sentence naming a SPECIFIC absent topic - "the passages do not mention
|
|
41
|
+
pricing" - is deliberately NOT included here, even though it reads the same
|
|
42
|
+
way: measured against real labelled data, models also use that exact wording
|
|
43
|
+
to falsely deny that the evidence covers something it actually does, and
|
|
44
|
+
lexical overlap cannot tell a true denial from a false one. A sentence
|
|
45
|
+
carrying any digit is never accepted this way either: a number is the single
|
|
46
|
+
highest-stakes thing this gate exists to check, so a figure can never ride
|
|
47
|
+
through on the back of surrounding meta-language.
|
|
31
48
|
"""
|
|
32
49
|
|
|
33
50
|
from __future__ import annotations
|
|
@@ -80,6 +97,38 @@ _SENTENCE_SPLIT_RE = re.compile(r"(?<=[.!?])\s+|\n+")
|
|
|
80
97
|
_CHUNK_REF_RE = re.compile(r"(?:\bchunks?\s*)?[\w-]*_(?:p\d+_)?s\d+_c\d+\b|(?<![\w])_c\d+\b")
|
|
81
98
|
_EMPTY_PARENS_RE = re.compile(r"\(\s*[,;\s]*\)")
|
|
82
99
|
|
|
100
|
+
# Each alternative is a wording that makes NO topic-specific claim about what
|
|
101
|
+
# the evidence does or doesn't cover - only a blanket statement that no answer
|
|
102
|
+
# is available. That distinction was reached empirically, not assumed: an
|
|
103
|
+
# earlier, broader draft of this pattern also matched "the passages do not
|
|
104
|
+
# provide X" for a named X (pricing, a procedure, a date). Measured against
|
|
105
|
+
# RAGTruth's labels, four marked hallucinations used exactly that wording to
|
|
106
|
+
# FALSELY deny that the evidence covers something it actually does, and lexical
|
|
107
|
+
# overlap could not separate those from genuine true denials (both ranged
|
|
108
|
+
# 0.06-0.40 on their own topic words). A claim naming a specific absent fact is
|
|
109
|
+
# a real, falsifiable claim about evidence coverage, even if this gate cannot
|
|
110
|
+
# verify it; only a claim that names nothing specific is safe to accept
|
|
111
|
+
# outright. "Based on the passages, X happens" is excluded for the same
|
|
112
|
+
# reason: X is a checkable claim, and only its citation attribution mentions
|
|
113
|
+
# the evidence.
|
|
114
|
+
_EVIDENCE_COMMENTARY_RE = re.compile(
|
|
115
|
+
r"\b(?:"
|
|
116
|
+
r"(?:unable|not\s+able|cannot|can\s+not|can'?t)\s+(?:to\s+)?answer\b.*?\b"
|
|
117
|
+
r"(?:passages?|context|documents?|information)"
|
|
118
|
+
r"|(?:may\s+not|do(?:es)?\s+not|don'?t|doesn'?t)\s+have\s+"
|
|
119
|
+
r"(?:all\s+the\s+|sufficient\s+|enough\s+|complete\s+)?(?:necessary\s+)?information"
|
|
120
|
+
r"\s+to\s+answer\s+the\s+question\b"
|
|
121
|
+
r")",
|
|
122
|
+
re.IGNORECASE,
|
|
123
|
+
)
|
|
124
|
+
# A sentence that is nothing but a pointer to its own citations - "(Passages 1,
|
|
125
|
+
# 2, and 3)" - rather than any assertion. Full-string anchored so this can
|
|
126
|
+
# never match a real sentence that merely happens to end in a parenthetical.
|
|
127
|
+
_BARE_CITATION_RE = re.compile(
|
|
128
|
+
r"^\(?(?:see\s+)?passages?\s+\d+(?:\s*(?:,\s*and|,|and|-|to)\s*\d+)*\)?\.?$", re.IGNORECASE
|
|
129
|
+
)
|
|
130
|
+
_HAS_DIGIT_RE = re.compile(r"\d")
|
|
131
|
+
|
|
83
132
|
_STOPWORDS = frozenset(
|
|
84
133
|
{
|
|
85
134
|
"a",
|
|
@@ -253,6 +302,36 @@ def _is_lead_in(sentence: str) -> bool:
|
|
|
253
302
|
return sentence.rstrip().endswith(":")
|
|
254
303
|
|
|
255
304
|
|
|
305
|
+
def _is_evidence_commentary(sentence: str) -> bool:
|
|
306
|
+
"""Is this a blanket admission of no answer, naming no specific topic?
|
|
307
|
+
|
|
308
|
+
"Unable to answer based on given passages" and "(Passages 1, 2, 3)" assert
|
|
309
|
+
nothing checkable, so stripping them punishes a model for honestly
|
|
310
|
+
admitting it has nothing to add. Unlike a lead-in, a matching sentence is
|
|
311
|
+
kept, not discarded, since it still carries information the reader should
|
|
312
|
+
see.
|
|
313
|
+
|
|
314
|
+
Deliberately narrower than "any sentence reporting on the evidence":
|
|
315
|
+
"the passages do not mention pricing" names a specific absent topic, which
|
|
316
|
+
IS a falsifiable claim about coverage, just one this gate cannot verify.
|
|
317
|
+
Measured against RAGTruth's labels, models use that wording both honestly
|
|
318
|
+
and to falsely deny covered information, and lexical overlap could not
|
|
319
|
+
separate the two (see the module docstring). Only a sentence that names
|
|
320
|
+
nothing specific is safe to accept outright.
|
|
321
|
+
|
|
322
|
+
A sentence carrying any digit is excluded even if the wording matches: a
|
|
323
|
+
number is the one thing this gate always checks, so no figure may ride
|
|
324
|
+
through on the back of surrounding meta-language. The bare-citation
|
|
325
|
+
pattern is the one exception, since its only digits are passage indices
|
|
326
|
+
inside a full-string match that admits nothing else to hide behind them.
|
|
327
|
+
"""
|
|
328
|
+
if _BARE_CITATION_RE.match(sentence.strip()):
|
|
329
|
+
return True
|
|
330
|
+
if _HAS_DIGIT_RE.search(sentence):
|
|
331
|
+
return False
|
|
332
|
+
return bool(_EVIDENCE_COMMENTARY_RE.search(sentence))
|
|
333
|
+
|
|
334
|
+
|
|
256
335
|
def _cited_units(answer: str) -> list[tuple[str, list[str]]]:
|
|
257
336
|
"""Pair each GROUP of citation tags with the text before it.
|
|
258
337
|
|
|
@@ -441,19 +520,44 @@ def verify(
|
|
|
441
520
|
polarity_guard = PolarityGuard()
|
|
442
521
|
unit_guard = UnitGuard()
|
|
443
522
|
|
|
523
|
+
def accept_as_commentary(text: str, tag_ids: Sequence[str], cited: Sequence[Passage]) -> None:
|
|
524
|
+
# Accepted outright: see _is_evidence_commentary. Kept, with whatever
|
|
525
|
+
# it was originally cited with, never verified against evidence
|
|
526
|
+
# content, since there is none to check it against.
|
|
527
|
+
nonlocal total
|
|
528
|
+
total += 1
|
|
529
|
+
cited_here = tuple(p.id for p in cited)
|
|
530
|
+
tags = " ".join(f"[chunk:{p.id}]" for p in cited)
|
|
531
|
+
kept.append(f"{text} {tags}".rstrip())
|
|
532
|
+
claims.append(Claim(text, ClaimStatus.SUPPORTED, tuple(tag_ids), cited_here))
|
|
533
|
+
for pid in cited_here:
|
|
534
|
+
if pid not in cited_ids:
|
|
535
|
+
cited_ids.append(pid)
|
|
536
|
+
|
|
444
537
|
for prose, tag_ids in units:
|
|
445
538
|
# Tags naming passages that were never retrieved are fabricated; they
|
|
446
539
|
# cannot support anything, so they simply drop out of the group.
|
|
447
540
|
cited = [by_id[i] for i in tag_ids if i in by_id]
|
|
448
541
|
sentences = _sentences(prose)
|
|
449
542
|
if not sentences:
|
|
543
|
+
# Too sparse for `_sentences` to keep at all (fewer than
|
|
544
|
+
# MIN_WORDS_PER_SENTENCE words in the whole unit): still worth one
|
|
545
|
+
# more check before giving up on it, since "(Passage 1)" is
|
|
546
|
+
# exactly this sparse and is legitimate evidence commentary.
|
|
547
|
+
candidate = prose.strip(" .,;:\n\t")
|
|
548
|
+
if _is_evidence_commentary(candidate):
|
|
549
|
+
accept_as_commentary(candidate, tag_ids, cited)
|
|
550
|
+
continue
|
|
450
551
|
total += 1
|
|
451
552
|
stripped += 1 # degenerate: tags with nothing to stand behind
|
|
452
|
-
claims.append(Claim(
|
|
553
|
+
claims.append(Claim(candidate, ClaimStatus.STRIPPED, tuple(tag_ids), ()))
|
|
453
554
|
continue
|
|
454
555
|
|
|
455
556
|
for raw in sentences:
|
|
456
557
|
sentence = _without_chunk_refs(raw)
|
|
558
|
+
if _is_evidence_commentary(sentence):
|
|
559
|
+
accept_as_commentary(sentence.rstrip(".").strip(), tag_ids, cited)
|
|
560
|
+
continue
|
|
457
561
|
if _is_lead_in(sentence) or len(_WORD_RE.findall(sentence)) < MIN_WORDS_PER_SENTENCE:
|
|
458
562
|
continue # not a claim; counts neither for nor against
|
|
459
563
|
total += 1
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: citebound
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: Bind every claim an LLM makes to the passage it cites. Deterministic, dependency-free verification for RAG and agent answers: every number and citation checked against the retrieved context, wrong citations repaired, unsupported sentences stripped, ungroundable answers refused. No model call, no API key.
|
|
5
5
|
License-Expression: Apache-2.0
|
|
6
6
|
Project-URL: Homepage, https://github.com/92kareeem/citebound
|
|
@@ -311,15 +311,15 @@ verification tools publish either figure; the second one is the one that matters
|
|
|
311
311
|
|
|
312
312
|
| Metric | Hand-written, 52 pairs | **Derived from RAGTruth, 134 pairs** |
|
|
313
313
|
|---|---|---|
|
|
314
|
-
| Pair accuracy | 60% (31 of 52) | **
|
|
314
|
+
| Pair accuracy | 60% (31 of 52) | **24% (32 of 134)** |
|
|
315
315
|
| Wrong claims caught | 34 of 51 | 39 of 134 |
|
|
316
|
-
| Right claims dropped | 5 of 53 |
|
|
316
|
+
| Right claims dropped | 5 of 53 | 20 of 134 |
|
|
317
317
|
|
|
318
318
|
The hand-written set mutates one operator or one unit at a time, so it says
|
|
319
319
|
which specific failures the gate can see. The derived set is built from
|
|
320
320
|
[RAGTruth](https://arxiv.org/abs/2401.00396)'s human-labelled hallucination
|
|
321
321
|
spans: every sentence was written by a production model and judged by somebody
|
|
322
|
-
other than us, so it says how much of the real problem that reaches. **Read
|
|
322
|
+
other than us, so it says how much of the real problem that reaches. **Read 24%
|
|
323
323
|
as the share of real hallucinations a deterministic layer catches on its own,
|
|
324
324
|
never as a detection rate.**
|
|
325
325
|
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"""A sentence that admits no answer is available is not a claim to verify.
|
|
2
|
+
|
|
3
|
+
Found on RAGTruth-derived data: 23 of 134 clean sentences were false refusals,
|
|
4
|
+
and some of those were not grounding failures at all - the model honestly
|
|
5
|
+
said it had nothing to add, and the gate punished it for saying so. This is
|
|
6
|
+
the fix, scoped narrowly on purpose: see the rationale in grounding.py's
|
|
7
|
+
module docstring and on ``_is_evidence_commentary`` for why a sentence naming
|
|
8
|
+
a specific absent topic is deliberately excluded. The four control tests
|
|
9
|
+
below are not synthetic - they are the real RAGTruth sentences, reworded with
|
|
10
|
+
stand-in topics, that an earlier and broader version of this pattern wrongly
|
|
11
|
+
accepted.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
from citebound import ClaimStatus, Passage, passages_from_texts, verify
|
|
17
|
+
|
|
18
|
+
REFUNDS = passages_from_texts(["Customers may request a refund within 30 days of purchase."])
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def status(answer: str, passages: list[Passage] = REFUNDS, question: str = "") -> ClaimStatus:
|
|
22
|
+
verdict = verify(answer, passages, question, citation_style="numeric")
|
|
23
|
+
assert verdict.claims, "expected exactly one parsed claim"
|
|
24
|
+
return verdict.claims[0].status
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
# --------------------------------------------------------- accepted outright
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def test_a_blanket_inability_to_answer_is_accepted() -> None:
|
|
31
|
+
assert status("(Unable to answer based on given passages) [1].") is ClaimStatus.SUPPORTED
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def test_inability_to_answer_is_accepted_in_several_wordings() -> None:
|
|
35
|
+
for wording in (
|
|
36
|
+
"I am unable to answer this based on the given passages [1].",
|
|
37
|
+
"I cannot answer this from the provided documents [1].",
|
|
38
|
+
"Not able to answer using the available context [1].",
|
|
39
|
+
):
|
|
40
|
+
assert status(wording) is ClaimStatus.SUPPORTED, wording
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def test_a_bare_pointer_to_citations_is_accepted() -> None:
|
|
44
|
+
for wording in (
|
|
45
|
+
"(Passages 1, 2, and 3) [1].",
|
|
46
|
+
"(Passage 1) [1].",
|
|
47
|
+
"See passages 1 and 2 [1].",
|
|
48
|
+
):
|
|
49
|
+
assert status(wording) is ClaimStatus.SUPPORTED, wording
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def test_generic_insufficiency_with_no_named_topic_is_accepted() -> None:
|
|
53
|
+
answer = (
|
|
54
|
+
"Please note that the provided passages may not have all the necessary "
|
|
55
|
+
"information to answer the question completely [1]."
|
|
56
|
+
)
|
|
57
|
+
assert status(answer) is ClaimStatus.SUPPORTED
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def test_a_sole_bare_citation_answer_is_verified_not_refused() -> None:
|
|
61
|
+
"""Before this fix, a lone meta-sentence emptied every unit and the whole
|
|
62
|
+
answer was refused (total == 0), even though nothing was actually wrong."""
|
|
63
|
+
verdict = verify("(Passages 1, 2, and 3) [1].", REFUNDS, citation_style="numeric")
|
|
64
|
+
assert verdict.ok
|
|
65
|
+
assert verdict.passed
|
|
66
|
+
assert verdict.claims[0].status is ClaimStatus.SUPPORTED
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def test_accepted_sentences_keep_their_original_citation() -> None:
|
|
70
|
+
verdict = verify(
|
|
71
|
+
"Unable to answer from the given passages [1].", REFUNDS, citation_style="numeric"
|
|
72
|
+
)
|
|
73
|
+
assert verdict.cited_ids == ("p1",)
|
|
74
|
+
assert verdict.claims[0].supported_by == ("p1",)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
# --------------------------------------------------- never, even on a match
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def test_a_matching_wording_is_never_accepted_with_a_number_present() -> None:
|
|
81
|
+
"""A figure is the one thing this gate always checks. Meta-language must
|
|
82
|
+
never be a way to smuggle one past verification."""
|
|
83
|
+
answer = "Unable to answer, but the fee is probably around $50 based on given passages [1]."
|
|
84
|
+
assert status(answer) is ClaimStatus.STRIPPED
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
# ----------------------------------- naming a specific topic is NOT accepted
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def test_naming_a_specific_absent_topic_is_not_accepted() -> None:
|
|
91
|
+
"""Reads the same as the accepted wordings, but this one is falsifiable:
|
|
92
|
+
it claims the evidence is silent on a named thing, which this gate cannot
|
|
93
|
+
verify and so must not wave through. (The quoted-in-docs RAGTruth example.)
|
|
94
|
+
"""
|
|
95
|
+
answer = (
|
|
96
|
+
"The passages do not provide detailed instructions on how to start "
|
|
97
|
+
"a paw paw tree from seed [1]."
|
|
98
|
+
)
|
|
99
|
+
assert status(answer) is ClaimStatus.STRIPPED
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def test_four_real_false_denials_are_still_caught() -> None:
|
|
103
|
+
"""RAGTruth's own labelled hallucinations: the model denies the evidence
|
|
104
|
+
covers something it actually does. An earlier, broader version of this
|
|
105
|
+
fix accepted all four unconditionally; each is a precision regression
|
|
106
|
+
this test exists to catch if the pattern is ever widened again. The
|
|
107
|
+
answers and passages are the real, public RAGTruth text, not paraphrased,
|
|
108
|
+
so this test cannot be accidentally defeated by a synthetic passage that
|
|
109
|
+
happens to be worded too conveniently (an earlier draft of this very test
|
|
110
|
+
was).
|
|
111
|
+
"""
|
|
112
|
+
duck = passages_from_texts(
|
|
113
|
+
[
|
|
114
|
+
"1 Roast duck in preheated oven for 1 hour. 2 Spoon 1/4 cup melted"
|
|
115
|
+
" butter over bird, and continue cooking for 45 more minutes.",
|
|
116
|
+
"Directions. Preheat the oven to 400 degrees F. Season the entire duck"
|
|
117
|
+
" breast with Essence.",
|
|
118
|
+
"Heat a cast iron skillet or other oven-safe skillet over medium heat."
|
|
119
|
+
" Place the duck legs in the pan with the skin sides down.",
|
|
120
|
+
]
|
|
121
|
+
)
|
|
122
|
+
qualities = passages_from_texts(
|
|
123
|
+
[
|
|
124
|
+
"If you do good work and you're an effective manager, you shouldn't"
|
|
125
|
+
" worry about dressing up your laurels. People will recognize the"
|
|
126
|
+
" work that you do.",
|
|
127
|
+
"The goal of a good manager is to achieve stellar results through"
|
|
128
|
+
" inspiring, leading, and developing your team. Developing skills to"
|
|
129
|
+
" become a good people manager is not easy.",
|
|
130
|
+
"This is an excellent question to ask as you are getting promoted to"
|
|
131
|
+
" manage others or have already been managing for awhile.",
|
|
132
|
+
]
|
|
133
|
+
)
|
|
134
|
+
components = passages_from_texts(
|
|
135
|
+
[
|
|
136
|
+
"Fuel Pump. The fuel pump has three functions: to deliver enough fuel"
|
|
137
|
+
" to supply the requirements of an engine under all operating"
|
|
138
|
+
" conditions, to maintain enough pressure in the line between the"
|
|
139
|
+
" carburetor.",
|
|
140
|
+
"The fuel sending unit assembly may be a combination of the electric"
|
|
141
|
+
" fuel pump, the filter, the strainer, and the electronic device used"
|
|
142
|
+
" to measure the amount of fuel in the tank via a float.",
|
|
143
|
+
"With the whole unit you will get a new pressure regulator. Its a lot"
|
|
144
|
+
" easier to change out.",
|
|
145
|
+
]
|
|
146
|
+
)
|
|
147
|
+
tuna = passages_from_texts(
|
|
148
|
+
[
|
|
149
|
+
"Salt and pepper to taste. 1 Heat your grill to a surface temperature"
|
|
150
|
+
" of 400 degrees. 2 Rub oil on tuna steaks and season with salt and"
|
|
151
|
+
" pepper.",
|
|
152
|
+
"Pour half of your olive oil on the bottom of the aluminum foil. Chop"
|
|
153
|
+
" up your green pepper into bite-size pieces.",
|
|
154
|
+
"Broil the tuna for 3 minutes per side. After 3 minutes, flip the tuna"
|
|
155
|
+
" steaks over to the other side and return to the broiler for an"
|
|
156
|
+
" additional 3 minutes or until done.",
|
|
157
|
+
]
|
|
158
|
+
)
|
|
159
|
+
cases = [
|
|
160
|
+
(
|
|
161
|
+
"Note: The passages do not specify the size of the duck or the desired"
|
|
162
|
+
" level of doneness, so the cooking time may need to be adjusted"
|
|
163
|
+
" accordingly [1, 2, 3].",
|
|
164
|
+
duck,
|
|
165
|
+
),
|
|
166
|
+
(
|
|
167
|
+
"The passages do not provide specific information on other important"
|
|
168
|
+
" qualities such as adaptability, problem-solving skills,"
|
|
169
|
+
" decision-making abilities, or conflict resolution strategies"
|
|
170
|
+
" [1, 2, 3].",
|
|
171
|
+
qualities,
|
|
172
|
+
),
|
|
173
|
+
(
|
|
174
|
+
"However, it's important to note that the passages don't provide a"
|
|
175
|
+
" clear distinction between the two components, and they seem to be"
|
|
176
|
+
" discussed interchangeably [1, 2, 3].",
|
|
177
|
+
components,
|
|
178
|
+
),
|
|
179
|
+
(
|
|
180
|
+
"Note: The passages do not provide specific cooking times or"
|
|
181
|
+
" temperatures, so it's important to check the tuna frequently during"
|
|
182
|
+
" the broiling process [1, 2, 3].",
|
|
183
|
+
tuna,
|
|
184
|
+
),
|
|
185
|
+
]
|
|
186
|
+
for answer, passages in cases:
|
|
187
|
+
assert status(answer, passages) is ClaimStatus.STRIPPED, answer
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|