This example shows how to build a classic Retrieval-Augmented Generation (RAG) pipeline with LlamaIndex: parse a PDF document, embed it with a Hugging Face model, index the embeddings in a vector store, and answer questions with Groq's Llama 3.2 LLM. The vector store is persisted to disk so it can be reused without re-indexing.
- Loading and parsing a PDF document with LlamaParse
- Creating vector embeddings with a Hugging Face model
(
sentence-transformers/all-MiniLM-L6-v2) - Building a
VectorStoreIndexand querying it with Groq's Llama 3.2 LLM - Persisting the vector store to
./storage/for reuse
- Python 3.11+
- A Groq API key
- A LlamaIndex Cloud (LlamaParse) API key
- A Hugging Face token
-
Create and activate a Python virtual environment:
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install the required packages:
pip install -r requirements.txt
-
Create your environment file from the template:
cp .env.example .env
-
Edit
.envand add your API keys:GROQ_API_KEY— your Groq API keyLLAMA_CLOUD_API_KEY— your LlamaIndex Cloud (LlamaParse) API keyHF_TOKEN— your Hugging Face token
-
Launch Jupyter and open
main.ipynb:jupyter notebook main.ipynb
-
Run all cells to see the demo in action.
- Make sure all required API keys are set in
.envbefore running the notebook. - The demo ships with a sample PDF (
data/2025_Tucson_Hybrid_user_manual.pdf). Point the loader at your own document to run the pipeline over your own data.
Written and developed by Amin Amiri. Released under the MIT License.