An open API service indexing awesome lists of open source software.

https://github.com/explore-de/rage4j

Evaluate your LLM based Java Apps
https://github.com/explore-de/rage4j

ai evaluation java junit langchain4j llm testing

Last synced: 26 days ago
JSON representation

Evaluate your LLM based Java Apps

Awesome Lists containing this project

README

          

[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=explore-de_rage4j&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=explore-de_rage4j)
[![Docusaurus Build And Deploy](https://github.com/explore-de/rage4j/actions/workflows/docusaurus.yml/badge.svg)](https://github.com/explore-de/rage4j/actions/workflows/docusaurus.yml)


rage4j

# Rage4J

RAG Evaluation library for Java.

## Overview

Rage4J provides tools to evaluate and measure the quality of language model outputs using various metrics like correctness, relevance, faithfulness, and semantic similarity. It integrates with LangChain4j and supports fluent test assertions for RAG pipelines.

**Modules:**
- **rage4j** - Core evaluation library with evaluators and model classes
- **rage4j-assert** - Fluent assertion library for RAG evaluation in tests
- **rage4j-persist** - Persistence module for saving evaluation results (JSONL format)
- **rage4j-persist-junit5** - JUnit 5 extension for automatic persistence lifecycle

## Installation

Add the dependency to your `pom.xml`:

```xml

dev.rage4j
rage4j
2.0.1-SNAPSHOT

```

For fluent test assertions:

```xml

dev.rage4j
rage4j-assert
2.0.1-SNAPSHOT
test

```

## Usage

### Core Evaluation

```java
Sample sample = Sample.builder()
.withQuestion("What is the capital of France?")
.withAnswer("Paris is the capital of France.")
.withGroundTruth("Paris")
.build();

Evaluator evaluator = new AnswerCorrectnessEvaluator(chatModel);
Evaluation result = evaluator.evaluate(sample);
System.out.println(result.getName() + ": " + result.getValue());
```

### Fluent Assertions

```java
RageAssert rageAssert = new OpenAiLLMBuilder().fromApiKey(apiKey);

rageAssert.given()
.question("What is the capital of France?")
.groundTruth("Paris")
.context("Paris is the capital of France.")
.when()
.answer("Paris is the capital of France.")
.then()
.assertFaithfulness(0.7)
.then()
.assertAnswerCorrectness(0.8);
```

## Documentation

Visit our documentation on Github Pages: Visit Docs

## Requirements

- Java 21
- Maven (wrapper included: `./mvnw`)

For development, use the code formatter (`./mvnw formatter:format`) and install the EditorConfig extension (IntelliJ has built-in support).

## Contributors



richard
richard

💻
Michael Hainz
Michael Hainz

💻
Vladislav Knyshov
Vladislav Knyshov

💻
Markus Herhoffer
Markus Herhoffer

📆
Aamin Gem
Aamin Gem

💻
DrBilip
DrBilip

💻
Andreas Dinauer
Andreas Dinauer

💻


Klaus-Martin Fink
Klaus-Martin Fink

💻
andresCh01
andresCh01

💻
Hubertus Seitz
Hubertus Seitz

💻