rnel.text
¶
Zero-shot RNEL from text (requires transformers): each piece of evidence is read by an NLI model.
Every (evidence, claim) pair gives an SL opinion b = p(entailment), d = p(contradiction), u = p(neutral). The pieces are then combined into RNEL reports and read with Definition 8.4: T, F and G from the fused evidence, C from the largest pairwise conflict between pieces. No training is involved; for a trained reader see rnel.nn.
DEFAULT_MODEL = 'cross-encoder/nli-deberta-v3-base'
module-attribute
¶
PieceReading
dataclass
¶
NLIReader
¶
Source code in src/rnel/text.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
tok = AutoTokenizer.from_pretrained(model)
instance-attribute
¶
model = AutoModelForSequenceClassification.from_pretrained(model).eval()
instance-attribute
¶
idx = (labels['entailment'], labels['contradiction'], labels['neutral'])
instance-attribute
¶
read(claim, evidence)
¶
Source code in src/rnel/text.py
34 35 36 37 38 39 40 41 | |
reports_from_reading(r, weight=5.0)
¶
One piece as weight units of evidence split by the NLI probabilities.
Neutral mass adds no evidence (the text does not bear on the claim), so it shows up as ignorance G. NLI gives no signal for "neither" (ill-posed claim) or "undetermined"; those need typed data (rnel.nn).
Source code in src/rnel/text.py
44 45 46 47 48 49 50 | |
rnel_from_text(reader, claim, evidence, weight=5.0, W=DEFAULT_W)
¶
Source code in src/rnel/text.py
53 54 55 56 57 | |
sl_from_text(readings, weight=5.0, W=DEFAULT_W)
¶
The SL cumulative-fusion opinion of the same pieces, for comparison.
Source code in src/rnel/text.py
60 61 62 63 64 | |