Get startedGet started for free

RAG Workflows with Weaviate

1. RAG Workflows with Weaviate

Welcome back!

2. Looking back...

In the last chapter, you successfully perform RAG by-hand: embedding a series of texts and a search query, performing a cosine distance calculation to determine their similarity, retrieving the most similar texts, and inserting them into a prompt for a generative model.

3. Coming up!

In this chapter, we'll use Weaviate to embed and store our embeddings for a more scalable and efficient solution. Additionally, we'll use Weaviate to orchestrate the RAG workflow using a higher-level syntax than that we've used up to this point. Now we have better tools at our disposal, we may as well upgrade the data, too!

4. From strings to PDFs

Now, we'll embed and store PDF documents rather than simple strings. PDFs contain more diverse data structures, including headings, tables, and images. In this chapter, we'll focus on just the text content, but we'll include images in Chapter 3. We'll use the docling library to convert the PDF files into markdown files, which contain raw text with additional character formatting for headers and tables. This system will allow us to ask questions requiring a document or series of documents, and receive smart, informed responses from the generative model.

5. Back to the "R" in RAG

The retrieval piece of the RAG workflow is the most nuanced, so we'll take a bit of time to discuss different strategies to search for and retrieve relevant documents.

6. Searching with vectors

Previously, we searched using vectors, embedding a search query like "retrieval augmented generation", and comparing its cosine distance to a series of embedded strings or documents to return the closest. Vector search is "smart" in the sense that synonyms, typos, and alternative wordings should produce the same or similar documents. This makes it a great choice for messy user inputs.

7. Searching with keywords

There are also keyword searches, which use the frequency that search terms are used across documents to determine which are the most relevant. Keyword searches are often simpler and reward exact matches, but are much less flexible to messy user inputs as we saw before.

8. The best of both words: hybrid search

However, you can have the best of both worlds. A hybrid approach performs both searches simultaneously, and then weights the rankings based on a value, alpha. This alpha value is essentially used to assign greater value to vector or keyword results. Ultimately, the best approach is the one that gives the best results for your use case.

9. Let's practice!

In the exercises, you'll have the chance to experiment with all three. See you there!

Create Your Free Account

or

By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.