MMRRerankerRetriever
Re-ranks retrieval results using Maximum Marginal Relevance for diversity.
The child retriever (the ranker) determines the candidate set via its
own configuration; this reranker selects top_k chunks for
diversity by balancing relevance and similarity among them.
Parameters
- mmr_lambda : number, default=
0.5 - Trade-off between relevance (1.0) and diversity (0.0).
- top_k : integer, default=
5 - Final number of chunks to select. The candidate set size is determined by the child retriever's own top_k.
- children : array, default=
[] - The child retriever whose results will be re-ranked.
Methods
get_metadata(cls) -> Dict[str, Any]
MMRRerankerRetrieverReturn UI metadata including the declarative operation summary.
retrieve(self, query: str, **kwargs) -> List[DashAI.back.models.RAG.documents.chunk.Chunk]
MMRRerankerRetrieverRetrieve and re-rank chunks using MMR diversity.
score_chunks(self, chunk_ids: List[int], query: str) -> List[Tuple[int, float]]
MMRRerankerRetrieverScore chunks by delegating to the child retriever.
add(self, child: DashAI.back.models.RAG.retrievers.base_retriever.BaseRetriever) -> None
CompositeRetrieverAdd a child retriever.
get_children(self) -> List[DashAI.back.models.RAG.retrievers.base_retriever.BaseRetriever]
CompositeRetrieverReturn a copy of the children list.
get_credential(self, name: str)
ConfigObjectResolve a registered credential component by name.
Parameters
- name : str
- Credential component class name (e.g. "HuggingFaceCredential").
Returns
- BaseCredential
- An instance of the requested credential component.
get_id(self) -> int | None
BaseRetrieverReturn the database ID of this retriever, or None.
get_schema(cls) -> dict
ConfigObjectGenerates the component related Json Schema.
Returns
- dict
- Dictionary representing the Json Schema of the component.
init_model(self) -> None
BaseRetrieverCalled by the factory after inject_infra().
inject_infra(self, env_RAG_path: str | os.PathLike, chunks: Dict[int, Dict[int, DashAI.back.models.RAG.documents.chunk.Chunk]], persistence: Any) -> None
BaseRetrieverInject runtime infrastructure after schema validation.
load(self, filename: str = '') -> None
BaseRetrieverRestore the retriever's state from disk.
remove(self, child: DashAI.back.models.RAG.retrievers.base_retriever.BaseRetriever) -> None
CompositeRetrieverRemove a child retriever.
save(self, filename: str = '') -> None
BaseRetrieverPersist the retriever's state to disk.
set_id(self, id: int) -> None
BaseRetrieverAssign a database ID to this retriever.
validate_and_transform(self, raw_data: dict) -> dict
ConfigObjectIt takes the data given by the user to initialize the model and returns it with all the objects that the model needs to work.
Parameters
- raw_data : dict
- A dictionary with the data provided by the user to initialize the model.
Returns
- dict
- A validated dictionary with the necessary objects.