Notebooks
W
Weaviate
RetrievalAugmentedGeneration Weaviate

RetrievalAugmentedGeneration Weaviate

vector-searchvector-databaseretrieval-augmented-generationllm-frameworksfunction-callingweaviate-recipesintegrationssemantic-kernelPythongenerative-aillm-agent-frameworks

Open In Colab

Introduction - Retrieval Augmented Generation using Weaviate and SK

Implements a simple workflow of retrieve then generate. Using semantic kernel to help with prompt engineering and orchestrating interactions with LLMs and Weaviate as a knowledge-base from which to retreive semantically relevant context.

This allows us to not only control what is being generated but also cite sources along with the relevance of those sources.

Setup

[ ]

OS-specific notes:

  • if you run into SSL errors when connecting to OpenAI on macOS, see this issue for a potential solution
  • on Windows, you may need to run Docker Desktop as administrator
[1]
[2]

Then, we register the memory store to the kernel:

[3]
{'recall': <semantic_kernel.orchestration.sk_function.SKFunction at 0x12affab10>,
, 'save': <semantic_kernel.orchestration.sk_function.SKFunction at 0x12affbe10>}

First with no RAG, just Generate:

[4]


That depends on you! Do you have any pets?

Add some prompt engineering:

[6]

I don't know.

Manually adding memories

Let's create some initial memories "About Me". We can add memories to our weaviate memory store by using save_information_async

[10]
[11]
[12]
Sucessfully populated memories!
[14]
Retreived document: When I turned 5 my parents gifted me goldfish for my birthday
[15]
0.891325980424881
[16]
[18]

Q&A powered by RAG!

[19]
Setup Q&A with memory!
Ask a question (type 'exit' to exit):

User:> What did my parents get me?

ChatBot:> 

It sounds like your parents got you a goldfish for your birthday when you were 5! 

 Source: When I turned 5 my parents gifted me goldfish for my birthday
 Relevance: 0.9213910102844238