GenAI Builder Concepts

Retrieval Augmented Generation (RAG)

Retrieval-Augmented Generation (RAG) is a technique in machine learning that combines the power of pretrained language models with the benefits of information retrieval systems to enhance the generation of text.

Hybrid Approach
Merges language models with retrieval systems.
Function
Enhances text generation by first retrieving relevant
Application
Used in question-answering, chatbots, and anywhere where contextually rich and accurate text generation is critical.
Advantage
Provides more informative and contextually relevant text by leveraging a vast corpus of information beyond the language model's pre-training data.

The following diagram illustrates the flow of the user prompt using RAG.

Think of RAG as a smart helper for the LLM to create text. RAG first finds useful bits of information from a large set of documents and then uses them to help write new sentences that make sense and are full of meaningful details. It helps make the text more interesting and full of real facts because it's using information from predefined sources of truth.

Vector Databases

A vector database is a type of database designed to efficiently store and query data in the form of vectors, which are arrays of numbers that represent complex data points like images, sounds, and text in a multi-dimensional space. It works by converting rich, unstructured data into vectors using algorithms called embeddings. These embeddings capture the essence of the data in a form that can be mathematically compared. The database then indexes these vectors in such a way that it can quickly retrieve items whose vectors are closest to each other, indicating high similarity or relevance.

Vector databases are particularly useful in applications requiring high-speed similarity searches, such as content recommendation systems, image and audio retrieval platforms, and machine learning model queries where the relationships between data points are more significant than the data itself.

The main advantage of a vector database is its ability to perform what's known as nearest neighbor or distance searches. This allows for finding the best matches in large data sets almost instantaneously, which is a challenge for traditional databases when dealing with high-dimensional data.

Embedding

The main advantage of a vector database is its ability to perform what's known as nearest neighbor searches. This allows for finding the best matches in large data sets almost instantaneously, which is a challenge for traditional databases when dealing with high-dimensional data.

Chunking

Chunking is the process of dividing large data sets or extensive text inputs into smaller, more manageable segments or chunks. This method is crucial for improving the efficiency, accuracy, and scalability of data processing and machine learning tasks.

RAG leverages chunking to enhance the vector storage/embedding. It divides large texts or data sets into chunks, allowing the model to retrieve relevant information from these chunks to generate more informed and accurate responses.