Course contentsShow
← AI Engineering
Lesson 516 of 1,88613. LLM Orchestration FrameworksFree lesson

Building Your First Index

Creating a VectorStoreIndex from documents to enable semantic search and retrieval.

Building Your First Index

You'll learn: How to create a VectorStoreIndex in LlamaIndex that transforms your documents into a searchable knowledge base using semantic search.

What Is a VectorStoreIndex?

Think of a VectorStoreIndex as a smart filing cabinet that organizes documents by meaning rather than just keywords. When you build an index, LlamaIndex converts your documents into vector embeddings (numerical representations of meaning) and stores them so you can later ask questions and retrieve the most semantically relevant information.

This is the foundational step that powers semantic search—finding answers based on what you mean, not just the exact words you use.

Creating Your First Index

After loading documents using LlamaIndex's data connectors (as you learned previously), building an index is straightforward:

from llama_index.core import VectorStoreIndex, Document

# Assume you've loaded documents
documents = [
    Document(text="Paris is the capital of France."),
    Document(text="Machine learning models learn from data.")
]

# Build the index
index = VectorStoreIndex.from_documents(documents)

Behind the scenes, LlamaIndex:

  1. Chunks your documents into nodes (manageable pieces)
  2. Generates embeddings for each node using an embedding model
  3. Stores these embeddings in a vector store (default is in-memory)

Why This Matters

Without an index, you'd need to manually search through documents or use exact keyword matching. The VectorStoreIndex enables semantic retrieval—asking "What's France's capital?" will match "Paris is the capital of France" even though the wording differs.

Key Takeaway: The VectorStoreIndex is your gateway to semantic search in LlamaIndex—it transforms raw documents into an intelligent, queryable knowledge base by converting text into vector embeddings.