Skip to content

fix: cosine distance space and boundary-aware paragraph overlap - #41

Merged
n0nuser merged 2 commits into
mainfrom
feat/rag-chunk-overlap-cosine-fixes
Jul 6, 2026
Merged

fix: cosine distance space and boundary-aware paragraph overlap#41
n0nuser merged 2 commits into
mainfrom
feat/rag-chunk-overlap-cosine-fixes

Conversation

@n0nuser

@n0nuser n0nuser commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • Chroma collection now created with hnsw:space=cosine, matching the cosine-similarity objective embedding models are trained against (existing deployments need a delete + re-ingest to pick this up; documented in docs/rag-retrieval.md).
  • _split_long_paragraph in the structural chunker no longer raw-slices oversized paragraphs with zero overlap: it now reuses chunk_overlap_chars and snaps split points to sentence/word boundaries, falling back to a raw slice only when no boundary exists in range.

Prompted by comparing the current RAG pipeline against the Claude RAG course notes — retrieval/hybrid-fusion side already matched or exceeded the course; these two gaps were the concrete deltas found in chunking/vector-store correctness.

Test plan

  • uv run pytest -q (95 passed, 9 skipped)
  • uv run ruff check .
  • uv run mypy localrag (pre-existing untyped-lib warnings only, unrelated to this change)

n0nuser added 2 commits July 6, 2026 23:11
…aragraphs

Chroma collection now created with hnsw:space=cosine to match embedding
models' cosine training objective (existing collections need delete +
re-ingest to pick this up). _split_long_paragraph in the structural
chunker previously raw-sliced oversized paragraphs with zero overlap
and no boundary awareness; it now reuses chunk_overlap_chars and snaps
splits to sentence/word boundaries, falling back to raw slice only
when no boundary is found.
@n0nuser
n0nuser merged commit 224f4d7 into main Jul 6, 2026
8 checks passed
@n0nuser
n0nuser deleted the feat/rag-chunk-overlap-cosine-fixes branch July 6, 2026 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant