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.
| What differs | LLM product | Platform product |
|---|---|---|
| It qualifies | A customer’s model on Azure OpenAI or served from Databricks | A customer’s Databricks workspace on Azure or AWS |
| Built-in tests | 19: 10 operational and 9 installation | 59 versioned definitions |
| A test is | Code in the engine | Data the engine reads: a chain of API calls |
| A test passes when | A measured value meets one of 26 thresholds the customer sets | The 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
- The product screens: settings, runs, scheduling, review, signing; on the company’s web platform (I built this)
- The platform API: extended for both products: jobs, project settings with encrypted secrets, saved custom tests (I reworked this)
- 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)
- 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
- A report service renders the PDF (I built this)
- Stored on the job (not mine)
- 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.
| Test | What it catches | How it is checked |
|---|---|---|
| Hallucination | Inventing a value the source doesn’t contain | 40 cases with fields missing from the text |
| Extraction accuracy | Wrong values in extracted fields | F1 for each field, against labeled narratives |
| Classification | Misclassified complaints and triage levels | Accuracy against labeled cases |
| Determinism | Different answers to the same input | 20 runs of one input must return the same JSON |
| Latency under concurrency | Failed or slow calls | 40 requests from 20 concurrent workers |
| Demographic bias | Different outputs when only the demographics in a case change | 5 scenarios, each in four demographic variants |
| Traceability | A response that can’t be traced back to the model and the request that produced it | Each 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
- 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)
- 403: A short function reads the response: and adds variables for later steps: an ID to poll, a statement to check (I built this)
- 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)
- 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
- A requirements document: PDF, DOCX or text (the customer’s)
- An LLM pulls out up to 8 testable statements: rewrites or drops ones that can’t be checked (I built this)
- An LLM writes a test for each, in parallel: from 5 real tests in the library (I built this)
- Checks: required fields, and the code compiles: fails: one retry with the errors (I built this)
- Person: A reviewer edits, removes or regenerates each one: with their feedback (I built this)
Running a qualification
- Saved with the project (I built this)
- Runs as its own suite next to the built‑in tests (I built this)
- 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.
| Failure | What happens |
|---|---|
| A call can’t be made at all | The step is marked as an error, later steps still run, and the test can’t pass |
| A test runs too long | Stopped at its limit and recorded as an error; the run moves on |
| The user stops the run | Finished results are kept; the rest are marked stopped |
| Settings are missing | The 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.