Prerequisites
- A SambaCloud account and API key
- Python 3.9 or later
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 thellm 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’sDataset 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
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:
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
ModuleNotFoundError: No module named 'langchain_community.chat_models.vertexai'
ModuleNotFoundError: No module named 'langchain_community.chat_models.vertexai'
You skipped the pinned
langchain-community install in Setup. Run pip install "langchain-community==0.3.30" --no-deps.KeyError: SAMBANOVA_API_KEY
KeyError: SAMBANOVA_API_KEY
Export the key before running:
export SAMBANOVA_API_KEY="your-key". Verify with echo $SAMBANOVA_API_KEY.Judge always returns the same value regardless of input
Judge always returns the same value regardless of input
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.
TestsetGenerator raises an error with no embedding model configured
TestsetGenerator raises an error with no embedding model configured
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.

