File tree Expand file tree Collapse file tree 3 files changed +16
-2
lines changed Expand file tree Collapse file tree 3 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -885,6 +885,7 @@ will return much faster than the first query and we'll be certain the authors ma
885
885
| ` answer.max_concurrent_requests ` | ` 4 ` | Max concurrent requests to LLMs. |
886
886
| ` answer.answer_filter_extra_background ` | ` False ` | Whether to cite background info from model. |
887
887
| ` answer.get_evidence_if_no_contexts ` | ` True ` | Allow lazy evidence gathering. |
888
+ | ` answer.evidence_relevance_score_cutoff ` | ` 1 ` | Cutoff evidence relevance score to include in the answer context (inclusive) |
888
889
| ` parsing.chunk_size ` | ` 5000 ` | Characters per chunk (0 for no chunking). |
889
890
| ` parsing.page_size_limit ` | ` 1,280,000 ` | Character limit per page. |
890
891
| ` parsing.pdfs_use_block_parsing ` | ` False ` | Opt-in flag for block-based PDF parsing over text-based PDF parsing. |
Original file line number Diff line number Diff line change @@ -768,8 +768,12 @@ async def aquery( # noqa: PLR0912
768
768
contexts ,
769
769
key = lambda x : (- x .score , x .text .name ),
770
770
)[: answer_config .answer_max_sources ]
771
- # remove any contexts with a score of 0
772
- filtered_contexts = [c for c in filtered_contexts if c .score > 0 ]
771
+ # remove any contexts with a score below the cutoff
772
+ filtered_contexts = [
773
+ c
774
+ for c in filtered_contexts
775
+ if c .score >= answer_config .evidence_relevance_score_cutoff
776
+ ]
773
777
774
778
# shim deprecated flag
775
779
# TODO: remove in v6
Original file line number Diff line number Diff line change @@ -77,6 +77,15 @@ class AnswerSettings(BaseModel):
77
77
default = True ,
78
78
description = "Whether to use retrieval instead of processing all docs." ,
79
79
)
80
+ # no validator because you can set the range in a prompt
81
+ evidence_relevance_score_cutoff : int = Field (
82
+ default = 1 ,
83
+ ge = 0 ,
84
+ description = (
85
+ "Relevance score cutoff for evidence retrieval, default is 1, meaning"
86
+ " only evidence with relevance score >= 1 will be used."
87
+ ),
88
+ )
80
89
evidence_summary_length : str = Field (
81
90
default = "about 100 words" , description = "Length of evidence summary."
82
91
)
You can’t perform that action at this time.
0 commit comments