Building a system that uses an LLM to answer questions from internal documents (RAG) means wiring together document loading, chunking, embedding, retrieval, and handoff to the LLM each time. LlamaIndex provides that wiring as a framework. I installed it and tested whether document indexing and retrieval worked with the network cut off and the LLM layer disabled.
LlamaIndex is a RAG framework that covers the path from document loading through building an embedding index, retrieval, and handoff to an LLM. LlamaIndex uses the MIT License for its source (*1).
1. Install it
FROM docker.io/library/python:3.12.13-slim
RUN pip install --no-cache-dir --quiet 'llama-index-core==0.14.23' 'llama-index-embeddings-huggingface==0.7.0'
COPY warmup_model.py /tmp/warmup_model.py
RUN python /tmp/warmup_model.py
WORKDIR /work
podman build -t llama-index-sandbox .
2. Test indexing and retrieval without an LLM
Setting Settings.llm = None disables the LLM portion, so I tested indexing and retrieval with the embedding model alone. I registered four short documents and searched with a query whose words had little overlap with any of them. I ran the test with network access disabled.
from llama_index.core import Document, VectorStoreIndex, Settings
from llama_index.embeddings.huggingface import HuggingFaceEmbedding
Settings.embed_model = HuggingFaceEmbedding(model_name="sentence-transformers/all-MiniLM-L6-v2")
Settings.llm = None
documents = [
Document(text="Restarting the router fixes the wifi connection issue in most cases."),
Document(text="The invoice was rejected because the tax identifier field was empty."),
Document(text="Water the tomato plants every morning before the sun gets strong."),
Document(text="A missing tax ID caused the payment validation to fail."),
]
index = VectorStoreIndex.from_documents(documents)
retriever = index.as_retriever(similarity_top_k=2)
query = "billing rejected, tax number missing"
nodes = retriever.retrieve(query)
for node in nodes:
print(f"score={node.score:.4f} {node.text}")
podman run --rm --network none --memory 2g --cpus 2 --pids-limit 512 \
-e HF_HUB_OFFLINE=1 -e TRANSFORMERS_OFFLINE=1 \
-v "$(pwd)":/work -w /work llama-index-sandbox \
python index_demo.py
-v makes the specified directory readable and writable from the container. Run this in an empty directory reserved for the experiment. I needed HF_HUB_OFFLINE and TRANSFORMERS_OFFLINE to prevent the embedding model's underlying libraries from checking online despite a cached model. I have run into this known symptom several times since the headroom article.
The output was:
QUERY: billing rejected, tax number missing
score=0.6907 A missing tax ID caused the payment validation to fail.
score=0.6777 The invoice was rejected because the tax identifier field was empty.
The two tax and billing documents had almost no word overlap with the query and took the top two positions. The search excluded the Wi-Fi and tomato-watering documents. Even without an LLM, the document loading, indexing, and retrieval pipeline worked on its own.
Validate the wiring with retrieval first
When you build a RAG system, testing the whole flow through the LLM call in one pass makes it harder to isolate whether indexing, retrieval, or generation caused a failure. LlamaIndex lets you remove the LLM layer and test retrieval on its own, so you can confirm the base wiring before testing generation.
Sources
*1 LlamaIndex (GitHub), https://github.com/run-llama/llama_index, MIT License