What is Retrieval Augmented Generation (RAG)?
Retrieval Augmented Generation (RAG) (original paper, Lewis et al.) leverages both generative models and retrieval models for knowledge-intensive tasks. It improves Generative AI applications by providing up-to-date information and domain-specific data from external data sources during response generation, reducing the risk of hallucinations and significantly improving performance and accuracy.
Building a RAG system can be cost and data efficient without requiring technical expertise to train a model while keeping the other advantages mentioned above.
Quickstart
To build RAG, you first need to create a vector store by indexing your source documents using an embedding model of your choice. LlamaIndex provides libraries to load and transform documents. After this step, you will create a VectorStoreIndex for your document objects with vector embeddings, and store them in a vector store. LlamaIndex supports numerous vector stores. See the complete list of supported vector stores here.
Now when you have a query, you will retrieve relevant information from the vector store, augment it with your original query, and use an LLM to get your final output.
Below you will find an example of how you can incorporate a new article into your RAG application using the Neosantara API and LlamaIndex, so that a generative model can respond with the correct information.
First, install the llama-index package from Pip. See the installation documentation for different ways to install.
Set the environment variables for the API keys. You can find the Neosantara API key on the api-keys page.
Now we will provide some Neosantara introduction and ask “What is Neosantara?” with the retrieved information to llama-3.3-nemotron-super-49b-v1.5, which doesn’t know what Neosantara AI is. We will use “nusa-embedding-0001” for embeddings.
Expected Output
Additional Configuration Options
You can customize the RAG system further by:
- Adjusting retrieval parameters:
- Configuring LLM parameters:
Troubleshooting
Common issues and solutions:
- API Key Error: Ensure your Neosantara API key is correctly set in the environment variable
- Document Loading Error: Check that the document directory exists and contains readable files
- Import Error: Make sure all required packages are installed with
pip install llama-index llama-index-llms-openai-like llama-index-embeddings-openai-like
Conclusion
The above example demonstrates how to build a RAG (Retrieval-Augmented Generation) system using Neosantara and LlamaIndex. By leveraging the power of these tools, you can create a generative model that provides accurate and up-to-date responses by retrieving relevant data from your vector store.
As you continue to explore the capabilities of Neosantara APIs and LlamaIndex, we encourage you to experiment with different use cases and applications. We are excited to see the innovative solutions that you will build using these powerful tools.
Thank you for following along with this tutorial!Last modified on November 11, 2025