Sept 25, 2026 · @Nery Garcia
A trained machine learning model is not a feature yet. It becomes one only when it is connected to something a person can use: a recommendation on a product page, a photo that gets labeled, a message that gets analyzed.
That connection is where most of the real work lives. Integrating machine learning into a web application is a software-engineering challenge, not just a model-training challenge. The model has to receive the right input, run at the right moment, return something the app can show, and keep working after launch.
This post walks through the four decisions that make that happen, and the mistakes that most often get in the way.
First, one word to know: inference
Machine learning has two phases. Training is when a model learns from examples. Inference is when the trained model is used to make a prediction on something new.
Your web application almost never trains the model. It runs inference. So the question for the rest of this post is simple: how do you get a prediction from the model to the person using your app, smoothly and reliably?
1. Decide where the model runs
The first decision is where inference happens. There are two main options: send the input to a server that runs the model, or download the model and run it right in the browser (ONNX Runtime).
| Approach | How it works | What you have to plan for |
|---|---|---|
| Server-side | The browser sends input to a backend. The backend runs the model and returns the result. | Serving infrastructure, capacity, scaling, and operational monitoring |
| Browser-side | The browser downloads the model and runs it locally. | A compatible model, a browser runtime, and the input and output handling around it |
If you go the browser route, two tools are worth knowing:
- TensorFlow.js runs TensorFlow and Keras models in the browser or in Node.js (web.dev).
- ONNX Runtime Web runs models in the ONNX format through JavaScript. ONNX is framework-independent, so models exported from PyTorch or TensorFlow can both use it (ONNX Runtime).
Your web framework is a separate choice. The runtime can be added to apps built with React, Vue, or Angular.
2. Connect the whole pipeline, not just the model
A prediction is the middle of a chain, not the whole thing. Every ML feature follows the same five steps:
- The user provides input.
- The app prepares that input (preprocessing).
- The model runs inference.
- The app interprets the output (postprocessing).
- The result is shown on screen.
Preprocessing turns what the user gave you into the format the model expects. Postprocessing turns the model’s raw output into something your app can use (ONNX Runtime).
Take image classification. The model file alone does nothing. The app has to prepare the image in the expected format, then translate the output into labels or scores. The exact steps depend on the model.
Why consistency matters
A model can perform well in development and poorly in your app. A common cause is training-serving skew: a difference between the conditions during training and the conditions when the app makes predictions. It can come from handling data inconsistently, from data that changes, or from feedback loops (Google’s Rules of ML).
Google’s advice is practical: check that the same example gets the same score in training and in the live app, and keep watching for differences.
3. Load the model once, use it many times
In the browser, running an ONNX model follows a set sequence (ONNX Runtime):
- Add the runtime to your project.
- Start an inference session with the model.
- Prepare the input.
- Run the session.
- Process the results for your app.
One detail makes a big difference: create the inference session once, not for every prediction. Setting up the model is the slow part. Do it one time, then reuse it for each request.
On a server, the lifecycle is bigger. You deploy the model files, choose computing resources, and set up scaling (Google Cloud). A model that works in a notebook on your laptop is not yet a service that works for your users.
4. Monitor the software and the predictions
An app that returns predictions without errors is not necessarily returning good predictions. Monitoring has to cover the model’s inputs and outputs, not only whether the app is running (Google Cloud).
Three things to watch:
- Training-serving skew. Live inputs or processing differ from what the model was trained on.
- Data drift. The incoming data changes over time.
- Prediction quality. When the real outcomes become available, check whether the predictions were actually correct (Datadog).
Keep one distinction in mind. A shift in the data is a warning sign, not proof that accuracy has dropped. Measuring real prediction performance, when you can, tells you more than drift numbers alone.
Google also recommends logging the inputs the model sees while it is live. That record lets you compare the live app with training, and it feeds future training and evaluation.
Five common mistakes
| Mistake | Why it matters |
|---|---|
| Treating the model file as the finished feature | The app still needs input preparation and output interpretation |
| Processing data one way in training and another way in production | Inconsistent handling causes training-serving skew |
| Restarting the browser inference session for every request | The session should be created once and reused |
| Deploying without planning serving resources | Production needs decisions about compute, inputs, and scaling |
| Checking only that predictions come back | You also need to watch data changes and, where possible, accuracy |
The takeaway
A machine learning model becomes a useful web feature only when its inputs, execution, outputs, and monitoring work together. The question is not just “how do I add AI to my app?” It is “how do I connect a trained model to an application that keeps working reliably over time?”
Get those four pieces right and the model stops being an experiment. It becomes something people can depend on.
Sources
- Build a web application with ONNX Runtime, ONNX Runtime
- ONNX Runtime Web tutorials, ONNX Runtime
- Client-side AI, web.dev
- Rules of Machine Learning, Google for Developers
- Best practices for implementing machine learning on Google Cloud, Google Cloud
- Best practices for monitoring ML models in production, Datadog



