Artificial intelligence has left the lab and reached the production floor. Drug manufacturers now run machine learning for visual inspection, trend prediction, anomaly detection, and process control. These systems cut human error and raise throughput. They also force an uncomfortable question. When a model touches something tied to patient safety, product quality, or data integrity, what actually gives us the right to trust what it says?
In July 2025, the European Medicines Agency (EMA) and the Pharmaceutical Inspection Co-operation Scheme (PIC/S) released GMP Annex 22, “Artificial Intelligence.” It is the first rulebook written specifically to govern AI inside pharmaceutical Good Manufacturing Practice. Paired with the revised Annex 11 on computerized systems, it builds a two track framework. Under that framework, AI becomes a controlled GMP object instead of a neutral tool someone happens to use.
This guide goes through what Annex 22 requires in practice, from scope and quality management through validation, explainability, and day to day operation.
What GMP Annex 22 covers
Annex 22 reaches any AI or machine learning model used in GMP regulated activities. The scope is deliberately tight. Regulators drew firm lines between what can go into production and what cannot.
Only static models are allowed
Dynamic models that keep learning from fresh data during production are out. The reason is process stability. A model that retrains itself on incoming readings can drift somewhere no one predicted. Picture an AI that quietly nudged a sterilization temperature threshold after seeing a batch of odd values. The process would no longer repeat the same way each time. GMP exists to guarantee that every step happens identically, and only a frozen, static model can meet that requirement.
Outputs must be deterministic
Probabilistic and generative outputs do not belong in pharmaceutical decisions. Quality calls cannot hang on “probably fine.” A model used for release or critical acceptance has to return the same answer for the same input, every single time. Ambiguous output also creates legal exposure. When a patient sues, the manufacturer has to show exactly why a product passed or failed. “The model felt fairly confident” will not hold up.
Generative AI and LLMs have special limits
Large language models and other generative systems are barred from critical GMP work such as product release. They may show up in non critical tasks, but only under human supervision, and a qualified person has to confirm the output fits the intended use. Drafting a standard operating procedure with an LLM is one thing. Letting it decide whether a batch ships is something else entirely.
The quality management foundation
Every AI application under Annex 22 stands on three supports: people, documentation, and risk management. These run across the whole model lifecycle, whether the model was built in house or bought from a vendor.
The people who must be involved
Four roles carry defined duties.
- The process subject matter expert states what the model should do and watches whether changing conditions, like lighting at a visual inspection station, move the results.
- The data scientist keeps the algorithm sound and watches for biased training data.
- Quality assurance oversees the compliance of the entire workflow, including whether test data stayed independent.
- IT keeps the system stable through access controls and audit trails.
Documentation across the lifecycle
Every activity needs retrievable records that a regulated user reviews. Development files cover algorithm choice, training data sources, cleaning logs, and parameter settings. Testing files cover the test plan, data characteristics, and deviation reports. Operational files cover performance monitoring, change controls, and human review records.
When a company buys a model from a supplier, such as an off the shelf visual inspection system, it also has to collect that vendor’s development documentation. Training data compliance statements and validation reports belong in the company’s own quality system.
Risk management sets the depth of control
Each activity gets judged by its effect on patient safety, product quality, and data integrity. That effect decides how deep the validation has to go. A high risk model, say one checking container closure integrity for a sterile product, may need a much larger test set. A low risk model, such as one reading raw material labels, can drop some testing steps. If a model begins to drift, for instance its accuracy falls, the risk assessment has to restart immediately.
Defining the intended use
The intended use has to be written down in detail before any acceptance testing starts. It describes the specific task the model supports or automates, grounded in a real understanding of the process it sits inside. It also maps the full input sample space: every common and uncommon variation the model might meet, plus the boundaries where it could fail or receive bad data.
Subject matter experts own this description. They record and approve it before testing begins.
Subgroups
Where it fits, the input space splits into subgroups by decision output, process baseline features like site or equipment, material or product traits, or the nature of the automated task such as defect type and severity. Different subgroups can carry different acceptance standards.
Human in the loop
When a model feeds a human operator’s decision and the work of testing that model has been reduced, the intended use has to state the operator’s responsibilities. That operator’s training and ongoing performance get monitored like any manual process.
Setting acceptance criteria
Acceptance criteria are the bar a model must clear before anyone trusts it for the job.
Test metrics
For a model that classifies product, such as accept or reject, useful metrics include the confusion matrix, sensitivity, specificity, accuracy, precision, and the F1 score. Which ones matter depends on what the model does.
The standard itself
Defined metrics need defined acceptance limits. The subject matter expert sets them and documents them before testing starts. Subgroups can have their own limits.
No degradation
A model’s acceptance criteria must beat or match the process it replaces. That sounds obvious, but it forces a real measurement. You have to know how well the old process performed before you can claim the new one is better.
Testing and validation
Most of the compliance effort lands here. Annex 22 is strict about both the data and the way it gets used.
Test data requirements
Test data must represent the full intended sample space, including every subgroup and every rare variant. It has to be large enough to calculate metrics with statistical confidence. Labels need very high correctness, often confirmed by several independent experts or validated equipment. Any preprocessing, such as normalization, must be specified in advance with a reason. Cleaning or excluding data gets recorded with justification. Generating test data or labels with generative AI is discouraged, and any use needs a strong rationale.
Independence of test data
Test data can never be the same data used to train or validate the model. Technical and procedural controls enforce this. One method collects test data only after training and validation finish. Another splits test data out of the full pool before training begins, then locks it away. The people who built the model never see it, access is controlled and audited, and no copies exist outside the secured store.
When physical objects are the test data, the objects used for final testing must not have been used for training or validation. Staff independence matters as well. Anyone who touched test data should not later work on training or validation of the same model. Where an organization cannot keep that separation, the person may take part only alongside a colleague who never saw the test data. That is the four eyes principle.
Running the tests
The test plan is prepared and approved before anything runs. It summarizes the intended use, lists the predefined metrics and acceptance criteria, references the test data, and explains how scores get calculated. The subject matter expert helps build it.
The point is a model that generalizes, meaning it performs on new data from its intended use rather than only on data it has seen. Testing checks for overfitting and underfitting. Any deviation from the plan, any failed criterion, or any unused test data gets recorded, investigated, and justified. All test documentation stays retained like any other GMP record.
Explainability and confidence
For models in critical applications, regulators want to know not just what the model decided but why.
Explainability
During testing of critical models, the system captures and records which features drove a given classification or decision, such as a rejection. Where useful, feature attribution techniques like SHAP values, LIME, or heatmaps show the factors that mattered. Reviewing those features becomes part of approving the test results, to confirm the model reasoned from relevant signals rather than a spurious correlation.
Confidence
The system records a confidence score for each prediction or classification where it applies. Models need a threshold so they only predict when it is appropriate. If confidence drops too low, the model should flag the result as undecided rather than push out a guess that could be wrong.
Operational management
Approving a model is not the finish line. Annex 22 governs how it runs in production.
- Change control: the tested model, its system, and the process it touches all enter change control before deployment. Any change, including to a physical object the model reads, gets recorded and assessed to decide whether retesting is needed. Skipping retesting requires a documented reason.
- Configuration control: the tested model sits under configuration control, with measures that catch unauthorized changes.
- Performance monitoring: the model’s metrics get checked on a schedule to catch system changes like worsening lighting.
- Input space monitoring: inputs get checked to confirm they still fall inside the model’s intended sample space, with defined drift metrics.
- Human review: when a model feeds a human decision, the process gets recorded, and depending on criticality and test level, every output may need consistent review.
What this means for pharmaceutical companies
Annex 22 turns AI governance from an internal preference into a documented regulatory obligation. Companies already running AI in GMP contexts should start by mapping where models sit in production today and whether they meet the static, deterministic, and independence rules. Vendor supplied models need their documentation pulled into the quality system now, not after an inspector arrives.
The heaviest work sits in testing and documentation. Teams need discipline around data independence, retained test sets, and recorded justifications for every deviation. Organizations that already run solid computerized system validation under Annex 11 will recognize much of the foundation.
Conclusion
The arrival of GMP Annex 22 changes what regulators expect from artificial intelligence in pharma. AI is no longer a tool that happens to be used near drug production. It is now an object that manufacturers must control, validate, and monitor under GMP. The companies that build those quality, documentation, and validation habits early will be ready when inspectors stop asking whether AI is used and start asking how it is trusted.

Comments are closed