Features

  • Parse complex PDF documents (100s of pages)
  • Chunk them and calculate embeddings for chunks
  • Efficient compute of embeddings using batch mode
  • Store the calculated embeddings in a vector database for fast retrieval
  • When user asks a question, the question and relevant document chunks are sent to LLM to get the answer

Tech Stack

Pre requisites

  • Nebius API key. Sign up for free at AI Studio

Getting Started

  1. Get the code:
    git   clone    https://github.com/nebius/ai-studio-cookbook/
    cd    rag/rag-milvus-1
    
  2. Install dependencies: If using uv (prefered):
    uv sync
    
    source .venv/bin/activate
    python -m ipykernel install --user --name=$(basename $(pwd)) --display-name "$(basename $(pwd))"
    # select this kernel when running in jupyter / vscode
    # see installed kernels
    jupyter kernelspec list 
    
    If using pip:
    python -m venv venv
    source venv/bin/activate
    pip install -r requirements.txt
    uv run python -m ipykernel install --user --name=$(basename $(pwd)) --display-name "$(basename $(pwd))"
    # select this kernel when running in jupyter / vscode
    # see installed kernels
    jupyter kernelspec list 
    
  3. Create .env file in the project root and add your Nebius API key:
    cp env.example .env
    
    NEBIUS_API_KEY=your_api_key_here
    

Running the Agent

If using uv :
uv run --with jupyter jupyter lab
If using pip
jupyter lab

Process PDFs

We will
  • parse PDF files
  • compute embeddings
  • and store them into vector database
Run this notebook: 1_process_pdfs.ipynb

Query PDFs

Use this notebook to query PDFs Run this notebook: 2_query_pdfs.ipynb

Dev Notes

How the uv project was created.
uv init --python 3.11 .
uv add llama-index pymilvus openai  python-dotenv llama-index-vector-stores-milvus llama-index-embeddings-nebius   llama-index-llms-nebius
uv add --dev ipykernel   # for jupyter kernel
uv sync
# creating requirements.txt file
uv export --no-hashes --format requirements-txt --output-file requirements.txt
/