haive.core.engine.retriever.providers.NeuralDBRetrieverConfig

NeuralDB Retriever implementation for the Haive framework.

from typing import Any This module provides a configuration class for the NeuralDB retriever, which uses ThirdAI’s NeuralDB for fast neural search without GPUs. NeuralDB provides efficient neural information retrieval with CPU-only inference and training capabilities.

The NeuralDBRetriever works by: 1. Using ThirdAI’s NeuralDB engine for neural search 2. Performing efficient CPU-based neural retrieval 3. Supporting fast training and inference 4. Enabling neural search without GPU requirements

This retriever is particularly useful when: - Need neural search without GPU infrastructure - Want fast CPU-based neural retrieval - Building cost-effective neural search systems - Need efficient training on CPU - Using ThirdAI’s NeuralDB platform

The implementation integrates with LangChain’s NeuralDBRetriever while providing a consistent Haive configuration interface with secure API key management.

Classes

NeuralDBRetrieverConfig

Configuration for NeuralDB retriever in the Haive framework.

Module Contents

class haive.core.engine.retriever.providers.NeuralDBRetrieverConfig.NeuralDBRetrieverConfig[source]

Bases: haive.core.common.mixins.secure_config.SecureConfigMixin, haive.core.engine.retriever.retriever.BaseRetrieverConfig

Configuration for NeuralDB retriever in the Haive framework.

This retriever uses ThirdAI’s NeuralDB to provide fast neural search without requiring GPU infrastructure, enabling efficient CPU-based retrieval.

retriever_type

The type of retriever (always NEURAL_DB).

Type:

RetrieverType

api_key

ThirdAI API key (auto-resolved from THIRDAI_API_KEY).

Type:

Optional[SecretStr]

model_path

Path to the NeuralDB model file.

Type:

Optional[str]

k

Number of documents to retrieve.

Type:

int

documents

Documents to index for retrieval.

Type:

List[Document]

training_steps

Number of training steps for the model.

Type:

int

Examples

>>> from haive.core.engine.retriever import NeuralDBRetrieverConfig
>>> from langchain_core.documents import Document
>>>
>>> # Create documents
>>> docs = [
...     Document(page_content="Machine learning enables computers to learn"),
...     Document(page_content="Deep learning is a subset of machine learning"),
...     Document(page_content="Neural networks are inspired by the brain")
... ]
>>>
>>> # Create the NeuralDB retriever config
>>> config = NeuralDBRetrieverConfig(
...     name="neuraldb_retriever",
...     documents=docs,
...     k=5,
...     training_steps=100
... )
>>>
>>> # Instantiate and use the retriever
>>> retriever = config.instantiate()
>>> docs = retriever.get_relevant_documents("neural network learning")
>>>
>>> # Example with pre-trained model
>>> pretrained_config = NeuralDBRetrieverConfig(
...     name="pretrained_neuraldb_retriever",
...     model_path="./my_neuraldb_model.pkl",
...     documents=docs,
...     k=3
... )
get_input_fields()[source]

Return input field definitions for NeuralDB retriever.

Return type:

dict[str, tuple[type, Any]]

get_output_fields()[source]

Return output field definitions for NeuralDB retriever.

Return type:

dict[str, tuple[type, Any]]

instantiate()[source]

Create a NeuralDB retriever from this configuration.

Returns:

Instantiated retriever ready for neural search.

Return type:

NeuralDBRetriever

Raises:
  • ImportError – If required packages are not available.

  • ValueError – If API key or configuration is invalid.