Skip to main content

Crate lc_rag

Crate lc_rag 

Source
Expand description

RAG (Retrieval-Augmented Generation) module for LangChainRust.

Provides document loaders, text splitters, retrievers, BM25 search, hybrid retrieval, GraphRAG, HyDE, multi-query, reranking, and a full RAG pipeline builder.

Re-exports§

pub use adapter::RagRunnable;
pub use parent_document::ParentDocumentRetriever;
pub use pipeline::RAGPipeline;
pub use pipeline::RAGPipelineBuilder;
pub use pipeline::RAGQueryResult;
pub use retriever_runnable::RetrieverRunnable;
pub use loaders::CSVLoader;
pub use loaders::DocumentLoader;
pub use loaders::DocxLoader;
pub use loaders::HTMLLoader;
pub use loaders::JSONLoader;
pub use loaders::LoaderError;
pub use loaders::MarkdownLoader;
pub use loaders::PDFLoader;
pub use loaders::SitemapLoader;
pub use loaders::TextLoader;
pub use loaders::WebScraperLoader;
pub use retriever::Retriever;
pub use retriever::RetrieverError;
pub use retriever::RetrieverTrait;
pub use retriever::SimilarityRetriever;
pub use self_query::SelfQueryArgs;
pub use self_query::SelfQueryRetriever;
pub use semantic_splitter::SemanticSplitter;
pub use bm25::AutoMergingConfig;
pub use bm25::BM25Params;
pub use bm25::BM25Retriever;
pub use bm25::ChunkedBM25Retriever;
pub use bm25::ChunkedSearchResult;
pub use bm25::Tokenizer;
pub use hybrid::filter_by_score;
pub use hybrid::reciprocal_rank_fusion;
pub use hybrid::RetrievalSource;
pub use hybrid::RetrievedDocument;
pub use unified_hybrid::HybridIndexConfig;
pub use unified_hybrid::HybridSearchResult;
pub use unified_hybrid::UnifiedHybridIndex;
pub use multi_query::MultiQueryConfig;
pub use multi_query::MultiQueryError;
pub use multi_query::MultiQueryRetriever;
pub use multi_query::StaticQueryGenerator;
pub use hyde::HyDEConfig;
pub use hyde::HyDEError;
pub use hyde::HyDERetriever;
pub use reranking::BM25Reranker;
pub use reranking::KeywordReranker;
pub use reranking::Reranker;
pub use reranking::RerankingConfig;
pub use reranking::RerankingError;
pub use reranking::RerankingExecutor;
pub use graph_rag::Community as GraphCommunity;
pub use graph_rag::Entity as GraphEntity;
pub use graph_rag::GraphStore;
pub use graph_rag::Relation as GraphRelation;
pub use graph_rag::GraphRAG;
pub use graph_rag::GraphRAGConfig;
pub use graph_rag::GraphRAGError;
pub use graph_rag::GraphRAGResult;
pub use graph_rag::QueryMode;

Modules§

adapter
RagRunnable adapter - bridges RAGPipeline to the Runnable trait.
bm25
BM25 retrieval module
graph_rag
GraphRAG (Knowledge Graph RAG) module.
hybrid
Hybrid retrieval module
hyde
HyDE (Hypothetical Document Embedding) Retriever implementation
loaders
Document loader implementations
multi_query
MultiQueryRetriever implementation
parent_document
ParentDocumentRetriever — a parent/child document retriever
pipeline
RAGPipeline & RAGPipelineBuilder — a complete RAG pipeline in one line
reranking
Reranking implementation
retriever
Retriever implementations
retriever_runnable
RetrieverRunnable — a Runnable adapter to bring any retriever into an LCEL chain
self_query
SelfQueryRetriever — a self-querying retriever
semantic_splitter
Semantic chunking
splitter
Text splitter implementation
unified_hybrid
Unified Hybrid Index

Structs§

ChunkDocument
Chunk document (split document fragment).
ChunkedVectorStore
Chunked Vector Store
Document
Document structure.
InMemoryDocumentStore
In-memory document store
InMemoryVectorStore
In-memory vector store
MockEmbeddings
Mock embeddings for testing purposes.
OpenAIEmbeddings
OpenAI Embeddings client
RecursiveCharacterSplitter
Recursive character splitter
SearchResult
Search result.

Enums§

EmbeddingError
Embedding error type
VectorStoreError
Vector store error types.

Traits§

ChunkedDocumentStoreTrait
Document store trait supporting a parent-child structure
DocumentStore
Document store trait
Embeddings
Embedding model trait
TextSplitter
Text splitter trait
VectorStore
Vector store trait.

Functions§

cosine_similarity
Compute cosine similarity between two vectors.

Type Aliases§

ChunkedDocumentStore
Type alias for InMemoryChunkedDocumentStore