Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
RAG-Driven Generative AI

You're reading from   RAG-Driven Generative AI Build custom retrieval augmented generation pipelines with LlamaIndex, Deep Lake, and Pinecone

Arrow left icon
Product type Paperback
Published in Sep 2024
Publisher Packt
ISBN-13 9781836200918
Length 334 pages
Edition 1st Edition
Languages
Tools
Concepts
Arrow right icon
Author (1):
Arrow left icon
Denis Rothman Denis Rothman
Author Profile Icon Denis Rothman
Denis Rothman
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Preface 1. Why Retrieval Augmented Generation? 2. RAG Embedding Vector Stores with Deep Lake and OpenAI FREE CHAPTER 3. Building Index-Based RAG with LlamaIndex, Deep Lake, and OpenAI 4. Multimodal Modular RAG for Drone Technology 5. Boosting RAG Performance with Expert Human Feedback 6. Scaling RAG Bank Customer Data with Pinecone 7. Building Scalable Knowledge-Graph-Based RAG with Wikipedia API and LlamaIndex 8. Dynamic RAG with Chroma and Hugging Face Llama 9. Empowering AI Models: Fine-Tuning RAG Data and Human Feedback 10. RAG for Video Stock Production with Pinecone and OpenAI 11. Other Books You May Enjoy
12. Index
Appendix

From raw data to embeddings in vector stores

Embeddings convert any form of data (text, images, or audio) into real numbers. Thus, a document is converted into a vector. These mathematical representations of documents allow us to calculate the distances between documents and retrieve similar data.

The raw data (books, articles, blogs, pictures, or songs) is first collected and cleaned to remove noise. The prepared data is then fed into a model such as OpenAI text-embedding-3-small, which will embed the data. Activeloop Deep Lake, for example, which we will implement in this chapter, will break a text down into pre-defined chunks defined by a certain number of characters. The size of a chunk could be 1,000 characters, for instance. We can let the system optimize these chunks, as we will implement them in the Optimizing chunking section of the next chapter. These chunks of text make it easier to process large amounts of data and provide more detailed embeddings of a document, as shown here:

A diagram of a number and embedding

Description automatically generated with medium confidence

Figure 2.1: Excerpt of an Activeloop vector store dataset record

Transparency has been the holy grail in AI since the beginning of parametric models, in which the information is buried in learned parameters that produce black box systems. RAG is a game changer, as shown in Figure 2.1, because the content is fully traceable:

  • Left side (Text): In RAG frameworks, every piece of generated content is traceable back to its source data, ensuring the output’s transparency. The OpenAI generative model will respond, taking the augmented input into account.
  • Right side (Embeddings): Data embeddings are directly visible and linked to the text, contrasting with parametric models where data origins are encoded within model parameters.

Once we have our text and embeddings, the next step is to store them efficiently for quick retrieval. This is where vector stores come into play. A vector store is a specialized database designed to handle high-dimensional data like embeddings. We can create datasets on serverless platforms such as Activeloop, as shown in Figure 2.2. We can create and access them in code through an API, as we will do in the Building a RAG pipeline section of this chapter.

A screenshot of a computer

Description automatically generated

Figure 2.2: Managing datasets with vector stores

Another feature of vector stores is their ability to retrieve data with optimized methods. Vector stores are built with powerful indexing methods, which we will discuss in the next chapter. This retrieving capacity allows a RAG model to quickly find and retrieve the most relevant embeddings during the generation phase, augment user inputs, and increase the model’s ability to produce high-quality output.

We will now see how to organize a RAG pipeline that goes from data collection, processing, and retrieval to augmented-input generation.

You have been reading a chapter from
RAG-Driven Generative AI
Published in: Sep 2024
Publisher: Packt
ISBN-13: 9781836200918
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image