Repository navigation
Fix(rag) retrievers persistence signature - #1047
Open
sofiachavezb wants to merge 10 commits into
Open
sofiachavezb wants to merge 10 commits into
sofiachavezb wants to merge 10 commits into
Conversation
Add NON_PERSISTENT_PARAMS to the retriever classes and a persistence signature that drops them, recursively, from a configuration. Query-time knobs such as top_k, the similarity metric, the retrieve-then-expand options or a composite's merge strategy no longer take part in the identity of a fitted retriever.
…e signature Setup, cleanup and index status now compare retrievers by their persistence signature instead of ad-hoc stripping of top_k and the similarity function. Tuning a query-time parameter, at any nesting level, keeps the fitted state instead of deleting or re-indexing it. CleanupService receives the component registry to resolve nested component classes.
…ration Preset matching now ignores only top_k, at every level of the config, so changing the similarity metric, the expansion options or batch_size shows the session as an advanced configuration. Legacy sessions without the expansion fields are compared strictly and may become advanced. batch_size is declared as a non-persistent parameter of the text embedding converters, and the embedding model row is keyed by its persistence signature, so changing it no longer creates a new embedding model and re-embeds every document.
Add configs_equal: deep, key-order independent, type strict (a boolean never equals a number, null is not absent), no subsets, explicit ignored keys. Preset matching, the index status and the session parameter history use it. Chunking presets now match exactly.
…lity Replace the JSON.stringify comparisons with deepEqual, ignore only top_k when matching retriever presets, and throw on a missing or malformed reference. Shares its test cases with the backend.
device joins batch_size as a non-persistent parameter of text embedding converters, so changing it neither reindexes nor creates another embedding model row.
After a successful index job, delete the chunk sets, retriever rows, embedding models, matrices and sparse folders no session uses, walking the retriever tree from parents to children. Chat turns clean only when the index footprint changed. Storage directory names move to storage_layout.
# Conflicts: # DashAI/back/job/RAG_index_job.py # DashAI/back/services/RAG/cleanup_service.py # DashAI/back/services/RAG/session_configuration_service.py # DashAI/front/src/components/generative/RAG/RAGConfigPanel.test.jsx # DashAI/front/src/pages/generative/RAGSession/advanced/CompositeRetrieverBuilder.jsx # DashAI/front/src/pages/generative/RAGSession/advanced/QueryTransformationAdvancedModal.jsx # tests/back/RAG/test_cleanup_session_scope.py
Base automatically changed from
fix(RAG)-similarity-metric-as-component
to
develop
November 27, 2026 14:06
The startup backfill that translates retrievers stored by v0.11.0 completes every level of a composite with its schema defaults, so converted hybrid sessions store enable_retrieve_then_expand and expand_window in each child. The hybrid preset was completed only at the top level, and with the strict preset match every upgraded hybrid session showed as a custom configuration. The preset now completes its children too; new sessions still round-trip.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Changing a retriever's distance metric (or its Top K) reindexed every document. Each retriever now declares which parameters only act at query time (
NON_PERSISTENT_PARAMS). The identity under which a retriever is stored, looked up and cleaned up uses only the remaining parameters, resolved recursively through nested components. Top K, the similarity metric, the expansion options,batch_sizeanddeviceno longer force a reindex, while the embedding pooling or the TFIDF/BM25 vectorizer still do.Also:
Type of Change
Changes (by file)
Persistence signature
models/RAG/retrievers/persistence_signature.py(new):persistence_signatureandreference_signature. They drop the query-time parameters and recurse into{component, params}references andchildrenlists. They raise if a nested component is not registered.models/RAG/retrievers/base_retriever.py:NON_PERSISTENT_PARAMSon the base class and on each retriever (dense, BM25, TFIDF, composites).converters/hugging_face/text_embedding/base.py:batch_sizeanddeviceare non-persistent.retriever_setup_service.py,index_status_service.py: the identity, the sparse folder and therag_embedding_modelrow are computed from the signature.Cleanup after reindexing
services/RAG/cleanup_service.py:cleanup_after_reindexandrun_post_index_cleanup. They release retriever trees from parents to children (at any depth), plus the matrices, embedding models and chunk sets that no live row references. It also integrates develop's reranker cleanup and shared-bridge protection.job/RAG_index_job.py: cleans up after a successful index and releases the index in afinally.job/RAG_job.py: a chat turn cleans up only when the session's index changed. Composites are no longer rebuilt on every turn.services/RAG/storage_layout.py(new): storage directory names, previously repeated literals.services/RAG/session_params.py(new): parameter filter shared by both jobs.Configuration equality and presets
services/RAG/config_equality.pyandfront/.../RAG/configEquality.js(new): deep structural equality that ignores key order, allows no subsets and is type-strict (a boolean never equals a number,nullis not absent). Both run the shared cases intests/shared/config_equality_cases.json.retriever_presets.py,chunking_presets.py: preset matching ignores onlytop_k. Chunking matching goes from subset to exact.front/.../RAG/presetMatching.js:findMatchingPresetthrows on a missing or malformed reference.RAGConfigPanel.jsx,PromptFieldCard.jsx,QueryTransformationAdvancedModal.jsx:deepEqualreplaces everyJSON.stringifyused for comparison.endpoints/rag.py: 404 when the session does not exist, 422 when stored data is malformed.Merge with develop
CompositeRetrieverBuilder.jsx: keeps develop's version. The translated component names in the captions were restored.Testing (optional)
uv run pytest tests/back/RAG tests/back/services: 2064 passed, 1 skipped.yarn build.PermissionError WinError 5when renaming folders undertmp/documents. It passes when rerun in isolation.Notes (optional)
batch_size/deviceno longer match the new signature. Each dense session reindexes once and creates a new row. Old rows and matrices are reclaimed when that session is reindexed. There is no global sweep.NumberInput/IntegerInputis out of scope here.E5MistralGGUFEmbeddinginherits thedeviceexclusion. Reusing vectors between CPU and GPU is an approximation.chunk_size,context_windowandmax_tokens._reranker_referencereturns{}whenquery_transformationhas noparams.has_stale_index_rowsreads the child-link table of the whole database.