Skip to main content
In this guide we will see how to automatically generate tests with KnwoledgeBase. Knowledge Bases is a database with a collection of documents. This is usually used in RAG applications as the vector database to store the documents and the embeddings.

Configure the Knowledge Base

For teaching purposes we will use a dummy knowledge base that will store the documents in memory. As you can see each document is grouped by a topic. So we can generate better questions for each topic.

Generate Functional Questions

Now we can generate questions for each topic. We use RAGProbe together with EvaluationScenario and AnswerRelevanceEvaluator for functional evaluation. In this configuration we will generate 2 questions, one for each topic. And we will use the BenignQuestion.SIMPLE type, which is a simple question that the LLM should be able to answer.
Then we only need to create the test_set and check the results.

Generate RAG Poisoning Tests

We can also automatically generate poisoning tests based to attack specific information domains. We just need to change the question_types to MaliciousQuestion and use RAGPoisoningEvaluator.

Complete Examples