retune
Rebuild and re-optimize the llmwiki vault's retrieval pipeline (corpus index + AutoRAG hybrid trial). Use when the user says /retune, after any /ingest adds pages, when `llmwiki ask` can't retrieve a
SKILL.md.claude/skills/retune/SKILL.md
GitHubRetune the llmwiki retrieval pipeline
CLI: llmwiki (vault /mnt/c/Users/emmaj/llmwiki, engines in .rag/). Retuning = llmwiki index (rebuild corpus parquet from vault markdown) then llmwiki tune (AutoRAG trial: BM25 + vector + hybrid-RRF race, scored on auto-generated QA, winner deployed).
When to call
- After /ingest lands new pages — until then they are
search-visible butask-invisible (ask retrieves from trial-time indexes). - Staleness tell:
llmwiki search Xfinds a page butllmwiki askabout it refuses — that's the signature; retune, don't debug retrieval. - After changing
.rag/config.yaml(nodes, prompt, models). - NOT after mere page edits to already-indexed topics — BM25/embeddings tolerate content drift; batch retunes instead.
Procedure
llmwiki index— seconds; prints page count. Extra roots:llmwiki index wiki Clippings.- Corpus grew a lot or QA set should refresh? Delete
.rag/data/qa.parquetfirst — tune reuses an existing QA set otherwise. llmwiki tune— run backgrounded, 10–40 min on the 3090 (QA gen if needed + embed corpus + trial). Tell the user it's running.- On completion, sanity-check the leaderboard: read
.rag/data/project/<latest>/*/*/summary.csv— expect hybrid ≥ BM25 ≥ vector on retrieval_recall, ROUGE ≈ 0.6. A collapsed metric (0.0) means a broken stage, not a bad corpus. - Verify end-to-end with one
llmwiki askabout a recently added page.
Known failure modes (all hit in practice, all guarded — do not re-diagnose from scratch)
- QA gen crashes on batch 2 (
Event ... bound to a different event loop): AutoRAG's legacy QA creator opens a new loop per cache batch while the Ollama client stays bound to the first. Guard:cache_batch≥content_sizein.rag/engines/tune.py. If it recurs, that guard was lowered. doc_id ... not found in corpus_datafrom ask after tune: stale project-level corpus copy.tune.pydeletesdata/project/data/{corpus,qa}.parquetbefore each trial for exactly this; if seen, the deletion was removed.ollama is not a valid llm name: this AutoRAG build needsautorag.generator_models["ollama"] = Ollamaregistered before Evaluator/Runner — present in bothtune.pyandautorag_ask.py.node ... is not supported: this build useslexical_retrieval/semantic_retrieval/hybrid_retrievalnode types (docs still show the retiredretrieval).- Trials accumulate as
data/project/0,1,2…;askuses the highest. Old trials are safe to delete except the newest.