Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A Cheat Sheet and Some Recipes For Building Advanced RAG | by Andrei | Jan, 2024 | LlamaIndex Blog #315

Open
1 task
irthomasthomas opened this issue Jan 8, 2024 · 0 comments
Labels
llm Large Language Models Papers Research papers RAG Retrieval Augmented Generation for LLMs technical-writing Links to deep technical writing and books

Comments

@irthomasthomas
Copy link
Owner

A comprehensive RAG Cheat Sheet detailing motivations for RAG as well as techniques and strategies for progressing beyond Basic or Naive RAG builds. (high-resolution version)
It’s the start of a new year and perhaps you’re looking to break into the RAG scene by building your very first RAG system. Or, maybe you’ve built Basic RAG systems and are now looking to enhance them to something more advanced in order to better handle your user’s queries and data structures.
In either case, knowing where or how to begin may be a challenge in and of itself! If that’s true, then hopefully this blog post points you in the right direction for your next steps, and moreover, provides for you a mental model for you to anchor your decisions when building advanced RAG systems.
The RAG cheat sheet shared above was greatly inspired by a recent RAG survey paper (“Retrieval-Augmented Generation for Large Language Models: A Survey” Gao, Yunfan, et al. 2023).
Basic RAG
Mainstream RAG as defined today involves retrieving documents from an external knowledge database and passing these along with the user’s query to an LLM for response generation. In other words, RAG involves a Retrieval component, an External Knowledge database and a Generation component.
LlamaIndex Basic RAG Recipe:
from llama_index import SimpleDirectoryReader, VectorStoreIndex

load data

documents = SimpleDirectoryReader(input_dir="...").load_data()

build VectorStoreIndex that takes care of chunking documents

and encoding chunks to embeddings for future retrieval

index = VectorStoreIndex.from_documents(documents=documents)

The QueryEngine class is equipped with the generator

and facilitates the retrieval and generation steps

query_engine = index.as_query_engine()

Use your Default RAG

response = query_engine.query("A user's query")

Suggested labels

{ "key": "RAG-Building", "value": "Techniques and strategies for building advanced Retrieval Augmented Generation systems for language models" }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
llm Large Language Models Papers Research papers RAG Retrieval Augmented Generation for LLMs technical-writing Links to deep technical writing and books
Projects
None yet
Development

No branches or pull requests

1 participant