Skip to content

feat: LongMemEval-S benchmark (R@5=98.00%) + chunk embedding fixes (v0.2.1) - #6

Merged
sachinsharma9780 merged 17 commits into
mainfrom
feature/benchmark-and-chunk-fix
May 9, 2026
Merged

sachinsharma9780 merged 17 commits into
mainfrom
feature/benchmark-and-chunk-fix

Conversation

@sachinsharma9780

Copy link
Copy Markdown
Owner

Summary

Core library fixes (v0.2.1)

  • Oversized chunk handling (store.py): when a batch embedding call fails
    (e.g. a chunk exceeds the model's context limit), the pipeline now retries
    each chunk individually. Chunks that are still too large are split
    recursively at a word boundary near the midpoint — both halves are embedded
    and their vectors are averaged + L2-normalised (_embed_with_halving).
    Previously the entire file's batch was silently dropped.

  • HTTP 400 non-retryable fix (embedding/provider.py): LiteLLM's
    APIConnectionError misreports Ollama HTTP 400 errors as status_code=500,
    causing 3 redundant retries (~5 s overhead) per oversized chunk. Now parses
    the status from the exception message string first so 4xx errors are
    immediately classified as non-retryable.

  • _upsert_vec log level (store.py): sqlite-vec INSERT failures promoted
    from DEBUG → WARNING so silent vector drops surface immediately.

LongMemEval-S benchmark

Evaluates memweave on 500-question multi-session memory retrieval using the
ECR + IDF + CAATB post-processor pipeline. All runs are fully local —
all-MiniLM-L6-v2 via Ollama, no LLM, no API key, no cloud.

Results (held-out, 450 questions): R@5 = 98.00%, R@23 = 100%
Cross-validated (5 seeds): R@5 = 97.24% ± 0.12%

Adds:

  • benchmarks/strategies/ — ECR, IDF, CAATB post-processors
  • benchmarks/longmemeval_bench.py — fixed-split benchmark runner (with full docstrings)
  • benchmarks/multiseed_sweep.py — 5-seed cross-validated runner
  • benchmarks/data/ — canonical split + 5 stratified CV seeds
  • benchmarks/final_results/ — JSONL/JSON result artifacts
  • README benchmark section with mempalace comparison

Adds benchmark infrastructure and first published dev-split result for
memweave on LongMemEval (50 dev questions, all-MiniLM-L6-v2, raw vector
mode, seed=42 split shared with mempalace baseline).

- benchmarks/BENCHMARK_PLAN.md    — milestone plan with integrity rules
- benchmarks/longmemeval_bench.py — per-question isolation, JSONL output,
                                    Recall@K/NDCG@K metrics, raw/hybrid/
                                    hybrid_mmr modes
- benchmarks/verify_milestone1.py — preflight checks (Ollama, dataset, split)
- benchmarks/results/results_mw_raw_dev_20260501_1727.jsonl
                                  — dev result: R@5=0.9400, NDCG@5=0.8807
                                    (mempalace raw baseline: 96.6% on 500 Qs)
…ving

When a batch embedding call fails (e.g. one chunk exceeds the model's
256-token context limit), fall back to per-chunk embedding instead of
dropping all chunks in the file. Oversized individual chunks are split
at a word boundary near the midpoint, both halves are embedded, and
the vectors are averaged + L2-normalised (_embed_with_halving).
Also promotes _upsert_vec log level DEBUG → WARNING so sqlite-vec
INSERT failures surface immediately.
LiteLLM's APIConnectionError misreports Ollama HTTP 400 errors as
status_code=500 (retryable), causing 3 redundant retries (~5s) per
oversized chunk. Parse the status from the exception message string
first (httpx format: "Client error '4XX'") before falling back to
the status_code attribute.
- lme_split_50_450.json: canonical fixed split (50 dev / 450 held-out)
- splits/lme_stratified_split_seed{42,0,1,2,3}.json: five stratified
  50/450 splits with largest-remainder rounding to preserve question-type
  proportions, used for the 5-seed cross-validated benchmark run
@codecov-commenter

codecov-commenter commented May 9, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 25.00000% with 27 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.70%. Comparing base (4448233) to head (e05f037).
⚠️ Report is 18 commits behind head on main.

Files with missing lines Patch % Lines
memweave/store.py 7.14% 26 Missing ⚠️
memweave/embedding/provider.py 87.50% 1 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##             main       #6      +/-   ##
==========================================
- Coverage   89.74%   88.70%   -1.05%     
==========================================
  Files          26       26              
  Lines        1863     1894      +31     
==========================================
+ Hits         1672     1680       +8     
- Misses        191      214      +23     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sachinsharma9780
sachinsharma9780 merged commit bdab17d into main May 9, 2026
1 check passed
@sachinsharma9780
sachinsharma9780 deleted the feature/benchmark-and-chunk-fix branch May 9, 2026 11:17
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.

2 participants