examples/rag-retriever/README.md
This example notebook provides a step-by-step demonstration of building and using a RAG system with Feast and the custom FeastRagRetriever. The notebook walks through:
Data Preparation
Embedding Generation
all-MiniLM-L6-v2 sentence transformer modelFeature Store Setup
RAG System Implementation
all-MiniLM-L6-v2 (configurable)granite-3.2-2b-instruct (configurable)Query Demonstration
Clone this repository: https://github.com/feast-dev/feast.git Navigate to the examples/rag-retriever directory. Here you will find the following files:
feature_repo/feature_store.yaml This is the core configuration file for the RAG project's feature store, configuring a Milvus online store on a local provider.
feature_store.yaml with your Milvus connection details:
feature_repo/ragproject_repo.py This is the Feast feature repository configuration that defines the schema and data source for Wikipedia passage embeddings.
rag_feast.ipynb This is a notebook demonstrating the implementation of a RAG system using Feast. The notebook provides:
all-MiniLM-L6-v2 for generating embeddingsgranite-3.2-2b-instruct as the generator modelOpen rag_feast.ipynb and follow the steps in the notebook to run the example.
As an alternative to the manual data preparation steps in the notebook above, Feast provides the DocEmbedder class that automates the entire document-to-embeddings pipeline: chunking, embedding generation, FeatureView creation, and writing to the online store.
pip install feast[milvus,rag]
from feast import DocEmbedder
from datasets import load_dataset
# Load your dataset
dataset = load_dataset("facebook/wiki_dpr", "psgs_w100.nq.exact", split="train[:1%]",
with_index=False, trust_remote_code=True)
df = dataset.select(range(100)).to_pandas()
# DocEmbedder handles everything in one step
embedder = DocEmbedder(
repo_path="feature_repo_docembedder/",
feature_view_name="text_feature_view",
)
result = embedder.embed_documents(
documents=df,
id_column="id",
source_column="text",
column_mapping=("text", "text_embedding"),
)
feast applyTextChunker (configurable chunk size, overlap, etc.)MultiModalEmbedder (defaults to all-MiniLM-L6-v2)BaseChunker for your own chunking strategyBaseEmbedder to use a different embedding modelSchemaTransformFn to control how the output maps to your FeatureView schemaSee rag_feast_docembedder.ipynb for a complete end-to-end example that uses DocEmbedder with the Wiki DPR dataset and then queries the results using FeastRAGRetriever.