LlamaIndex in Python: A RAG Guide With Examples - Real Python
Briefly

LlamaIndex in Python: A RAG Guide With Examples - Real Python
"RAG is a technique where the system, at query time, first retrieves relevant external documents or data and then passes them to the LLM as additional context. The model uses this context as a source of truth when generating its answer, which typically makes the response more accurate, up to date, and on topic. Note: RAG can help reduce hallucinations and prevent models from giving wrong answers. However, recent LLMs are much better at admitting when they don't know something rather than making up an answer."
"Before installing LlamaIndex, you should create and activate a Python virtual environment. Refer to Python Virtual Environments: A Primer for detailed instructions on how to do this. Once you have the virtual environment ready, you can install LlamaIndex from the Python Package Index (PyPI): This command downloads the framework from PyPI and installs it in your current Python environment. In practice, llama-index is a core starter bundle of packages containing the following: llama-index-core llama-index-llms-openai llama-index-embeddings-openai llama-index-readers-file As you can see, OpenAI is the default LLM provider for LlamaIndex."
Retrieval-augmented generation (RAG) retrieves relevant external documents at query time and supplies them to an LLM as additional context. The context acts as a source of truth, improving accuracy, topicality, and timeliness of model responses and reducing hallucinations. RAG enables answering questions about private internal data, such as company records or email history, without modifying the base model. LlamaIndex is a Python framework that enables RAG applications by indexing and retrieving user data for LLM consumption. Installation requires a Python virtual environment and installing the llama-index package, which bundles core, OpenAI LLM and embeddings connectors, and file readers.
Read at Realpython
Unable to calculate read time
[
|
]