fix(rag): drop unnecessary sentence-transformers hard dependency#1979
Conversation
RAG embeds via Lemonade, but RAGSDK._check_dependencies() required sentence-transformers to import — a heavy, fragile dep (torch/torchcodec) it never uses. On any box where sentence-transformers failed to import (e.g. broken torchcodec/FFmpeg native libs), every RAG indexing call produced 0 chunks even though the Lemonade EmbeddingGemma embedder was loaded and ready. Remove the import and the requirement, stop eagerly importing it at UI-server boot, and drop it from the "rag" extra (kept in "ui" for the optional memory cross-encoder reranker, which already degrades gracefully). Closes the test gap that let this through: the dependency-guard test encoded the wrong behavior (required ST), and the Test RAG workflow never ran tests/unit/rag/. Adds a regression guard (RAG must init with ST absent/broken) and wires tests/unit/rag/ into CI. Also fixes a pre-existing env-dependent pptx table test (forces the pure-python markdown path deterministically).
|
Verdict: Approve with suggestions — safe to merge; the two items below are optional cleanups, not blockers. This PR removes Nothing blocking. Two small leftovers from the removal are worth tidying while you're here. 🔍 Technical detailsVerified claims
🟢 Minor — stale hint in the broken-dep error message ( 🟢 Minor — single-element loop reads as leftover scaffolding ( Strengths
|
…-transformers-dep
Address PR review: flatten the now single-element broken-dependency loop to a plain faiss block, and correct the broken-load hint — the torchcodec/FFmpeg example only ever applied to the removed sentence-transformers, so it now points users at the wrong cause; faiss (arch mismatch) is the only remaining candidate.
|
Addressed both suggestions in 8cf2752:
Also merged latest |
Why this matters
RAG embeds through Lemonade, yet the RAG SDK hard-required
sentence-transformersto import — a heavy, fragile dependency (torch/torchcodec) it never actually uses. On any machine wheresentence-transformersfailed to import (e.g. brokentorchcodec/FFmpeg native libs), every RAG document-indexing call silently produced 0 chunks even though the Lemonade EmbeddingGemma embedder was loaded and ready — a hard-to-diagnose "RAG returns nothing" failure. After this change, RAG initializes and indexes normally regardless ofsentence-transformershealth; the library is now only what it should be — an optional dependency of the memory cross-encoder reranker (which already degrades gracefully).This also closes the test gap that let it through: the RAG dependency-guard test previously encoded the wrong behavior (it required
sentence-transformers), and the Test RAG CI workflow didn't runtests/unit/rag/at all — so nothing exercised the guard.Test plan
pytest tests/test_rag.py tests/unit/rag/— green (115 tests; previously 28 errors from obsolete ST mocks)sentence-transformersforcibly unavailable (tests/unit/rag/test_dependency_guard.py)black --check/flake8clean on changed filestests/unit/rag/(path filter + test command updated)Notes
test_pptx_extraction.py::test_table_extractionwas env-dependent (failed when LibreOffice was installed, since the PPTX→PDF path flattens tables); it now forces the pure-python markdown path so the assertion is deterministic.