Show retrieved but non-evidence docs. Support language changing
This commit is contained in:
parent
50b5d936f5
commit
cbe40fac99
|
@ -255,8 +255,10 @@ class FullQAPipeline(BaseComponent):
|
||||||
|
|
||||||
id2docs = {doc.doc_id: doc for doc in docs}
|
id2docs = {doc.doc_id: doc for doc in docs}
|
||||||
lack_evidence = True
|
lack_evidence = True
|
||||||
|
not_detected = set(id2docs.keys()) - set(spans.keys())
|
||||||
for id, ss in spans.items():
|
for id, ss in spans.items():
|
||||||
if not ss:
|
if not ss:
|
||||||
|
not_detected.add(id)
|
||||||
continue
|
continue
|
||||||
ss = sorted(ss, key=lambda x: x["start"])
|
ss = sorted(ss, key=lambda x: x["start"])
|
||||||
text = id2docs[id].text[: ss[0]["start"]]
|
text = id2docs[id].text[: ss[0]["start"]]
|
||||||
|
@ -280,7 +282,23 @@ class FullQAPipeline(BaseComponent):
|
||||||
lack_evidence = False
|
lack_evidence = False
|
||||||
|
|
||||||
if lack_evidence:
|
if lack_evidence:
|
||||||
self.report_output({"evidence": "No evidence found"})
|
self.report_output({"evidence": "No evidence found.\n"})
|
||||||
|
|
||||||
|
if not_detected:
|
||||||
|
self.report_output(
|
||||||
|
{"evidence": "Retrieved docs without matching evidence:\n"}
|
||||||
|
)
|
||||||
|
for id in list(not_detected):
|
||||||
|
self.report_output(
|
||||||
|
{
|
||||||
|
"evidence": (
|
||||||
|
"<details>"
|
||||||
|
f"<summary>{id2docs[id].metadata['file_name']}</summary>"
|
||||||
|
f"{id2docs[id].text}"
|
||||||
|
"</details><br>"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
self.report_output(None)
|
self.report_output(None)
|
||||||
return answer
|
return answer
|
||||||
|
@ -295,6 +313,9 @@ class FullQAPipeline(BaseComponent):
|
||||||
"""
|
"""
|
||||||
pipeline = FullQAPipeline(retrievers=retrievers)
|
pipeline = FullQAPipeline(retrievers=retrievers)
|
||||||
pipeline.answering_pipeline.llm = llms.get_highest_accuracy()
|
pipeline.answering_pipeline.llm = llms.get_highest_accuracy()
|
||||||
|
pipeline.answering_pipeline.lang = {"en": "English", "ja": "Japanese"}.get(
|
||||||
|
settings["reasoning.lang"], "English"
|
||||||
|
)
|
||||||
return pipeline
|
return pipeline
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
Loading…
Reference in New Issue
Block a user