How to Architect a Self-improving ML System with Automated Model Retraining

How to Architect a Self-improving ML System with Automated Model Retraining

04 July, 2025 | 8 Min | By Riya Agarwal

So, you've deployed your shiny new ML model. It's acing predictions, and life is good. But then, that familiar trouble begins: model drift. Performance starts to sag, and the thought of another manual model retraining slog looms. Sound familiar? We've all been there. In this post, we're not just complaining or talking theory; we’re pulling back the curtain to show you exactly how we tackled this at Dexit-314e’s very own Intelligent Document Processing Platform, building an ML system that fights back.

Get ready to dive into a self-improving architecture powered by automated model retraining, and learn how to make your models continuously learn and adapt.

What this blog talks about:

Why Model Drift Demands Automated Retraining

What is Model Drift, Really? 

Simply put, model drift is when the world your model lives in changes, but your model doesn't. The data it sees in production starts to look different from the pristine dataset it was trained on.

This usually shows up in two main flavors:

  • Data Drift: This occurs when the statistical properties of the input features themselves change. Imagine a model trained to identify objects in images; if it suddenly starts receiving images with different lighting conditions, resolutions, or from new camera types it hasn't seen before, that's data drift. Or, for a text processing model, new slang, jargon, or writing styles appearing in the input text would constitute data drift.
  • Concept Drift: This is when the relationship between the input features and the target variable changes, even if the input data itself looks similar. The underlying meaning or context shifts. For example, in fraud detection, what constitutes a "fraudulent transaction" might evolve as fraudsters develop new techniques; the same transaction patterns that were once benign might now be suspicious.

The bottom line? Your model’s understanding gets stale, and performance tanks.

(If you want the full-blown deep dive on all things model drift, check out our previous post: Why is my AI Model's Performance Degrading? How to Solve Model Drift – we really get into the weeds there.)

The Pain of Manual Model Retraining

The model drifts, and the traditional response? Manual intervention for retraining the model. 
While this approach might seem direct, it presents several significant operational challenges, particularly as AI systems scale:

  • Significant Time Investment: The process of diagnosing drift, acquiring and preparing new datasets, executing training runs, evaluating performance, and managing deployment is inherently time-consuming. This diverts engineering resources from core development and innovation tasks.
  • Increased Potential for Errors: Manual processes are more susceptible to human error at various stages, from incorrect data selection or versioning to misconfigured training parameters, which can lead to suboptimal model performance or failed retraining attempts.
  • Scalability Limitations: As the number of deployed models increases, or as the frequency of necessary retraining events grows, a manual approach quickly becomes unsustainable. Managing these retraining model cycles for a large portfolio of models is a considerable operational burden.
  • Reactive Problem Solving: Manually retraining models typically addresses performance degradation after it has been detected, meaning the model may have been underperforming for a period, potentially impacting user experience or business outcomes. A proactive stance is far more desirable.

This reactive cycle underscores the necessity of shifting towards a continuous training machine learning paradigm. We require systems designed for ongoing adaptation and learning, rather than periodic, labor-intensive interventions. This is where the value of automated model retraining, as implemented in Dexit's architecture, becomes evident. Let's delve into how such a system is structured.

The Dexit Blueprint: Architecting a Self-improving Document AI System

To illustrate a practical approach to automated model retraining, we'll walk through the MLOps architecture implemented within the Dexit platform.

Dexit processes a diverse range of documents, relying on sophisticated models for understanding and extracting information. The primary models involved in this continuous improvement loop are:

  • Document Classification: Utilizing a fine-tuned vision language model (VLM) to categorize documents.
  • Entity Extraction: Employing the VLM to identify and extract specific entities with their values and bounding boxes.

This multi-model environment underscores the need for a robust and adaptable retraining pipeline. Let's explore the core steps that constitute Dexit's self-improving system.

Here's Dexit’s core automated model retraining system at a glance.

The Dexit Blueprint_ Architecting a Self-improving Document AI System

Step 1: Initial Training, Deployment & Crucial Feedback Loop – Harnessing Human Intelligence

The journey to deploy Model V1 begins with data acquisition from the client. After manual EDA and preprocessing of raw documents (including PDF to JPG, OCR, and bounding box generation), the processed data is formatted and stored (e.g., in an R2 bucket). Model V1 is trained using Python scripts, with all training parameters, metrics, and code versions meticulously logged to an open-source MLOps platform for reproducibility. Following training, Model V1 is rigorously evaluated on a held-out test set, with these critical metrics also logged. Upon successful evaluation, Model V1 is registered in a Model Registry. Finally, the validated Model V1 is deployed for inference via Dexit's API, its status tracked in database tables where it's marked as the default, ready for continuous monitoring.

Once a model version is live, the system actively learns from user interactions. This feedback is pivotal for its adaptation and improvement, akin to reinforcement learning from human feedback.

  1. Capturing Corrections: Users review AI-generated classifications and entities from Model V1. Any corrections they make (document type changes, entity modifications/additions/removals) are captured.
  2. The feedback_data Table: Initial predictions from Model V1 generate entries in the table.
  3. The "Commit" API Flow: When a user "commits" reviewed documents:
    - An API compares initial predictions from Model V1 (in feedback_data) with the final, user-verified metadata, and feedback_data rows are updated.
    - This process generates high-quality, human-verified signals for potential model retraining.

Step 2: The Vigilant Monitor – Detecting Performance Degradation

With ongoing feedback, the system continuously monitors the performance of the active Model V1.

  1. Temporal Workflows for Monitoring: Temporal workflows are triggered upon document commit.
  2. Threshold-based Triggering:
    - The workflow checks the retraining state in the model table. If retraining is TRIGGERED or INPROGRESS, it exits the flow.
    - It retrieves a configurable threshold for Model V1.
  3. Calculating Current Accuracy (Model V1):
    - Activities query the feedback_data table for rows wherein committed documents are associated with the current Model V1.
    - Accuracy 1.0 - (Corrected Count / Total Committed Count) is calculated, overall for Classification and per-entity for Entity Extraction.
  4. Decision and Trigger: If accuracy for Model V1 (or a specific entity) falls below its threshold (set based on our standards), the workflow initiates the appropriate retraining workflow to create a new candidate, Model V[1+1], which we refer to as V2.
  5. Updating Retraining State: Upon triggering retraining the retraining state for that model type is updated to INPROGRESS.

Step 3: Smart Dataset Creation – Fueling Effective Retraining

When retraining is triggered for the current Model V1, a new, targeted training dataset is constructed to produce Model V2.

  1. Criticality of Data Selection: The quality and composition of this new dataset are paramount for successful model retraining.
  2. For Classification:
    - Fetches all samples that have been corrected in the feedback related to Model V1 where retraining has not happened.
    - Fetches a balanced set of non-corrected samples also to prevent overfitting on errors and maintain knowledge of correct predictions.
  3. For Entity Extraction:
    - Identifies underperforming entities from Model V1's feedback.
    - Applies stratified sampling for samples that have been corrected based on entity precision buckets (Low, Medium, High) and focuses on errors for underperforming entities.
    - Fetches a balanced set of non-corrected samples to provide context.
    - The rationale is to concentrate retraining on problematic areas while maintaining overall performance.
  4. Dataset Preparation: The combined samples are prepared into the final training input structure for the subsequent training jobs.

Step 4: The Retraining Engine – Forging a New Model Version V2

With the curated dataset ready, the actual retraining process begins.

  1. Orchestrated Training: Temporal activities trigger an open-source framework for running AI workload jobs to provision infrastructure and execute training.
  2. Fine-tuning from Model V1: The training script retrieves the currently deployed Model V1 from the Model Registry to use as the base for fine-tuning.
  3. Training and Logging: Model V1 is fine-tuned on the new dataset. All parameters, metrics, etc., are logged to an open-source MLOps platform as a new experiment run for the candidate Model V2.
  4. Candidate Registration: The newly trained candidate, Model V2, is registered in the Model Registry, linked to its retraining dataset and an open-source MLOps platform experiment, but it is not yet marked as default.

Step 5: The Gauntlet – Ensuring True Improvement (Evaluation)

Before deploying Model V2, it undergoes rigorous evaluation against the incumbent Model V1.

  1. Evaluation Datasets:
    - Original Test Set: Candidate Model V2 is evaluated on the same held-out test set that was used for the initial Model V1 (and potentially subsequent V1 versions if they also established new benchmarks on it).
    -Recent Production Data Slice: Performance is also assessed on a test split from the data used to create/trigger the retraining of Model V2.
  2. Comparative Metrics: Key performance metrics (overall accuracy for Classification; per-entity precision/recall/F1 for Entity Extraction) are calculated for both Model V1 and candidate Model V2 and compared side-by-side.
  3. Decision Criteria: Predefined criteria determine if Model V2 is demonstrably "better" than Model V1 (e.g., statistically significant improvement, no critical regressions).

Step 6: The Rollout – Deploying the Champion & Resetting Baselines

If candidate Model V2 proves superior to Model V1:

  1. Deployment: A Dexit API call updates the model version in the model table, setting the default flag to true for Model V2 and false for the previous Model V1. Model V2 is now the live production model.
  2. State Update: The retrain_state in the model table is updated to COMPLETED.
  3. Adaptive Thresholds: Crucially, the retraining_threshold values are updated based on Model V2's new baseline performance. This is a key aspect of continuous training in machine learning, ensuring future retraining is triggered relative to the current model's capabilities.
  4. Data Archival: Feedback data rows that are marked as retrained=true are moved from feedback_data to feedback_archive for long-term storage and to keep the active feedback table manageable.

Step 7: The Contingency Plan – When Retraining Falls Short

Not every retraining attempt guarantees improvement. Dexit's "Alternate Path" handles scenarios where the candidate Model V2 fails evaluation against Model V1:

  1. Failure Analysis (Manual): Investigate why Model V2 didn't improve (e.g., issues with feedback quality, suboptimal sampling).
  2. Adjust Strategy: Modify configuration parameters for dataset creation (e.g., non_corrected_sample_ratio, precision bucket sampling rates).
  3. Data Reset: The retrained=false flag is reset in the feedback_data table for relevant entries, making corrected data available again.
  4. Re-trigger Retraining: The retrain model process is re-initiated. It will again fine-tune from the current default Model V1 (since Model V2 was rejected), aiming to produce a new, hopefully improved, candidate (which would still be termed Model V2 in this iterative cycle, or perhaps Model V2.1 for internal tracking before it becomes the official next version). The goal is to learn from the failure and try a different approach until an improved model is successfully deployed.
    - Highlight: This resilience and ability to adapt the retraining strategy based on outcomes are vital for a robust MLOps pipeline.

Key Learnings & Best Practices for Your Own Model Retraining Pipelines

Building and maintaining an automated model retraining system like Dexit's is an iterative journey, filled with valuable lessons. Whether you're just starting or looking to refine an existing MLOps pipeline, consider these key learnings and best practices:

Feedback is Gold, but Quality is King:

The entire premise of a self-improving system driven by user feedback hinges on the quality of that feedback. While it's tempting to gather as much data as possible, noisy, inconsistent, or ambiguous corrections can lead your model retraining efforts astray, potentially even degrading performance.

Best Practice: Implement mechanisms to validate or review feedback, especially if it comes from diverse user groups. Ensure your UI/UX for feedback capture is clear and minimizes opportunities for erroneous input. The effectiveness of your reinforcement learning from the human feedback loop directly correlates with the signal quality. 

Strategic Sampling is Non-Negotiable:

Simply throwing all accumulated feedback into your next training run is rarely the optimal strategy. How you select and sample data for machine learning model retraining drastically impacts outcomes.

Best Practice: As seen with Dexit's approach, employ targeted sampling. For classification, balance corrected samples with non-corrected ones to prevent catastrophic forgetting. For entity extraction, stratify samples based on current performance (e.g., oversample errors for low-performing entities). There's no one-size-fits-all; experiment and tailor your sampling to your specific models and data characteristics. 

Define "Better" Clearly and Quantifiably:

Before promoting a newly retrained model version (e.g., V[1+1]) to production, you must have an unambiguous definition of what constitutes an "improvement" over the current version (V1).

Best Practice: Establish explicit, quantifiable criteria. This involves selecting key performance metrics (overall accuracy, F1-scores for critical classes/entities, recall for high-impact errors) and setting thresholds for improvement. Also, define acceptable regression tolerances for other metrics. Ensure these are evaluated on consistent, held-out test sets. 

Monitor Your MLOps Pipeline, Not Just Your Models:

An automated retraining pipeline is itself a complex software system. While it's designed to monitor your ML models, the pipeline itself requires oversight. Failures in data ingestion, workflow execution (e.g., Temporal jobs), or infrastructure provisioning (e.g., an open-source framework for running AI workloads) can silently break your continuous learning loop.

Best Practice: Implement robust logging, alerting, and monitoring for all components of your MLOps infrastructure. Track pipeline health, job success rates, and resource utilization. 

Iterate and Evolve – Automation is Not "Set It and Forget It":

Your first automated model retraining system will likely not be your last or perfect version. The data landscape evolves, business requirements change and new modeling techniques emerge.

Best Practice: Treat your MLOps pipeline as a living system. Regularly review its performance, analyze retraining outcomes, and be prepared to refine your strategies—be it sampling logic, evaluation criteria, or even the underlying tools. Continuous improvement applies to the pipeline itself.

Factor in Compute Costs and Resource Management:

Continuous training in machine learning, while beneficial, has resource implications. Frequent retraining, especially of large models, consumes compute resources (CPUs, GPUs, memory) and incurs costs.

Best Practice: Optimize your training jobs for efficiency. Explore techniques like early stopping or efficient fine-tuning. Implement smart scheduling for retraining (e.g., trigger only on significant drift, or during off-peak hours where feasible). Balance the desire for constant model freshness with pragmatic resource constraints.


Dexit's journey underscores a vital MLOps truth: static models can't keep pace. Automated model retraining offers a powerful solution, delivering proactive model drift management, sustained accuracy, and efficient use of engineering talent. While Dexit's specifics are unique, the core principles—robust feedback loops (leveraging reinforcement learning from human feedback), diligent monitoring, automated triggers, and strategic dataset creation—are universal for effective continuous training in machine learning. Embracing automated machine learning model retraining is no longer a luxury but a necessity for building resilient, adaptive AI. The future is self-improving; let's architect it.

CONTRIBUTORS BEHIND THE BUILD

Stay on Top of Everything in Healthcare IT

Join over 3,200 subscribers and keep up-to-date with the latest innovations & best practices in Healthcare IT.

Related posts