Dividere il traffico tra versioni del modello
Instradi una percentuale delle richieste verso un challenger.
Dividere il traffico tra versioni del modello è una lezione MLOps Academy gratuita su CoddyKit. Questa è la lezione 1 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento MLOps Academy, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso MLOps Academy include 4 lezioni in totale.
Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.
Two Models, One Live Test
You have a new model you believe is better. Instead of guessing, you let real traffic decide. An A/B test runs both models side by side on live users. 🔬
Champion and Challenger
The current model in production is your champion. The new candidate you want to prove is the challenger. The test sees if the challenger truly beats the champion.
Splitting the Traffic
The core idea is simple: send a slice of requests to each model. A common start is 90/10, keeping most users safe on the champion while the challenger proves itself.
A Tiny Router
A basic split just rolls a random number per request and routes by the cutoff. Here ten percent of traffic reaches the challenger.
import random
def pick_model(challenger_share=0.1):
return "challenger" if random.random() < challenger_share else "champion"Keep Each User Consistent
Random per request flips a user between models on every visit. Instead, hash the user id so the same person always lands on the same model.
Hashing for Sticky Splits
Hashing the user id gives a stable bucket. The same id maps to the same model every time, which keeps the test clean.
import hashlib
def bucket(user_id, challenger_share=0.1):
h = int(hashlib.md5(user_id.encode()).hexdigest(), 16)
return "challenger" if (h % 100) < challenger_share * 100 else "champion"Log Which Model Served
For every prediction, record which model handled it. Without this assignment log, you can never compare the two groups fairly later on. 📝
Start Small, Then Ramp
Begin with a tiny challenger share to limit risk. As confidence grows, you raise the percentage gradually instead of flipping everyone over at once.
Control the Split with Config
Hard-coding the share means a redeploy to change it. Read the split ratio from config so you can dial traffic up or down without shipping code.
Same Inputs, Fair Fight
Both models must see the same kind of requests and the same features. If the groups differ in who they serve, any winner you find may be an illusion.
It Is Just Routing
At its heart, an A/B test is a routing layer plus careful logging. Get the split sticky and recorded, and you have the foundation for a trustworthy comparison. ✅
Quick Check
Let us check how to keep your split clean.
Recap
An A/B test pits a champion against a challenger by splitting live traffic. Hash users for sticky buckets, log every assignment, and start small. 🎯
Domande Frequenti
La lezione «Dividere il traffico tra versioni del modello» è gratuita?
Sì — il testo completo di «Dividere il traffico tra versioni del modello» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso MLOps Academy, passa a CoddyKit PRO. Il corso MLOps Academy include 4 lezioni in totale.
Cosa imparerò in «Dividere il traffico tra versioni del modello»?
Instradi una percentuale delle richieste verso un challenger. Eserciti MLOps Academy con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.
Ho bisogno di esperienza per iniziare MLOps Academy?
Non è richiesta alcuna esperienza precedente. MLOps Academy su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 1 di 4.
Quanto tempo richiede la lezione «Dividere il traffico tra versioni del modello»?
La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.
Posso scrivere ed eseguire codice in questa lezione MLOps Academy?
Sì. Ogni lezione MLOps Academy include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.
Tutte le lezioni di questo corso
- Dividere il traffico tra versioni del modello
- Scegliere le metriche che contano
- Interpretare la significatività senza autoingannarsi
- Promuovere o ripristinare il modello vincitore