ragas README

The project's README from github.com/vibrantlabsai/ragas. As one markdown file: README.md.

Supercharge Your LLM Application Evaluations 🚀

Latest release Made with Python License Apache-2.0 Ragas Downloads per month Join Ragas community on Discord Ask DeepWiki.com

Documentation | Quick start | Join Discord | Blog | NewsLetter | Careers

Objective metrics, intelligent test generation, and data-driven insights for LLM apps

Ragas is your ultimate toolkit for evaluating and optimizing Large Language Model (LLM) applications. Say goodbye to time-consuming, subjective assessments and hello to data-driven, efficient evaluation workflows. Don't have a test dataset ready? We also do production-aligned test set generation.

Key Features

:shield: Installation

Pypi:

pip install ragas

Alternatively, from source:

pip install git+https://github.com/vibrantlabsai/ragas

:fire: Quickstart

Clone a Complete Example Project

The fastest way to get started is to use the ragas quickstart command:

# List available templates
ragas quickstart

# Create a RAG evaluation project
ragas quickstart rag_eval

# Specify where you want to create it.
ragas quickstart rag_eval -o ./my-project

Available templates:

Coming Soon:

Evaluate your LLM App

ragas comes with pre-built metrics for common evaluation tasks. For example, Aspect Critique evaluates any aspect of your output using DiscreteMetric:

import asyncio
from openai import AsyncOpenAI
from ragas.metrics import DiscreteMetric
from ragas.llms import llm_factory

# Setup your LLM
client = AsyncOpenAI()
llm = llm_factory("gpt-4o", client=client)

# Create a custom aspect evaluator
metric = DiscreteMetric(
    name="summary_accuracy",
    allowed_values=["accurate", "inaccurate"],
    prompt="""Evaluate if the summary is accurate and captures key information.

Response: {response}

Answer with only 'accurate' or 'inaccurate'."""
)

# Score your application's output
async def main():
    score = await metric.ascore(
        llm=llm,
        response="The summary of the text is..."
    )
    print(f"Score: {score.value}")  # 'accurate' or 'inaccurate'
    print(f"Reason: {score.reason}")


if __name__ == "__main__":
    asyncio.run(main())

Note: Make sure your OPENAI_API_KEY environment variable is set.

Find the complete Quickstart Guide

Want help in improving your AI application using evals?

In the past 2 years, we have seen and helped improve many AI applications using evals. If you want help with improving and scaling up your AI application using evals.

🔗 Book a slot or drop us a line: [email protected].

🫂 Community

If you want to get more involved with Ragas, check out our discord server. It's a fun community where we geek out about LLM, Retrieval, Production issues, and more.

Contributors

+----------------------------------------------------------------------------+
|     +----------------------------------------------------------------+     |
|     | Developers: Those who built with `ragas`.                      |     |
|     | (You have `import ragas` somewhere in your project)            |     |
|     |     +----------------------------------------------------+     |     |
|     |     | Contributors: Those who make `ragas` better.       |     |     |
|     |     | (You make PR to this repo)                         |     |     |
|     |     +----------------------------------------------------+     |     |
|     +----------------------------------------------------------------+     |
+----------------------------------------------------------------------------+

We welcome contributions from the community! Whether it's bug fixes, feature additions, or documentation improvements, your input is valuable.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

🔍 Open Analytics

At Ragas, we believe in transparency. We collect minimal, anonymized usage data to improve our product and guide our development efforts.

✅ No personal or company-identifying information

✅ Open-source data collection code

✅ Publicly available aggregated data

To opt-out, set the RAGAS_DO_NOT_TRACK environment variable to true.

Cite Us

@misc{ragas2024,
  author       = {VibrantLabs},
  title        = {Ragas: Supercharge Your LLM Application Evaluations},
  year         = {2024},
  howpublished = {\url{https://github.com/vibrantlabsai/ragas}},
}

ragas (vibrantlabsai/ragas)

Searching Database…

16.1K ·GitHub
这是干什么用的?Ragas 是一个开源的 Python 工具包,用于评估和优化 LLM 应用:它用客观的指标、自动生成的测试集和数据驱动的洞察,取代缓慢、主观的人工评估。
它是在我自己的代码里调用的库,还是一个托管平台?它是一个 Python 库:从 PyPI 安装(或者从源码构建)到你自己的项目里就能用。它还附带一个小的命令行工具,'ragas quickstart' 命令可以生成一个完整的示例项目。
我怎么开始上手?先用 pip 安装,导出你的 OPENAI_API_KEY,然后运行 'ragas quickstart' —— 它会克隆一个可以直接运行的评价项目;目前提供的模板是 rageval,用于评估 RAG 系统。
运行评估需要 OpenAI 的 API 密钥吗?跑 quickstart 需要的:README 会提醒你设置 OPENAI_API_KEY 环境变量,因为其中一些指标是基于 LLM 的,底层会调用模型。
它能不能评估 AI 智能体,还是目前只支持 RAG?现成的支持以 RAG 为主:rageval 目前评估的是 RAG 系统;而智能体评估、提示词变体、工作流评估和 LLM 基准测试的模板还标注着'即将推出'。
它会收集我的使用数据吗?会,默认会收集少量匿名化的使用统计,用于改进产品;收集代码是开源的,汇总数据也是公开的。设置 RAGAS_DO_NOT_TRACK=true 即可关闭。
它能对接哪些框架和工具?它宣称与 LangChain 等流行的 LLM 框架以及主流的可观测性工具无缝集成,可以直接接入你的应用已经在用的技术栈。
我还没有测试数据集怎么办?Ragas 会帮你生成:它能自动构建覆盖多种场景、贴近生产环境的综合测试数据集,让你在收集到真实数据之前就能开始评估。
内置了哪些类型的指标?针对常见评估任务提供了现成的指标,既有基于 LLM 的,也有传统指标 —— 例如 Aspect Critique 使用 DiscreteMetric 对你输出的任意方面打分。
为什么不用我自己肉眼看模型输出就行?人工评估既耗时又主观;Ragas 用客观指标、自动生成的测试数据和来自生产环境的反馈闭环来取代它,让你的 LLM 应用持续改进。
Size
46.4 MB
Stars
16.1K
Age
3y
Commits · 90 Days