Agent Skillslangwatch/langwatch › generate-rag-dataset

generate-rag-dataset

GitHub

分析RAG知识库内容,生成包含多种题型(事实、推理、边界等)的合成评估数据集。支持导出为CSV或DataFrame格式,用于LangWatch平台导入及测试数据准备,确保答案与上下文一致且覆盖全面。

skills/_compiled/native/generate-rag-dataset/SKILL.md langwatch/langwatch

Trigger Scenarios

需要为RAG管道生成测试数据 准备LangWatch实验所需的评估数据集 构建RAG系统的合成问答对

Install

npx skills add langwatch/langwatch --skill generate-rag-dataset -g -y
More Options

Non-standard path

npx skills add https://github.com/langwatch/langwatch/tree/main/skills/_compiled/native/generate-rag-dataset -g -y

Use without installing

npx skills use langwatch/langwatch@generate-rag-dataset

指定 Agent (Claude Code)

npx skills add langwatch/langwatch --skill generate-rag-dataset -a claude-code -g -y

安装 repo 全部 skill

npx skills add langwatch/langwatch --all -g -y

预览 repo 内 skill

npx skills add langwatch/langwatch --list

SKILL.md

Frontmatter
{
    "name": "generate-rag-dataset",
    "license": "MIT",
    "metadata": {
        "category": "recipe"
    },
    "description": "Generate a synthetic evaluation dataset from your RAG knowledge base. Creates diverse Q&A pairs with expected answers and relevant context, ready for LangWatch experiments and platform import. Use when you need test data for your RAG pipeline.",
    "compatibility": "Requires LangWatch SDK. Works with Claude Code and similar coding agents."
}

Generate a RAG Evaluation Dataset

This recipe analyzes your RAG knowledge base and generates a comprehensive Q&A evaluation dataset.

Step 1: Analyze the Knowledge Base

Read the codebase to find the knowledge base:

  • Document files (PDFs, markdown, text files)
  • Database schemas (if documents are stored in a DB)
  • Vector store configuration (what's being embedded)
  • Chunking strategy (how documents are split)

Read every document you can access. Understand:

  • What topics does the knowledge base cover?
  • What's the depth of information?
  • What terminology is used?
  • What are the boundaries (what's NOT covered)?

Step 2: Generate Diverse Question Types

Create questions across these categories:

Factual Recall

Direct questions answerable from a single passage:

  • "What is the recommended threshold for X?"
  • "When should Y be applied?"

Multi-Hop Reasoning

Questions requiring information from multiple passages:

  • "Given condition A and condition B, what should be done?"
  • "How do X and Y interact when Z occurs?"

Comparison

Questions comparing concepts within the knowledge base:

  • "What's the difference between approach A and approach B?"
  • "When should you use X instead of Y?"

Edge Cases

Questions about boundary conditions or unusual scenarios:

  • "What happens if the measurement is outside normal range?"
  • "What if two recommendations conflict?"

Negative Cases

Questions about topics NOT covered by the knowledge base:

  • "Does the system support Z?" (when it doesn't)
  • Questions requiring external knowledge the KB doesn't have

These help test that the agent correctly says "I don't know" rather than hallucinating.

Step 3: Include Context Per Row

For each Q&A pair, include the relevant document chunk(s) that contain the answer. This enables:

  • Platform experiments without the full RAG pipeline
  • Evaluating answer quality independent of retrieval quality
  • Testing with different prompts using the same retrieved context

Format:

{
    "input": "When should I irrigate apple orchards?",
    "expected_output": "Irrigate to maintain soil moisture between 25-35 kPa...",
    "context": "## Irrigation Management\nSoil moisture threshold for apple orchards: maintain between 25-35 kPa...",
    "question_type": "factual_recall"
}

Step 4: Export Formats

Create both:

Python DataFrame (for SDK experiments)

import pandas as pd
df = pd.DataFrame(dataset)
df.to_csv("rag_evaluation_dataset.csv", index=False)

Platform-Ready CSV

Export with columns: input, expected_output, context, question_type This can be imported directly into LangWatch platform datasets.

Step 5: Validate Dataset Quality

Before using the dataset:

  1. Check topic coverage: are all knowledge base topics represented?
  2. Verify answers are actually in the context, with no hallucinated expected outputs
  3. Check question diversity: not all the same type
  4. Verify negative cases have appropriate "I don't know" expected outputs
  5. Run a quick experiment to baseline accuracy

Common Mistakes

  • Do NOT generate questions without reading the actual knowledge base first
  • Do NOT skip negative cases. Testing "I don't know" is crucial for RAG
  • Do NOT use the same question pattern for every entry. Diversify types
  • Do NOT forget to include the relevant context per row
  • Do NOT generate expected outputs that aren't actually in the knowledge base

Version History

  • 12615f1 Current 2026-08-20 10:01

Same Skill Collection

.claude/skills/browser-pair/SKILL.md
.claude/skills/browser-test/SKILL.md
.claude/skills/code-review/SKILL.md
.claude/skills/feature-map/SKILL.md
.claude/skills/haven-setup/SKILL.md
.claude/skills/langwatch-kanban/SKILL.md
plugins/langwatch/skills/langwatch/SKILL.md
services/langy-agent/skills/github/SKILL.md
skills/_compiled/native/agent-best-practices/SKILL.md
skills/_compiled/native/agent-performance/SKILL.md
skills/_compiled/native/connect-agent/SKILL.md
skills/_compiled/native/datasets/SKILL.md
skills/_compiled/native/debug-instrumentation/SKILL.md
skills/_compiled/native/debug-with-langwatch/SKILL.md
skills/_compiled/native/eval-triage/SKILL.md
skills/_compiled/native/evaluate-multimodal/SKILL.md
skills/_compiled/native/evaluations/SKILL.md
skills/_compiled/native/experiments/SKILL.md
skills/_compiled/native/github/SKILL.md
skills/_compiled/native/level-up/SKILL.md
skills/_compiled/native/online-evaluations/SKILL.md
skills/_compiled/native/prompts/SKILL.md
skills/_compiled/native/scenarios/SKILL.md
skills/_compiled/native/setup-lw/SKILL.md
skills/_compiled/native/test-cli-usability/SKILL.md
skills/_compiled/native/test-compliance/SKILL.md
skills/_compiled/native/tracing/SKILL.md

Metadata

Files
0
Version
12615f1
Hash
34278d5b
Indexed
2026-08-20 10:01

Home - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-21 13:56
浙ICP备14020137号-1 $Map of visitor$