Repository navigation
fix(search): lower semantic-only trigram grounding floor to 0.3 - #165
Merged
Merged
Conversation
The lexical-grounding anchor (a pure-semantic hit must share a trigram word_similarity >= threshold with the query) vetoed relevant docs whose vocabulary differs from the query's surface words. Concretely, the query "identificar tipos de flores a partir de sus medidas" cleared the 0.84 semantic floor against "Estadística Bayesiana Aplicada - Penguins y Iris" (max cosine 0.8694) but was dropped because its peak trigram score was 0.322, just under the 0.40 floor — the doc never uses the word "medidas". Lower the prod-effective sources (startup.sh-generated .env, plus the .env.example doc and compose default) to 0.3, aligning with the existing fuzzy floor and leaving margin. A corpus check for that query at 0.3 admits only the target doc plus the pre-existing lexical hit, no flood. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
MarcosACH
approved these changes
Jun 22, 2026
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.
Why
The lexical-grounding anchor (SPEC §Ranking) requires a pure-semantic hit to share a trigram
word_similarity≥ threshold with the query. This vetoed genuinely relevant docs whose vocabulary differs from the query's surface words.Concrete case (investigated live in prod): the query "identificar tipos de flores a partir de sus medidas" cleared the 0.84 semantic floor against "Estadística Bayesiana Aplicada - Penguins y Iris" (max cosine 0.8694) but was dropped because its peak trigram score was 0.322, just under the 0.40 floor — the document never uses the word "medidas" (it says masa/tamaño corporal). Meanwhile the project's own "BUSCASAM" doc, which quotes the example query verbatim, was the sole result via lexical match.
Change
Lower the prod-effective sources to 0.3:
infra/terraform/modules/app-vm/startup.sh(the line that writes the live.env)infra/.env.example(doc)infra/compose.yaml(default)0.3 aligns with the existing fuzzy floor (
FUZZY_WORD_SIMILARITY_THRESHOLD=0.3) and leaves margin over 0.322. A corpus check for that query at 0.3 admits only the target doc plus the pre-existing lexical hit — no flood.Deploy status
buscasam-appvia.envedit +apicontainer recreate; verifiedGET /api/searchnow returns the Iris doc.terraform applyrun to persist the value into instance startup-script metadata (in-place metadata update,0 to add, 1 to change, 0 to destroy— no VM reboot/recreate), so a future reboot won't revert to 0.4.backend/src/buscasam/settings.py:61is intentionally left at0.4(affects only dev/tests; changing it would shift the committed relevance-fixture sweep). Separate calibration if repo/prod defaults should align.🤖 Generated with Claude Code