翻篇收录说明
翻篇网页快照

What Is Machine Learning Inference? How It Works

https://telnyx.com/ai-inference/ml-inference

最近抓取:2026-12-05 07:27:23(北京时间)

最近内容变化:2026-12-05 07:27:23(北京时间)

这是最近一次有效抓取的文本快照,不含网页脚本、图片和动态交互内容。实际网页可能已更新。

访问原网页

页面简介

Machine learning inference is how a trained model scores new data. See what it produces, real-time vs batch serving, CPU vs GPU, and how to measure it.

正文摘录

Back to AI InferenceMachine learning inference: how trained models make predictions in productionInferencePublished 17 Nov 2026Machine learning inference is the moment a trained model starts working for you. See what it produces, how to serve it, and when you need a GPU.By Eli MogulContent Writer & EditorTakeawaysTraining happens once in a while. Inference is the daily shift your model works for every request your product sends it.Most production ML is quiet work like scoring and ranking, and it has to finish before anyone notices a pause.Choose how to serve a model by asking who's waiting on the result, then size the hardware to match.You may not need a GPU at all. Plenty of smaller models run well on ordinary servers, especially after quantization.Judge a live model by its worst moments, not its average ones.What is machine learning inference?Machine learning inference is running new data through a trained model to get an output. Training is the studying; inference is the model answering questions on the job, with its weights (the numbers it learned) locked in place.What is the primary function of the inference process in machine learning?The primary function of the inference process in machine learning is to apply a trained model to new, unseen data to produce an output, such as a prediction, a classification, a score, or an embedding.It's also where a model starts paying for itself. In a notebook, it helps no one; behind an endpoint, it checks every payment, email, or search your product handles.You'll also hear it called inference in machine learning, ML inference, or model inference. The answer to "what is ML inference" fits in four steps:You train the model once, and its weights are frozen.Inference loads those weights into memory.Each new input runs through a forward pass, one trip through the model's layers.Nothing is learned along the way.For the bigger picture, including training vs. inference, see what is AI inference.A machine learning inference exampleYour inbox's spam filter is a machine learning inference example you used today:An email arrives.The text is split into tokens the model can read and converted into numbers.The model runs a forward pass and returns a 0.97 probability of spam.The mail app compares that score with its threshold, the cutoff above which it acts, and files the email as spam.The model learned nothing from that email. It returned a number, and the app made the call.What machine learning inference producesMachine learning inference returns whatever the model was trained to produce: a probability, a number, a vector, a ranked list, or a set of boxes. Your application decides what to do with it.Scores, labels, and predictionsScores and labels are the most common outputs of machine learning inference. A classifier returns a probability, and your application turns it into a yes or no with a threshold: fraud or not, spam or not, about to cancel or not.A regressor returns a number instead, like a likely sale price or next week's demand. Vision models return boxes and labels for what they see, and speech models return text.Embeddings and rankingsEmbeddings and rankings power search results and "you might also like" rows. An embedding is a list of numbers that captures meaning, so a search for "cheap flights" lands near "budget airfare."For search, inference turns your query into an embedding and a vector database finds the closest matches. For recommendations, a model scores candidates and ranking logic picks the few you see.This is where much of the world's inference goes. Facebook reported that recommendation models made up up to 79% of AI inference cycles in a production-scale data center. A later Meta paper put Facebook's AI power capacity at roughly 10:20:70 across experimentation, training, and inference, with much of that scoring running on CPUs.Language models are a different serving problem: they write one token at a time, with a forward pass for each.Machine learning inference in actionHere's what inference looks like in six everyday places:At a bank, a card swipe sends the amount, merchant, and location to a fraud model. It returns a risk score before the terminal shows "Approved," and a high score triggers a text asking if the charge was you.In a contact center, a speech model transcribes the caller live and a second model tags the reason for the call, so the agent sees the right account early.On a factory line, a vision model checks a photo of each circuit board and flags missing or crooked parts for a human to inspect.In a food delivery app, a regression model turns distance, traffic, and kitchen load into the arrival time you watch tick down.At a streaming service, a batch job scores thousands of titles for every subscriber overnight, so your home screen is ready when you open the app.On a support team, embedding search finds past tickets about a "refund for late order" even when they never use the word refund.The difference between them is who's waiting: the cardholder needs an answer in milliseconds, while nobody watches the streaming job at 3 a.m.Real-time, batch, and asynchronous inferenceYou serve a model in one of three ways, chosen by who is waiting for the answer: a person right now (real-time), nobody (batch), or a person who can wait a little while (asynchronous).Real-time vs batch vs asynchronous inferenceCaption: Real-time, batch, and asynchronous inference differ in who is waiting for the answer.Real-time inference and its latency budgetReal-time inference answers one request at a time within a latency budget, the maximum time the answer is allowed to take. Tap "Pay," and a fraud model has milliseconds to score the charge.Tight budgets leave hardware partly idle. In Google's 2017 TPU paper (Jouppi et al.), a 7 ms limit on 99th-percentile response time for one production model, MLP0, held a Haswell CPU to 42% and a K80 GPU to 37% of the throughput each reached with no limit.Streaming is real-time inference that sends partial output as it's ready, which is why live captions appear as someone speaks.On a phone call, you can hear every delay. The code below runs three inference calls in one back-and-forth: text-to-speech plays a phrase, speech-to-text transcribes the reply, and a language model scores it.import os import requests API = "https://api.telnyx.com/v2" HEADERS = {"Authorization": f"Bearer {os.environ['TELNYX_API_KEY']}"} def speak_phrase(text): # Text-to-speech: turn the target phrase into audio for the caller r = requests.post( f"{API}/text-to-speech/speech", headers=HEADERS, json={"text": text, "voice": "Telnyx.NaturalHD.astra", "output_type": "binary_output"}, ) return r.content # audio bytes to play on the call def transcribe_attempt(audio_bytes): # Speech-to-text: turn the caller's reply into text r = requests.post( f"{API}/ai/audio/transcriptions", headers=HEADERS, files={"file": ("attempt.wav", audio_bytes, "audio/wav")}, data={"model": "openai/whisper-large-v3-turbo"}, ) return r.json()["text"] def score_attempt(target, transcript): # Language model: score the attempt and suggest one fix r = requests.post( f"{API}/ai/chat/completions", headers=HEADERS, json={ "model": "moonshotai/Kimi-K2.6", "messages": [ {"role": "system", "content": "Score the attempt from 1 to 10 and give one tip."}, {"role": "user", "content": f"Target: {target}\nHeard: {transcript}"}, ], }, ) return r.json()["choices"][0]["message"]["content"]The pause the caller hears is all three calls plus the network between them. To compare transcription speed by model, see the STT models guide.Batch and asynchronous inferenceBatch inference scores a whole dataset on a schedule, like the overnight job that ranks a million customers by churn risk before the retention team logs in. You judge it on throughput and cost per item.Asynchronous inference sits in between: you submit a request, get a ticket back, and collect the result later. It's a serving pattern rather than a formal term, and it suits long jobs like transcribing an hour-long meeting.How batching fits inside a latency budgetBatching groups requests that arrive within a few milliseconds of each other and runs them through the model together. Each request waits slightly longer, but throughput rises, as long as the group still finishes inside the latency budget.In the Clipper serving system (Crankshaw et al., 2017), adaptive batching gave a scikit-learn linear SVM up to 26 times the throughput of no batching while staying within a 20 ms latency objective.CPU or GPU for machine learning inferenceMany machine learning models run inference fine on a CPU. Deep learning inference with large inputs or heavy traffic is where a GPU pays off.When a CPU is enoughA CPU is enough for machine learning inference when the model is small, traffic is modest, or it runs on a device like a laptop or kiosk. Decision trees, linear models, and small neural networks usually qualify.The gap is real for vision models. In MLPerf Inference v5.1, ResNet-50 took 7.63 ms per image on a CPU-only AMD Ryzen 9 7950X PC and 0.51 ms on a Lenovo ThinkEdge SE100 with one NVIDIA RTX 2000E Ada GPU (90th-percentile latency, edge SingleStream).Quantization, storing weights in fewer bits, narrows it. A 2018 Google whitepaper by Raghuraman Krishnamoorthi found 8-bit weights make a model 4 times smaller and run 2 to 3 times faster than floating point on CPUs. For convolutional networks, post-training 8-bit quantization kept accuracy within 2%.When you need a GPUYou need a GPU for machine learning inference when you serve large deep learning models, high request volume, or large batches.In the same MLPerf round, a dual Intel Xeon 6980P system served 18,704 queries per second on the DLRM recommendation model, while an 8x NVIDIA H200 system served 370,068, about 20 times more. MLPerf doesn't publish prices, so this says nothing about cost per query.Here's how the two compare:CPUGPUGood fitTrees, linear models, small networks, modest traffic, edge devicesLarge deep lear