Database / Weaviate Vector database Interview questions
How do you implement RAG using Weaviate's generative search module?
Implementing RAG with Weaviate's built-in generative search means configuring a generative module on the collection, then using one of the generate-family query methods to combine retrieval and generation in a single call, rather than manually orchestrating a separate retrieval step and a separate LLM call.
client.collections.create( name="SupportArticles", vector_config=Configure.Vectors.text2vec_openai(), generative_config=Configure.Generative.openai(model="gpt-4o-mini"), ) collection = client.collections.get("SupportArticles") response = collection.generate.near_text( query="how do I reset my password", grouped_task="Using the retrieved articles, write a concise step-by-step answer.", limit=3 ) print(response.generated)
The near_text call first retrieves the three most relevant articles via vector search, then passes them (as context) to the configured generative module along with the grouped_task instruction, and returns a single synthesized answer grounded in that retrieved content. This pattern, sometimes called "grouped generation," produces one combined answer across all retrieved results, distinct from a "single prompt" mode that instead generates a separate response per individual retrieved object.
More Related questions...