Testing LLMs and Databricks platforms for regulated use

I built two products end to end that qualify an LLM deployment or a Databricks platform for regulated (GxP) use, with tests scored on the customer’s thresholds, versioned platform checks and a signed report.

Context
Purgo AI, 2025–present
Read
6 min
Updated
Built with
TypeScript, NestJS, Next.js, PostgreSQL, Python, Azure OpenAI, Databricks, AWS, GCP Cloud Run

My part

  • Built the LLM validation product end to end (UI, API and test engine)
  • Wrote the Databricks validation engine and all 59 of its test definitions
  • Wrote the pipeline that turns requirements into platform tests
  • Built both products’ screens and run scheduling on the company’s web platform, and the LLM product’s job tracking
  • Wrote both products’ PDF reports and the DocuSign signing flow

The company’s base web platform was there before me.

Life-sciences companies must qualify an AI model or a data platform before they use it in regulated work. Under their quality rules (GxP), that means showing, with evidence, that it was installed as specified (installation qualification, or IQ) and works as intended (operational qualification, or OQ).

I built the two products Purgo’s customers use to run those checks and produce the report they sign for their auditors. Both run on the company’s web platform.

The two products, and why each has its own engine
What differsLLM productPlatform product
It qualifiesA customer’s model on Azure OpenAI or served from DatabricksA customer’s Databricks workspace on Azure or AWS
Built-in tests19: 10 operational and 9 installation59 versioned definitions
A test isCode in the engineData the engine reads: a chain of API calls
A test passes whenA measured value meets one of 26 thresholds the customer setsThe chain’s last function returns a pass

I made three decisions that shaped both products: the LLM tests avoid judging prose, the platform tests are data and not code, and generated tests must compile against the real API before a reviewer sees them.

How the products fit together

The parts of both products

A qualification run

  1. The product screens: settings, runs, scheduling, review, signing; on the company’s web platform (I built this)
  2. The platform API: extended for both products: jobs, project settings with encrypted secrets, saved custom tests (I reworked this)
  3. Two test engines:
    • The LLM engine: 19 tests written as code (I built this)
    • The Databricks engine: 59 versioned definitions read as data (I built this)
  4. What they test:
    • The customer’s model on Azure OpenAI or Databricks (not mine)
    • The customer’s Databricks workspace on Azure or AWS (not mine)

After the run

  1. A report service renders the PDF (I built this)
  2. Stored on the job (not mine)
  3. Person: Signed in the app with embedded DocuSign (I built this)

A run goes through one of two engines, and both end in the same report and signing steps.

I builtI reworkedNot mineA person decides

A run can take many minutes, since starting a cluster alone can take a quarter of an hour, so neither engine makes the caller wait. Each one is stateless: it answers at once with a job ID, pushes results after every test, and checks before each test whether the user has stopped the run.

LLM tests that avoid judging prose

The LLM validation product is the newer of the two, and I built it end to end: the UI, the API and the test engine. Its 19 tests are code, unlike the platform product’s definitions below, because each one needs datasets, concurrent calls, statistics and sometimes a second model to grade the answers.

Ten operational (OQ) tests run the model on fixed datasets and compare the results with thresholds the customer sets. Judging free text is the hard part, so the tests avoid comparing prose. The determinism and bias tests make the model answer in JSON with fixed keys and closed lists of answers. The determinism test looks for the same JSON every time, and the bias test looks for the same answer across a case’s four demographic variants. Where prose can’t be avoided, a separate judge model grades it against a checklist; the judge is never the model under test.

Seven of the ten operational tests: what each one catches, and how
TestWhat it catchesHow it is checked
HallucinationInventing a value the source doesn’t contain40 cases with fields missing from the text
Extraction accuracyWrong values in extracted fieldsF1 for each field, against labeled narratives
ClassificationMisclassified complaints and triage levelsAccuracy against labeled cases
DeterminismDifferent answers to the same input20 runs of one input must return the same JSON
Latency under concurrencyFailed or slow calls40 requests from 20 concurrent workers
Demographic biasDifferent outputs when only the demographics in a case change5 scenarios, each in four demographic variants
TraceabilityA response that can’t be traced back to the model and the request that produced itEach response must carry a completion ID, a model ID and a timestamp

Nine installation (IQ) tests read how an Azure deployment is set up: region, pinned model version, authentication, access, private networking and audit logging. All 26 thresholds are the customer’s, and every check records its threshold next to the measured value.

Platform tests as data, not code

The platform product checks that a customer’s Databricks workspace is set up and behaves as specified: catalog setup, access control and audit logging, cluster behavior, network and security-group settings, lineage and data sharing. Its engine has 59 versioned test definitions, running on Azure, AWS or both. I wrote the engine and every definition.

A test is a definition the engine reads, not code built into the engine. Each definition is a chain of API calls against the customer’s own workspace, with a small function after each call and one at the end that decides the result.

One negative test, from its definition to the report

A definition that checks that a user without access is refused

  1. A step calls the API as a second identity that lacks access: method, URL, headers and body, filled in from the run’s variables (I built this)
  2. 403: A short function reads the response: and adds variables for later steps: an ID to poll, a statement to check (I built this)
  3. A last function reads every step and returns:
    • Expected: access denied (I built this)
    • Actual: access denied, status 403 (I built this)
    • Result: pass (I built this)
  4. The report prints the test’s description and a manual procedure: so a person could repeat it by hand (I built this)

The engine treats the 403 as a result, not an error, and it is the result this test expects.

Each step carries a small function instead of a fixed assertion, because real checks wait and branch: start a cluster, poll until it runs, query, check, clean up. Every HTTP status is a result, since many tests are negative. Each function runs in an isolated scope. On AWS the engine signs each request itself, which lets one executor serve both clouds.

The definitions live in their own repository and every run clones the current version, so a fix goes live without a redeploy. The report records the version it ran, so every result can be traced to the exact version of the tests that produced it, and that is how changes to the tests are controlled.

Generating tests from requirements

I built a pipeline that turns a customer’s requirements document into tests in the same format as the built-in ones, so the new tests run alongside them.

From a requirements document to tests that run in every qualification

Writing tests from requirements

  1. A requirements document: PDF, DOCX or text (the customer’s)
  2. An LLM pulls out up to 8 testable statements: rewrites or drops ones that can’t be checked (I built this)
  3. An LLM writes a test for each, in parallel: from 5 real tests in the library (I built this)
  4. Checks: required fields, and the code compiles: fails: one retry with the errors (I built this)
  5. Person: A reviewer edits, removes or regenerates each one: with their feedback (I built this)

Running a qualification

  1. Saved with the project (I built this)
  2. Runs as its own suite next to the built‑in tests (I built this)
  3. Same engine, same evidence, same report (I built this)

Nothing an LLM writes runs until it has passed the checks and a person has reviewed it.

I builtThe customer’sA person decides

A generated test stays a proposal until it has passed the checks and a person has reviewed it, because its code runs against the customer’s workspace. The writing prompt also carries a list of Databricks objects that LLMs tend to invent.

What a run produces

Each product ends in a PDF report built for the reviewer who signs it. For each test it shows the manual procedure, the expected and actual values, and every step’s request and response with credentials removed. It keeps the numbers behind every result, so a reviewer can disagree with a threshold without rerunning anything. The reviewer signs the report in the app through embedded DocuSign and has to log in again for every signing, which ties each signature to the person who made it.

When things go wrong

A run can also go wrong without any test failing, and I built both engines to expect the cases in this table.

Failures the engines expect, and what the report shows
FailureWhat happens
A call can’t be made at allThe step is marked as an error, later steps still run, and the test can’t pass
A test runs too longStopped at its limit and recorded as an error; the run moves on
The user stops the runFinished results are kept; the rest are marked stopped
Settings are missingThe LLM product refuses the run before it starts; checks that need missing credentials report a skip

What this doesn’t show

  • The hallucination cases and the repeated runs in the determinism test are samples. A pass means the model stayed within the customer’s thresholds on those cases, not that it never invents a value.
  • A qualification only records the model and the platform as they were on the day it ran, so a later change to either needs a new run.