Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,22 @@ The model can output predictions in two formats:
}]
```

Use `min_confidence` with span output to drop predictions below a threshold:

```python
detector.predict(
context=contexts,
question=question,
answer=answer,
output_format="spans",
min_confidence=0.8,
)
```

For transformer detectors, emitted hallucination spans already have
confidence values of at least `0.5`, so thresholds below `0.5` are no-ops;
higher thresholds raise that floor.

### Token Format
```python
[{
Expand Down
2 changes: 2 additions & 0 deletions lettucedetect/detectors/rag_fact_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ def predict(
:param question: Question (optional)
:param output_format: "tokens", "spans", or "detailed"
:param min_confidence: Drop ``"spans"`` below this confidence threshold (``[0, 1]``).
Does not filter ``output_format="detailed"``; detailed output returns
the unfiltered spans, triplets, and fact-check results.
:param kwargs: Additional arguments

:return: List of predictions in lettuceDetect format, or dict for detailed format
Expand Down