Lesson 143 — Advanced

On-device & Edge Modalities

Chhote speech aur vision models ko user ke device pe chalaana privacy, offline operation aur zero per-request cost deta hai — par saath mein memory, thermal aur quality ke limits bhi aate hain. Is lesson mein hum dekhenge quantization kya karta hai aur quality kahan girti hai, phone/laptop ki hardware ceilings, on-device se kya milta hai, aur device vs self-host vs API ka per-modality decision.

⏱ 10 min• Advanced• Deep Research & Long-Horizon Scenarios

On-device modality kya hai

Kya hai?

On-device/edge modality matlab speech ya vision ka chhota model user ke phone ya laptop pe hi chalna — cloud round trip nahi. Data device se bahar nahi jaata, network na ho toh bhi feature chalta rehta hai.

Kab kaam aata hai?

Dictation, live captions, camera filters, voice commands, offline assistants — jab input private ho, latency predictable chahiye, ya network unreliable ho.

Kahan milta hai?

Mobile/web ML runtimes mein, OS ke built-in speech/vision APIs mein, quantized open models mein jo device pe chalte hain, aur hybrid apps mein jo on-device + API dono use karte hain.

Do wajah se modalities device pe suit karti hain: models chhote ho sakte hain (specialized STT/vision models chhote batches mein chal sakte hain) aur input hi private hai — awaaz aur camera frames har waqt bahar bhejna consent-wise aur bill-wise dono mehnga. Plus network mein round trip aksar sabse slow part hota hai.

Mental model: Har inference teen jagah ho sakta hai — user device, tumhara self-hosted server, ya vendor API. Ye decision per-modality hoti hai; ek hi application teeno ko saath use kar sakti hai, aur ye normal hai.

Quantization aur uska trade

# Quantization: precision kam -> size/speed behtar, par quality ka trade
params = 3_000_000_000        # example model size
fp16_bytes = params * 2       # -> 6 GB class
int8_bytes = params * 1       # -> 3 GB class
int4_bytes = params // 2      # -> 1.5 GB class

# Device pe zyada tar int4/int8 hi fit hota hai — par quality gir sakti hai
# Quality kahan PEHLE dikhti hai:
# numbers, rare words, accents, fine transcription, exact field reading
Rule of thumb: Accuracy-critical extraction cloud model pe rakho; device pe uska chhota fallback (draft/preview). Aur quantized model ka output kabhi directly database mein mat daalo — verification layer zaroori hai.

Phone aur laptop ki limits

Hardware limits ek design input hain, QA ka baad ka thought nahi. Peak demand (ek saath 5 images? 1 ghante ki recording?) pe device ka behavior measure karo: p95 latency aur memory high-water mark dono. Jitna chhota model, utna predictable experience.

Shipping rule: Apne slowest supported device pe benchmark karo. Dev phone pe smooth, user ke teen-saal-purane phone pe jank — yehi 1-star reviews ka sabse aam source hai.

Device vs self-host vs API — per modality

# Per modality decide karo — poora stack ek jagah mat pakdo
def place(small_model, privacy_strict, offline_needed, volume):
    if offline_needed or privacy_strict:
        if small_model:
            return "device"      # private + offline, chhota model fit hai
        return "self-host"       # private chahiye, par device pe fit nahi
    if volume_high and cost_sensitive:
        return "self-host"       # steady volume pe per-call API cost bachti hai
    return "api"                 # default: zero ops, best quality
  • On-device kya buy karta hai: offline, zero per-request cost, fixed latency, data bahar nahi. Kya deta hai: chhota model (quality trade) aur device matrix ka QA.
  • Self-host tab: privacy chahiye par model device pe fit nahi, ya volume steady hai jahan per-call API cost operational effort se zyada bhaari ho.
  • API tab: quality first, network available, scale variable — ops zero.
  • Ek application ke teen paths chalna normal hai: on-device dictation draft, cloud se final polish, specific job managed service — decision per modality aur per feature.
Interview line: Placement ek binary nahi, ek matrix hai — har modality ke liye columns bharo: offline, privacy, latency, volume. Cell hi jawab de deta hai, aur tumhara reasoning bhi dikhta hai.

Exercise

Question: Weights ki precision kam karke model ka size aur speed behtar karna — kya kehlata hai?

Question: On-device inference se per-request kitna cost aata hai? (ek shabd ya number)

Question: Sustained inference se phone ka performance dheere-dheere girta hai — uska naam? (do shabd)

Question: On-device, self-host aur API ka faisla kis level pe liya jaata hai — app-level ya per-modality?

Common mistakes

  • Quantized model ko bina eval ke production mein chhod dena: Numbers, names aur fine text pe chup-chaap quality gir jaati hai. Fix: same task set pe full vs quantized compare, critical fields pe verification layer.
  • Sirf flagship phone pe test karna: Dev device fast hoti hai; user ke budget phones pe thermal throttling aur OOM aata hai. Fix: slowest supported device hi benchmark device ho.
  • Privacy claim sirf "we do not store" se justify karna: Audio agar device se bahar ja raha hai toh storage se farq nahi padta. Fix: on-device ya strict processing path — claim ko architecture se prove karo.
  • Poora stack ek hi jagah pakad lena: Ek option har modality ki need nahi samajhta — offline dictation aur heavy vision alag maang rakhte hain. Fix: per-modality matrix, decision cell se aayega.
Desi example: Bijli vibhag, borewell aur overhead tank

Ghar ka connection (API) sasta aur reliable hai par band ho sakta hai; chhota overhead tank (on-device) roz ke kaam ke liye turant aur free; apartment ka borewell (self-host) sabke liye sasta par maintenance tumhari. Har need ka alag source — sab kuch tanker se mangwana bekaar:

text
api        -> bijli vibhag: zero maintenance, bill per use
self-host  -> borewell: privacy + volume pe sasta, par pump tumhara
device     -> overhead tank: offline, free, capacity limited
har modality ke liye alag decide karo — sab ek hi source nahi
Interview angle — yahan se sawaal aate hain
  • Q: Modalities on-device kyun suit karti hain? — Chhote specialized models, private input (voice/faces), aur network round trip jo aksar slowest part hota hai.
  • Q: Quantization kya hai aur uska cost? — Weights ko kam precision mein store karna: size/speed better, par exactness (numbers, names, fine text) pehle girti hai.
  • Q: Phone pe sustained inference ki teen limits? — Memory ceiling, thermal throttling, battery drain — teeno design inputs hain, QA ke baad ke nahi.
  • Q: On-device vs self-host vs API kaise split karoge? — Per modality: offline/privacy strict → device (agar model fit) ya self-host; warna volume/quality ke hisaab se API.
Lesson complete?

Placement ka matrix clear — quantization trade, device limits aur device-vs-self-host-vs-API decision ab tumhare paas hai. Ab aakhri lesson — Capstone: Ship a Multimodal Build — mein L12 ke sab pieces jod kar ek shippable feature banayenge.

Popular courses: Data Science Course in Lucknow · AI Course in Lucknow · Python Course in Lucknow · Power BI Course · Data Analytics Course