Fix prep_docs not assigning auto-generated doc_ids to Document inputs#81
Open
lntutor wants to merge 1 commit into
Open
Fix prep_docs not assigning auto-generated doc_ids to Document inputs#81lntutor wants to merge 1 commit into
lntutor wants to merge 1 commit into
Conversation
When a list of Document objects with no doc_id is passed, prep_docs detects the None ids, prints that it is reverting to auto-generated integer ids, and computes list(range(len(docs))) -- but never writes them back onto the documents. So every returned Document keeps doc_id=None, and since the same Document object is placed into each Result, all results end up with doc_id=None: get_score_by_docid(None) matches the first result for any query and no integer id resolves. The string-input path already assigns the ids correctly; this makes the Document-input path consistent. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N6RtoHuxrDqTUo9Mw9h4Cv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's broken
When
prep_docsreceives a list ofDocumentobjects whosedoc_idisNone, it detects this, prints that it's reverting to auto-generated integer ids, and computeslist(range(len(docs)))— but then throws that list away:So every returned
Documentkeepsdoc_id=None:Since the same
Documentobject is placed into eachResult(e.g.transformer_ranker.py), all results end up withdoc_id=None, soRankedResults.get_score_by_docid(None)matches the first result for any query and no integer id resolves. The string-input path a few lines below already assignslist(range(len(docs)))correctly, so the two entry paths are inconsistent.Fix
Write the generated ids back onto the documents, matching the string-input path.
Tests
Adds
test_prep_docs_document_input_autogenerates_idstotests/test_results.py. Full file passes (4).