Overview of Retrieval-Augmented Generation (RAG) in LangChain4j
RAG is a technique used to provide LLMs with domain-specific or proprietary knowledge by retrieving relevant information from a data source and injecting it into the prompt before sending it to the LLM. This reduces hallucinations and allows the model to answer questions based on data it wasn't trained on.
LangChain4j supports three RAG styles:
- Easy RAG: The fastest way to start, abstracting away embeddings and splitting.
- Naive RAG: A basic implementation using vector search.
- Advanced RAG: A modular framework supporting query transformation, multi-source retrieval, and re-ranking.
Common retrieval methods include Full-text (keyword) search, Vector (semantic) search, and Hybrid search (a combination of both). Currently, full-text and hybrid search are primarily supported via the AzureAiSearchContentRetriever.