> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/avnlp/vectordb/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Build your first RAG pipeline with VectorDB in minutes

This guide walks you through creating a complete semantic search pipeline using VectorDB with Chroma as the vector database.

## What you'll build

By the end of this quickstart, you'll have:

* A working semantic search pipeline using Chroma
* Documents indexed with dense embeddings
* The ability to search using natural language queries
* Optional RAG answer generation

<Info>
  This example uses Chroma for local development. You can swap to any other supported vector database (Pinecone, Weaviate, Qdrant, Milvus) by changing the configuration.
</Info>

## Before you begin

Make sure you've completed the [installation](/installation) steps and have:

* Python 3.11+ installed
* VectorDB dependencies installed via `uv sync`
* Virtual environment activated

## Step 1: Create a configuration file

Create a configuration file `config.yaml` that defines your search pipeline:

```yaml config.yaml theme={null}
dataloader:
  type: "arc"
  split: "test"
  limit: 100
  use_text_splitter: false

embeddings:
  model: "sentence-transformers/all-MiniLM-L6-v2"
  device: "cpu"
  batch_size: 32

chroma:
  collection_name: "quickstart-semantic-search"
  path: "./chroma_data"
  recreate: true

search:
  top_k: 5

rag:
  enabled: false

logging:
  name: "vectordb_quickstart"
  level: "INFO"
```

<Note>
  This configuration uses the ARC dataset (science reasoning questions) and loads 100 test documents. The embedding model runs on CPU for compatibility.
</Note>

## Step 2: Index your documents

Create a Python script `index.py` to index documents into Chroma:

```python index.py theme={null}
from vectordb.langchain.semantic_search import ChromaSemanticIndexingPipeline

# Initialize the indexing pipeline
pipeline = ChromaSemanticIndexingPipeline("config.yaml")

# Run the indexing process
result = pipeline.run()

print(f"Successfully indexed {result['documents_indexed']} documents")
print(f"Collection: {result['collection_name']}")
```

Run the indexing script:

```bash theme={null}
python index.py
```

You should see output like:

```
Successfully indexed 100 documents
Collection: quickstart-semantic-search
```

<Tip>
  Indexing creates dense vector embeddings for each document using the specified model. These embeddings capture semantic meaning for similarity search.
</Tip>

## Step 3: Search your documents

Create a search script `search.py` to query your indexed documents:

```python search.py theme={null}
from vectordb.langchain.semantic_search import ChromaSemanticSearchPipeline

# Initialize the search pipeline
pipeline = ChromaSemanticSearchPipeline("config.yaml")

# Run a semantic search query
results = pipeline.search(
    query="What is photosynthesis?",
    top_k=5
)

print(f"Query: {results['query']}")
print(f"\nTop {len(results['documents'])} results:\n")

for i, doc in enumerate(results['documents'], 1):
    score = doc.metadata.get('score', 'N/A')
    content = doc.page_content[:200]  # First 200 characters
    print(f"{i}. [Score: {score}]")
    print(f"   {content}...\n")
```

Run the search script:

```bash theme={null}
python search.py
```

You'll see the top 5 most semantically similar documents to your query.

## Step 4: Add RAG answer generation (optional)

To generate answers from retrieved documents, enable RAG in your configuration:

```yaml config.yaml theme={null}
rag:
  enabled: true
  model: "llama-3.3-70b-versatile"
  api_key: "${GROQ_API_KEY}"
  temperature: 0.7
  max_tokens: 2048
```

<Warning>
  Make sure you have set your `GROQ_API_KEY` environment variable before enabling RAG.
</Warning>

Update your search script to display the generated answer:

```python search.py theme={null}
from vectordb.langchain.semantic_search import ChromaSemanticSearchPipeline

pipeline = ChromaSemanticSearchPipeline("config.yaml")

results = pipeline.search(
    query="What is photosynthesis?",
    top_k=5
)

print(f"Query: {results['query']}\n")

# Display RAG-generated answer
if 'answer' in results:
    print(f"Answer: {results['answer']}\n")

print(f"Retrieved {len(results['documents'])} documents")
```

Now when you run the search, you'll get an AI-generated answer based on the retrieved documents.

## Understanding the pipeline

Here's what happens under the hood:

<Steps>
  <Step title="Query embedding">
    Your query text is converted to a dense vector using the same embedding model used during indexing
  </Step>

  <Step title="Similarity search">
    The vector database finds documents with embeddings closest to your query embedding using cosine similarity
  </Step>

  <Step title="Result ranking">
    Results are ranked by similarity score, with the most relevant documents returned first
  </Step>

  <Step title="Optional RAG generation">
    If enabled, the LLM generates an answer using the retrieved documents as context
  </Step>
</Steps>

## Try different vector databases

VectorDB supports multiple vector databases with the same interface. Here's how to switch from Chroma to Pinecone:

<CodeGroup>
  ```python Chroma (local) theme={null}
  from vectordb.langchain.semantic_search import ChromaSemanticSearchPipeline

  pipeline = ChromaSemanticSearchPipeline("config.yaml")
  results = pipeline.search("What is machine learning?", top_k=5)
  ```

  ```python Pinecone (cloud) theme={null}
  from vectordb.langchain.semantic_search import PineconeSemanticSearchPipeline

  pipeline = PineconeSemanticSearchPipeline("config.yaml")
  results = pipeline.search("What is machine learning?", top_k=5)
  ```

  ```python Weaviate theme={null}
  from vectordb.langchain.semantic_search import WeaviateSemanticSearchPipeline

  pipeline = WeaviateSemanticSearchPipeline("config.yaml")
  results = pipeline.search("What is machine learning?", top_k=5)
  ```

  ```python Qdrant theme={null}
  from vectordb.langchain.semantic_search import QdrantSemanticSearchPipeline

  pipeline = QdrantSemanticSearchPipeline("config.yaml")
  results = pipeline.search("What is machine learning?", top_k=5)
  ```

  ```python Milvus theme={null}
  from vectordb.langchain.semantic_search import MilvusSemanticSearchPipeline

  pipeline = MilvusSemanticSearchPipeline("config.yaml")
  results = pipeline.search("What is machine learning?", top_k=5)
  ```
</CodeGroup>

Just update your config file with the appropriate database settings and API keys.

## Using Haystack instead of LangChain

VectorDB provides identical functionality for both frameworks:

<CodeGroup>
  ```python LangChain theme={null}
  from vectordb.langchain.semantic_search import ChromaSemanticSearchPipeline

  pipeline = ChromaSemanticSearchPipeline("config.yaml")
  results = pipeline.search("What is photosynthesis?", top_k=5)

  for doc in results["documents"]:
      print(doc.page_content)
  ```

  ```python Haystack theme={null}
  from vectordb.haystack.semantic_search import ChromaSemanticSearchPipeline

  pipeline = ChromaSemanticSearchPipeline("config.yaml")
  result = pipeline.search("What is photosynthesis?", top_k=5)

  for doc in result["documents"]:
      print(doc.content)
  ```
</CodeGroup>

## Next steps

Now that you have a working semantic search pipeline, explore advanced features:

<CardGroup cols={2}>
  <Card title="Hybrid search" icon="arrows-split-up-and-left" href="/features/hybrid-search">
    Combine dense and sparse retrieval for better results
  </Card>

  <Card title="Reranking" icon="arrow-down-1-9" href="/features/reranking">
    Use cross-encoders for higher precision
  </Card>

  <Card title="Query enhancement" icon="wand-magic-sparkles" href="/advanced/query-enhancement">
    Improve recall with multi-query and HyDE
  </Card>

  <Card title="Metadata filtering" icon="filter" href="/data/metadata-filtering">
    Filter results by document attributes
  </Card>
</CardGroup>
