Skip to main content
Ragas is a metric library for evaluating RAG pipelines. Judge-model calls are the core of how it scores responses, so a fast judge directly speeds up every evaluation run.

Prerequisites

Setup

1

Install Ragas

Ragas 0.4.3 imports a langchain-community module that newer releases removed, so the second command pins that package. Keep --no-deps so pip doesn’t downgrade langchain-core. pip check then reports that langchain-community requires dataclasses-json. Ragas still runs, so you can ignore that warning.
2

Export your SambaCloud API key

3

Point Ragas's judge model at SambaCloud

Ragas’s llm_factory accepts any OpenAI client instance, including one configured with a custom base_url:

Metrics

Ragas groups its LLM-judged metrics into three output shapes. Each example below uses the llm from Setup.

Discrete: a correct/incorrect verdict

Score a correct and an incorrect answer to check that the judge tells them apart:
Output

Numeric: a score on a continuous scale

Output

Ranking: ordering multiple candidate responses

Output

Datasets and experiments

Ragas’s Dataset and @experiment give you a repeatable way to run a batch of inputs through your system and score every result, instead of calling a metric one example at a time. This example uses client and llm from Setup and metric from the Discrete example.
Output
Each row runs one SambaCloud chat completion and one DiscreteMetric judge call. dataset.save() writes ragas_data/datasets/capitals.csv, and arun() writes the scored results to a CSV with a randomly generated name under ragas_data/experiments/, so you can compare experiment runs later.

Not covered: synthetic test data generation

Ragas’s RAG test set generation (TestsetGenerator) builds synthetic queries and reference answers from your own documents via a knowledge graph. Unlike every example above, it requires both an LLM and an embedding model:
SambaCloud has no embedding model, so this feature can’t run on SambaCloud alone. Embedding models such as E5-Mistral-7B-Instruct are available on SambaStack. See Embeddings. If you need synthetic test data generation, pair your SambaStack instance’s embedding model with a SambaCloud or SambaStack LLM for this one feature, and use SambaCloud for everything else on this page.

Troubleshooting

You skipped the pinned langchain-community install in Setup. Run pip install "langchain-community==0.3.30" --no-deps.
Export the key before running: export SAMBANOVA_API_KEY="your-key". Verify with echo $SAMBANOVA_API_KEY.
Test both a correct and a deliberately incorrect response against your metric before trusting it in a real eval run, as shown in the Discrete example above. A judge that doesn’t discriminate is not providing a useful signal, whatever its stated score.
Expected: synthetic test data generation needs an embedding model, which SambaCloud doesn’t provide. See Not covered above and use your SambaStack instance’s embedding model for this feature specifically.

Additional resources