Module learned

Module learned 

Source
Expand description

Learned index structures using ML models for data indexing.

This module implements learned indices, which use machine learning models to predict the position of data in the index, replacing traditional index structures like B-trees with neural networks or linear models.

§Architecture

The implementation uses a Recursive Model Index (RMI) architecture:

  • Stage 0: Root model that routes to second-stage models
  • Stage 1: Multiple specialized models for different data ranges
  • Each model learns to predict positions in the sorted data

§Example

use ipfrs_semantic::learned::{LearnedIndex, RMIConfig};
use ipfrs_core::cid::Cid;

// Create a learned index with default configuration
let mut index = LearnedIndex::new(RMIConfig::default());

// Add embeddings with their CIDs
let cid = Cid::default();
let embedding = vec![0.1, 0.2, 0.3, 0.4];
index.add(cid.clone(), embedding.clone())?;

// Search for nearest neighbors
let query = vec![0.15, 0.25, 0.35, 0.45];
let results = index.search(&query, 5)?;

Structs§

LearnedIndex
Recursive Model Index (RMI) for learned indexing
LearnedIndexStats
Statistics for the learned index
RMIConfig
Configuration for Recursive Model Index (RMI)

Enums§

ModelType
Type of model to use in the learned index