published fresh until

Ragas: Generate a testset from LangChain documents

Summary As of November 2026, load Markdown documents with DirectoryLoader, wrap the generation model, and generate a ten-item Ragas testset for review as a DataFrame. Start with pip install langchain-community

Not for scoring retrieval and answer quality; see ragas-score-retrieval-and-answer-quality.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: Run pip install langchain-community.

When you need it

Use this to generate synthetic evaluation data from documents for a RAG pipeline. The page's quickstart loads Markdown documents and generates a testset that you can review before selecting queries.

Steps

1. Install the document loader and the OpenAI integration shown on the page:

pip install langchain-community
pip install langchain-openai

2. Obtain the page's sample documents:

git clone https://huggingface.co/datasets/vibrantlabsai/Sample_Docs_Markdown

3. Load the Markdown files:

from langchain_community.document_loaders import DirectoryLoader
path = "Sample_Docs_Markdown/"
loader = DirectoryLoader(path, glob="**/*.md")
docs = loader.load()

4. Make OPENAI_API_KEY available in the environment as the page requires. Initialize its OpenAI generation model and embeddings:

from ragas.llms import LangchainLLMWrapper
from langchain_openai import ChatOpenAI
from ragas.embeddings import OpenAIEmbeddings
import openai

generator_llm = LangchainLLMWrapper(ChatOpenAI(model="gpt-4o"))
openai_client = openai.OpenAI()
generator_embeddings = OpenAIEmbeddings(client=openai_client)

5. Generate the testset with the page's example size:

from ragas.testset import TestsetGenerator

generator = TestsetGenerator(llm=generator_llm, embedding_model=generator_embeddings)
dataset = generator.generate_with_langchain_docs(docs, testset_size=10)

Check it worked

Use the page's inspection call and review the generated queries to select those suitable for the final testset:

dataset.to_pandas()

Limits

The OpenAI example requires OPENAI_API_KEY. For documents loaded with llama_index, the page directs you to generate_with_llama_index_docs instead. The sample documents may be replaced with your own documents. The page does not name a version of Ragas for this procedure.

Not for: scoring retrieval and answer quality; see ragas-score-retrieval-and-answer-quality.

Sources

Checked

2026-11-24; read <https://docs.ragas.io/en/stable/getstarted/rag_testset_generation/>; no command was run.

Started from a post by @Ragas, packaged by the editor. Original post

Subjects

More in testing

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Ragas: Generate a testset from LangChain documents
Summary: As of November 2026, load Markdown documents with DirectoryLoader, wrap the generation model, and generate a ten-item Ragas testset for review as a DataFrame. Start with pip install langchain-community
Copy for agent
get the whatworks thread ragas-generate-testset-from-langchain-documents and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread ragas-generate-testset-from-langchain-documents
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp