feat: add EmbeddingsFilter contextual compression to HybridRetriever … - #133
bhavyakeerthi3 wants to merge 1 commit into
Conversation
|
Still open deliberately, and queued rather than ignored — sorry it has been quiet for six months. This PR changes what reaches the LLM, and this repository's constitution requires a before-and-after measurement on real questions for exactly that kind of change. "This should be better" is explicitly not a finding here, because retrieval quality has no right answer, only "did this move". The reason there has been no verdict is that the tool which produces that measurement was not trustworthy. #211 fixes that last part. Once it lands, this PR gets a real answer: the golden questions, before and after, with the noise floor reported, and the result is a number rather than an opinion. Two things that will need doing first, so they are not a surprise:
Nothing is needed from you right now. Thank you for the contribution, and for your patience with the delay. |
|
Measured before reviewing, and the result settles it: at Run against the current bundle ( Merged as written, every question would reach the LLM with no context whatsoever. For comparison, 0.5 keeps 32% and 0.3 keeps 50% — and even 0.3 caps at 20 per question, because The number isn't wrong through carelessness; it's wrong because a cosine threshold is not portable. 0.76 was presumably reasonable against whatever model and bundle it was tuned on.
What was right here, and has already landedThe other half of this PR — The problem you were solving is realBeta transcripts from this week show exactly the noise you were targeting: a question about analysis tools retrieved estrogen-responsive gene expression and RAB GTPase trafficking, and the model wrote a confident answer around them. That is worth fixing. What it needs is a threshold derived from this corpus rather than carried in — or a mechanism that doesn't have a magic number, which is the open question in Also worth knowing before reworking: Closing because it cannot land in this form, not because the idea is wrong. Thank you for it, and sorry it took six months to get a real answer. |
🐛Summary
Closes #132
Wraps the HybridRetriever with a
ContextualCompressionRetrieverusingLangChain's
EmbeddingsFilterto discard low-relevance documents beforethey reach the LLM.
Changes
EmbeddingsFiltercompressor withsimilarity_threshold=0.76ContextualCompressionRetrieverImpact