org.llm4s.rag
Members list
Packages
Type members
Classlikes
High-level RAG (Retrieval-Augmented Generation) pipeline.
High-level RAG (Retrieval-Augmented Generation) pipeline.
Provides a unified interface for:
- Document ingestion (from files, directories, or raw text)
- Semantic search with hybrid fusion
- Answer generation with retrieved context
Attributes
- Example
-
import org.llm4s.chunking.ChunkerFactory import org.llm4s.config.Llm4sConfig import org.llm4s.model.ModelRegistryService import org.llm4s.rag.RAG import org.llm4s.rag.RAG.RAGConfigOps // `build` is an extension of RAGConfig; without this import it is not found // `build` also needs a ModelRegistryService and a ProviderRegistry in scope. The registry // below comes from `Llm4sConfig.modelRegistryService()`; ProviderRegistry.default is a given already. given ModelRegistryService = Llm4sConfig.modelRegistryService().toOption.get // Create pipeline val rag = RAG.builder() .withEmbeddings("openai") .withChunking(ChunkerFactory.Strategy.Sentence, 800, 150) .build .toOption.get // Ingest documents rag.ingest("./docs") // Search val results = rag.query("What is X?") // With answer generation (requires LLM client) val ragWithLLM = RAG.builder() .withEmbeddings("openai") .withLLM(llmClient) .build .toOption.get val answer = ragWithLLM.queryWithAnswer("What is X?") - Companion
- object
- Supertypes
-
trait Closeabletrait AutoCloseableclass Objecttrait Matchableclass Any
Result from RAG answer generation.
Result from RAG answer generation.
Value parameters
- answer
-
The generated answer text
- contexts
-
The chunks used as context for generation
- question
-
The original question
- usage
-
Optional token usage statistics
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Configuration for RAG pipeline.
Configuration for RAG pipeline.
Uses immutable copy pattern for fluent configuration. All settings have sensible defaults for quick start.
Value parameters
- embeddingModel
-
the model to embed with. When
None, the model of the resolved provider config is used, then the provider's own default. - embeddingProvider
-
id of the embedding provider, resolved through the org.llm4s.llmconnect.spi.ProviderRegistry when the pipeline is built - the same id as in
EMBEDDING_MODEL=<id>/<model>. Any provider on the classpath can be named, and one that is not fails the build with the registry's "not registered" error.
Attributes
- Example
-
// Minimal configuration val config = RAGConfig() .withEmbeddings("openai") // Full customization with SQLite val config = RAGConfig() .withEmbeddings("openai", "text-embedding-3-large") .withChunking(ChunkerFactory.Strategy.Sentence, 800, 150) .withRRF(60) .withSQLite("./rag.db") .withLLM(llmClient) // Using PostgreSQL with pgvector val config = RAGConfig() .withEmbeddings("openai") .withPgVector("jdbc:postgresql://localhost:5432/mydb", "user", Secret("pass"), "embeddings") - Companion
- object
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Result from RAG search operation.
Result from RAG search operation.
Value parameters
- content
-
The text content of the chunk
- id
-
Chunk identifier
- keywordScore
-
Optional keyword match score
- metadata
-
Additional metadata (source, docId, etc.)
- score
-
Combined relevance score
- vectorScore
-
Optional vector similarity score
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
RAG pipeline statistics.
RAG pipeline statistics.
Value parameters
- chunkCount
-
Number of chunks indexed
- documentCount
-
Number of documents indexed
- vectorCount
-
Number of vectors in store
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- trait
- Supertypes
-
trait Sumtrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
RerankingStrategy.type