fix(retrieval): embed queries and documents with the right cohere input types #17
All Vouch review confidence checks passed
Residual risk 0.34 = Change Risk (0.39) × (1 − Review Confidence (0.13)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 264 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 13% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.334
Real PR Conversation Timeline
1 comments
"Review active on #17"
general
weight: 0.35
copilot-pull-request-reviewer[bot]
Summary
Questions were embedded as if they were documents. This PR gives each side its own Cohere
input_type, adds retries, and adds a local embedding provider so the engine runs without API keys.Closes #3
Changes
embedding_provider.embed()sentCOHERE_EMBEDDING_INPUT_TYPE(defaultsearch_document) for both passages and questions. Cohere v3 is trained asymmetrically, so retrieval quality dropped with no error anywhere. The setting is removed.EmbeddingProviderprotocol (app/providers/embeddings.py):embed_documents()for ingestion,embed_query()for questions, plusnameanddim.CohereEmbeddings:search_document/search_query, batches of 96 (API limit),truncate=ENDinstead ofNONE(a long chunk no longer fails the whole document).post_with_retries(app/providers/http.py): honorsRetry-After, exponential backoff on 429/5xx and network errors, at most 4 attempts, fails fast on other 4xx. The provider response is logged and never returned.LocalEmbeddings:fastembed(ONNX on the CPU) withparaphrase-multilingual-MiniLM-L12-v2, 384 dims, selected withEMBEDDING_PROVIDER=local. Optional extra:uv sync --extra local.How to test
test_local_model_is_multilingualdownloads the model once (about 220 MB) and checks that a Spanish question is closer to the English passage that answers it than to an unrelated one.Results
Quality numbers for both providers come with the benchmark (#10); this PR fixes the input type and makes that benchmark possible without keys.
Checklist
<type>/<issue>-<short-description>and the PR title is a Conventional Commitruff check,ruff format --check,mypyandpytestpass locally🤖 Generated with Claude Code