langchain_patterns

Implement RAG pipelines with LangChain4j for document ingestion, embedding stores, and retrieval.

Updated Jan 14, 2026
One-click install
npx skills add https://github.com/jvsandhu/agentic-skills --skill langchain-patterns-jvsandhu
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: langchain_patterns
Source: https://github.com/jvsandhu/agentic-skills/tree/main/skills/langchain_patterns
Command: npx skills add https://github.com/jvsandhu/agentic-skills --skill langchain-patterns-jvsandhu

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Building question-answering systems over private document collections requires wiring together document loaders, text splitters, embedding models, vector stores, and retrieval logic, which is error-prone without proven patterns. ## Core Features & Use Cases - Document Ingestion Pipelines: Load files, split them into token-aware chunks with overlap, embed them, and store them in an embedding store with metadata. - Retrieval Strategies: Configure content retrievers with score thresholds, hybrid vector-plus-keyword search, re-ranking, and hierarchical retrieval across summaries and chunks. - RAG-Enabled AI Services: Define LangChain4j AI service interfaces with system prompts and content retrievers for grounded, source-attributed answers. - Use Case: Build a company knowledge-base assistant in Spring Boot that ingests policy documents, retrieves relevant passages per question, and answers with citations while saying "I don't know" for out-of-scope queries. ## Quick Start Ask the agent to scaffold a Spring Boot RAG service using LangChain4j that ingests a folder of documents and answers questions over them.

Frequently Asked Questions about langchain_patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build a RAG application with LangChain4j?

Create a Spring Boot project with the langchain4j-spring-boot-starter dependency, configure an EmbeddingModel and EmbeddingStore, ingest documents with a recursive splitter, then wire a ContentRetriever into an AI service interface that answers questions with retrieved context.

How to implement document ingestion and chunking in LangChain4j?

Load files with FileSystemDocumentLoader, split them using DocumentSplitters.recursive with 500-1000 token chunks and 20-50 token overlap, embed all segments with your embedding model, and store embeddings plus segments in the embedding store with metadata.

Does LangChain4j support hybrid search combining vector and keyword retrieval?

Yes, you can combine vector search from the embedding store with a full-text keyword engine and merge results using Reciprocal Rank Fusion. The skill includes a HybridSearchService pattern demonstrating this combination with re-ranking.

Why does my RAG system return poor retrieval results?

Poor retrieval usually stems from wrong chunk sizes, incompatible embedding models, or overly restrictive metadata filters. Check chunk overlap settings, verify embedding model compatibility, and consider adding a re-ranking step with a cross-encoder.

How do I reduce memory usage with large document collections in LangChain4j?

Replace InMemoryEmbeddingStore with a disk-based or external vector database, implement pagination and filtering on queries, and periodically clean unused embeddings. Batch embedding generation also helps for bulk ingestion operations.