-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mismatch issue of Documents shown and Citation number in text fix #3421
Conversation
When document order presented to LLM differs from order shown to user, wrong doc numbers are cited. Fix: - SearchTool.get_search_result returns now final and initial ranking - initial ranking is passed through a few objects and used for replacement in citation processing Notes: - the citation_num in the CitationInfo() object has not been changed.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Updated: - test_citation_substitution (changed description) - test_citation_processing (removed data only relevant for the substitution)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code best practices
self, context_docs: list[LlmDoc], doc_id_to_rank_map: DocumentIdOrderMapping | ||
self, | ||
context_docs: list[LlmDoc], | ||
doc_id_to_rank_map: DocumentIdOrderMapping, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer putting the display_doc_order_list within the DocumentIdOrderMapping
@@ -224,6 +226,7 @@ def _get_response(self, llm_calls: list[LLMCall]) -> AnswerStream: | |||
answer_handler = CitationResponseHandler( | |||
context_docs=search_result, | |||
doc_id_to_rank_map=map_document_id_order(search_result), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would create the single object with both in this function here, so above we can do processed_search_result, displayed_search_results
search_result = SearchTool.get_search_result(current_llm_call) or [] | ||
search_result, displayed_search_results_map = SearchTool.get_search_result( | ||
current_llm_call | ||
) or ([], {}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pref ([], []) for consistency and building the ordering in the call below similar to the other object. For reducing complexity for future readers
@@ -22,12 +22,16 @@ def __init__( | |||
self, | |||
context_docs: list[LlmDoc], | |||
doc_id_to_rank_map: DocumentIdOrderMapping, | |||
display_doc_order_dict: dict[str, int], | |||
stop_stream: str | None = STOP_STREAM_PAT, | |||
): | |||
self.context_docs = context_docs | |||
self.doc_id_to_rank_map = doc_id_to_rank_map | |||
self.stop_stream = stop_stream | |||
self.order_mapping = doc_id_to_rank_map.order_mapping |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This attribute would contain both that way we have a single cohesive "state object" we can pass to the function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!!!!!!! @yuhongsun96 fault if anything goes wrong
…yx-dot-app#3421) * Mismatch issue of Documents shown and Citation number in text fix When document order presented to LLM differs from order shown to user, wrong doc numbers are cited. Fix: - SearchTool.get_search_result returns now final and initial ranking - initial ranking is passed through a few objects and used for replacement in citation processing Notes: - the citation_num in the CitationInfo() object has not been changed. * PR fixes - linting - removed erroneous tab - added a substitution test case - adjusted original citation extraction use case * Included a key test and * Fixed extra spaces * Updated test documentation Updated: - test_citation_substitution (changed description) - test_citation_processing (removed data only relevant for the substitution)
When document order presented to LLM differs from order shown to user, wrong doc numbers are cited.
Fix:
Notes:
Description
[Provide a brief description of the changes in this PR]
How Has This Been Tested?
[Describe the tests you ran to verify your changes]
Accepted Risk (provide if relevant)
N/A
Related Issue(s) (provide if relevant)
N/A
Mental Checklist:
Backporting (check the box to trigger backport action)
Note: You have to check that the action passes, otherwise resolve the conflicts manually and tag the patches.