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
- Host: GitHub
- URL: https://github.com/explore-de/rage4j
- Owner: explore-de
- License: mit
- Created: 2024-12-18T09:07:39.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2026-05-09T16:42:42.000Z (about 2 months ago)
- Last Synced: 2026-05-09T18:31:22.941Z (about 2 months ago)
- Topics: ai, evaluation, java, junit, langchain4j, llm, testing
- Language: Java
- Homepage: https://explore-de.github.io/rage4j/
- Size: 4.33 MB
- Stars: 12
- Watchers: 2
- Forks: 2
- Open Issues: 20
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-java - Rage4J
README
[](https://sonarcloud.io/summary/new_code?id=explore-de_rage4j)
[](https://github.com/explore-de/rage4j/actions/workflows/docusaurus.yml)
# 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
💻

Michael Hainz
💻

Vladislav Knyshov
💻

Markus Herhoffer
📆

Aamin Gem
💻

DrBilip
💻

Andreas Dinauer
💻

Klaus-Martin Fink
💻

andresCh01
💻

Hubertus Seitz
💻