Eval datasets in RedDB — from ad-hoc prompts to versioned regression sets
Store evaluation cases and run outputs in RedDB so you can retrieve a named dataset and compare results in your application.
On this page
Keep evaluation cases and results together
An evaluation is easier to repeat when its input cases and run outputs are stored separately. This example creates two small RedDB tables: one for cases in a named dataset and one for the outputs produced by a model. The evaluation runner and comparison logic belong in your application.
The commands below were tested with RedDB 1.26.8 through its HTTP query endpoint. They do not require PostgreSQL-specific types, extensions, or functions.
Start a local database
red server --http-bind 127.0.0.1:5000 --path ./evals.rdb --dev--dev disables authentication and is for a trusted local machine only. In a second terminal, create a helper using curl and jq:
query() {
curl -fsS http://127.0.0.1:5000/query \
-H 'content-type: application/json' \
--data "$(jq -cn --arg query "$1" '{query: $query}')"
}Store and retrieve a case
query 'CREATE TABLE eval_cases (id TEXT, dataset TEXT, prompt TEXT, expected TEXT)'
query "INSERT INTO eval_cases (id, dataset, prompt, expected) VALUES ('case-001', 'core-v1', 'What is 2 + 2?', '4')"
query "SELECT id, prompt, expected FROM eval_cases WHERE dataset = 'core-v1'"The query response contains the case’s ID, prompt and expected answer. Your runner can read the cases in core-v1, call the model you want to evaluate, and compare each output with the expected answer using your chosen scoring method.
Save an evaluation output
query 'CREATE TABLE eval_runs (id TEXT, dataset TEXT, case_id TEXT, model TEXT, output TEXT)'
query "INSERT INTO eval_runs (id, dataset, case_id, model, output) VALUES ('run-001', 'core-v1', 'case-001', 'example-model', '4')"
query "SELECT id, case_id, model, output FROM eval_runs WHERE dataset = 'core-v1'"Use an application-generated unique ID for every case and result. The example values are fixed to keep the SQL readable. In a real application, use parameterized queries and do not concatenate untrusted prompts into SQL.
Make comparisons repeatable
Treat core-v1 as a name chosen by your application, not as an automatic snapshot. To keep an evaluation repeatable, preserve the cases for a dataset version and create a new version when cases change. Record the model version, prompt configuration and scoring rules alongside your results in your own schema.
This example does not implement dataset immutability, model calls, scoring or parallel workers. Test those pieces and your backup and restore process for your deployment before using the results to make release decisions.
Ready to build with RedDB?
Create an account and explore the Always Free database.
Create your account →