-
Couldn't load subscription status.
- Fork 779
Deduplicating media on Context creation
#1153
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
Conversation
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.
Pull Request Overview
This PR implements media deduplication for Context creation to avoid passing duplicate images to the LLM. It introduces an info_hash field in ParsedMedia to enable deduplication based on rounded bounding boxes while preserving high-resolution metadata, and applies ordered set-based deduplication when creating context prompts.
Key changes:
- Added
info_hashtoParsedMediafor flexible deduplication without affecting stored metadata - Applied deduplication to media lists during context creation in
_map_fxn_summary - Created test PDF with duplicate media to validate deduplication behavior
Reviewed Changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/paperqa/types.py | Added _get_info_hash() method to support deduplication via optional info_hash key |
| src/paperqa/core.py | Implemented ordered set deduplication for media during context creation |
| packages/paper-qa-docling/src/paperqa_docling/reader.py | Added info_hash generation with rounded bounding boxes for pictures and tables |
| tests/test_paperqa.py | Added test to verify media deduplication during context creation |
| packages/paper-qa-docling/tests/test_paperqa_docling.py | Added test to verify ParsedMedia deduplication behavior |
| tests/duplicate_media_template.md | Template for generating test PDF with duplicate images |
| src/paperqa/prompts.py | Removed redundant separator between text and tables |
| tests/test_agents.py | Updated expected file counts to include new test PDF |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Documentation Updates 1 document(s) were updated by changes in this PR |
1d66dd7 to
5299143
Compare
ef669d6 to
4e954cc
Compare
This reverts commit 6c628c033bfec8ca64e36887b3ed6004e11b609d.
4e954cc to
7b4e1f5
Compare
I realized we were passing the same images for
Contextcreation. This PR:info_hashtoParsedMediato allow for loosened deduplication without affecting stored infoContextcreation promptThis PR also makes a custom PDF for testing deduplication capabilities within multimodal PaperQA.