haive.core.engine.retriever.providers.SVMRetrieverConfig¶
Support Vector Machine Retriever implementation for the Haive framework.
from typing import Any This module provides a configuration class for the SVM (Support Vector Machine) retriever, which uses Support Vector Machine algorithm for document retrieval. SVM retriever treats document retrieval as a binary classification problem where the query represents the positive class and retrieves documents most similar to this positive class.
The SVMRetriever works by: 1. Training an SVM classifier using the query as positive examples 2. Using the SVM decision function to score documents 3. Ranking documents by their SVM scores 4. Returning the top-k highest scoring documents
This retriever is particularly useful when: - Working with text classification-style retrieval - Need margin-based similarity scoring - Want robust retrieval with outlier resistance - Building retrieval systems with limited training data - Combining with other ML-based retrieval approaches
The implementation integrates with LangChain’s SVMRetriever while providing a consistent Haive configuration interface.
Classes¶
Configuration for Support Vector Machine retriever in the Haive framework. |
Module Contents¶
- class haive.core.engine.retriever.providers.SVMRetrieverConfig.SVMRetrieverConfig[source]¶
Bases:
haive.core.engine.retriever.retriever.BaseRetrieverConfig
Configuration for Support Vector Machine retriever in the Haive framework.
This retriever uses SVM classification to score and rank documents based on their similarity to the query, treating retrieval as a classification problem.
- retriever_type¶
The type of retriever (always SVM).
- Type:
- documents¶
Documents to index for retrieval.
- Type:
List[Document]
Examples
>>> from haive.core.engine.retriever import SVMRetrieverConfig >>> from langchain_core.documents import Document >>> >>> # Create documents >>> docs = [ ... Document(page_content="Machine learning optimizes model parameters"), ... Document(page_content="Deep learning networks minimize loss functions"), ... Document(page_content="Natural language processing tokenizes text inputs") ... ] >>> >>> # Create the SVM retriever config >>> config = SVMRetrieverConfig( ... name="svm_retriever", ... documents=docs, ... k=2, ... kernel="rbf", ... C=1.0, ... gamma="scale" ... ) >>> >>> # Instantiate and use the retriever >>> retriever = config.instantiate() >>> docs = retriever.get_relevant_documents("machine learning optimization methods")
- instantiate()[source]¶
Create an SVM retriever from this configuration.
- Returns:
Instantiated retriever ready for classification-based retrieval.
- Return type:
SVMRetriever
- Raises:
ImportError – If required packages are not available.
ValueError – If documents list is empty.