Core Concepts
LlamaIndex.TS is built around a few key concepts that work together to enable powerful LLM applications. Understanding these concepts will help you build more effective RAG systems, agents, and workflows.Overview
At its core, LlamaIndex.TS helps you:- Load and process your data into structured formats
- Index that data for efficient retrieval
- Query the indexed data using natural language
- Generate responses using LLMs with relevant context
All of these components are modular and composable, allowing you to customize every part of the pipeline.
Documents and Nodes
Documents
Documents are the primary data containers in LlamaIndex.TS. They represent your raw data with metadata.Nodes
Nodes are atomic units of data in LlamaIndex.TS. Documents are split into nodes (chunks) for efficient retrieval.Node Parsing
LlamaIndex.TS includes several node parsers (text splitters) to chunk your documents:- SentenceSplitter: Splits by sentences while respecting chunk size
- SimpleNodeParser: Basic chunking with overlap
- MarkdownNodeParser: Preserves markdown structure
- CodeSplitter: Language-aware code splitting
Embeddings
Embeddings are vector representations of text that capture semantic meaning. They enable semantic search by measuring similarity between queries and documents.By default, LlamaIndex.TS uses OpenAI’s embedding models, but you can use any provider including local models via Ollama.
Indices
Indices are data structures that organize your nodes for efficient retrieval. The most common is the VectorStoreIndex.VectorStoreIndex
Stores embeddings for semantic search:Other Index Types
LlamaIndex.TS provides several index types for different use cases:- SummaryIndex: Sequential scanning of all nodes
- KeywordTableIndex: Keyword-based retrieval
- KnowledgeGraphIndex: Graph-based relationships
Retrieval
Retrievers fetch relevant nodes from an index based on a query.Advanced Retrieval
Combine multiple retrieval strategies:- Hybrid Search: Combine semantic and keyword search
- Reranking: Improve results with a reranker model
- Metadata Filtering: Filter by document metadata
Query Engines
Query Engines combine retrieval and response generation to answer questions.Streaming Responses
Stream responses for better UX:Chat Engines
Chat Engines enable multi-turn conversations with context retention.Chat Engine Types
Different chat engines for different use cases:- ContextChatEngine: Retrieves context for each message
- SimpleChatEngine: Direct chat without retrieval
- CondensePlusContextChatEngine: Condenses chat history before retrieval
LLMs (Large Language Models)
LLMs generate the final responses in your application. LlamaIndex.TS supports multiple providers.Switching Providers
Easily switch between LLM providers:RAG (Retrieval-Augmented Generation)
RAG is the core pattern that combines retrieval with generation. It allows LLMs to answer questions using your data.How RAG Works
1
Index Your Data
Documents are chunked, embedded, and stored in a vector index.
2
Query Processing
User query is embedded using the same embedding model.
3
Retrieval
Most similar chunks are retrieved based on vector similarity.
4
Context Augmentation
Retrieved chunks are added to the LLM prompt as context.
5
Generation
LLM generates a response using the provided context.
Basic RAG Pipeline
Agents and Workflows
For more advanced use cases, agents can reason, plan, and use tools to accomplish tasks.Settings and Configuration
Settings is a global configuration object that controls default behavior:Vector Stores
For production applications, use a dedicated vector database instead of in-memory storage:- Pinecone
- Qdrant
- Chroma
- Weaviate
- Milvus
- MongoDB Atlas
- PostgreSQL (pgvector)
- And more!
Next Steps
Now that you understand the core concepts, dive deeper into specific topics:Query Engines
Learn about different query engine types and customization
Chat Engines
Build conversational interfaces with context
Agents
Create intelligent agents with tools and reasoning
Vector Stores
Integrate production vector databases