cookbook · vertical · drug-name-redact
Recipe · vertical

Proprietary drug names out, generics in.

A local .kolm that rewrites patient-facing copy to strip brand drug names and replace them with their generic equivalents. Backed by a frozen RxNorm snapshot bundled into the artifact — no upstream calls, no per-deploy drift.

base modelqwen2.5-3b-instruct
gold pairs450 (315 train / 135 eval)
k-score floor0.88
artifact size38 MB
compile time~22 min
spec sourceredactor + lookup

What this recipe does

Patient education copy, discharge summaries, and pharma marketing material often need to reference medications without endorsing one brand over another. This recipe compiles a small rewriter that detects proprietary drug names (Lipitor, Zoloft, Adderall, etc.), looks up the active ingredient in a frozen RxNorm snapshot bundled with the artifact, and substitutes the generic.

The verifier rejects any output that re-introduces a brand name. The lookup table is frozen at compile time so the artifact's behavior never drifts in deployment.

The spec

{
  "output_kind": "text",
  "verifier": {
    "banned_token_regex": "./rxnorm-brands.regex",
    "must_preserve_generic_for_each_redacted_brand": true,
    "max_edit_distance": 0.4
  },
  "recall": {
    "frozen_snapshot": "rxnorm-2026-01.kolm-recall"
  }
}

Compile

kolm compile "strip proprietary drug names, preserve generic equivalents" \
  --base qwen2.5-3b-instruct \
  --pairs ./drug-redact-gold/*.jsonl \
  --recall ./rxnorm-2026-01/ \
  --verifier no-brand-names,generic-preserved \
  --k-floor 0.88 \
  --output drug-name-redact.kolm

ok wrote drug-name-redact.kolm
   k_score=0.91  signature=hmac-sha256
   0/135 held-out outputs contained a brand name

K-score gate

K-score 0.91 held-out 135 inputs · brand-leak 0% · generic-preserved 99% · semantic-faithful 96%

Brand-leak metric is exact: any output containing a token from the bundled brand-name regex breaks the chain and is rejected.

Run-time profile

CMS server
340ms
RTX 5090
62ms
Mac mini
280ms
CPU x86
540ms

Deploy

# CMS pre-publish hook โ€” strip brands before patient-facing pages go live:
on_publish = (page) => {
  const safe = kolm.run('drug-name-redact.kolm', page.body);
  page.body = safe.text;
  audit.log({ artifact: 'drug-name-redact.kolm', page_id: page.id, k_score: safe.receipt.k_score });
};