AI Sentiment Analysis Implementation in Mobile Applications
Sentiment analysis in mobile context solves concrete tasks: automatic moderation of user reviews, real-time chat and comment sentiment analysis, feedback monitoring inside app. Choice between on-device model and cloud API determines everything — latency, privacy, cost, accuracy.
On-Device vs Cloud API
Cloud API (OpenAI, Google Cloud Natural Language, AWS Comprehend) — higher accuracy, especially on unstructured text, but each request costs money and needs network. For product analytics (reviews, surveys) — fine. For real-time analysis of every typed character — no.
On-device (CoreML + BERT / TensorFlow Lite + MobileBERT) — private, works offline, zero network latency. Downside: model weighs 40–80 MB, lower accuracy on edge cases, harder to maintain (retraining = app update or OTA model).
On iOS: CoreML with DistilBERT-sentiment model (converted via coremltools from Hugging Face checkpoint). Inference < 50 ms on iPhone 12+. Initialize MLModel on app startup, not first use — otherwise 300 ms delay on first analysis.
On Android: TensorFlow Lite with MobileBERT — similar approach. Initialize Interpreter in Application.onCreate() in background thread.
Sentiment Granularity
Basic positive/negative/neutral is too coarse for most tasks. Fine-grained sentiment provides more:
- Aspect-based sentiment: "delivery is great, but packaging is bad" — not one sentiment but two across aspects.
- Emotion classification: joy, anger, sadness, fear, surprise — more valuable for product analytics than just +/−.
- Intensity: very negative vs slightly negative — affects response priority.
In practice: for aspect-based — use cloud model (flair, spaCy with custom NER + sentiment pipeline) or GPT with structured output. On-device reaches only 3-class classifier without aspects.
Concrete Case: In-App Review Analysis
Feedback screen: user types text → analyze sentiment on-device as they type or on submit → if negative score > 0.7, before sending show "We're sorry you had trouble. Want to contact support right away?" → route to chat instead of public review. This is standard pattern to reduce negative public reviews.
Technical implementation: CoreMLSentimentAnalyzer.analyze(text) returns SentimentResult(label:score:). Debounce 500 ms so inference doesn't run on every character. Store result in ReviewDraft — on submit send to server with text.
Multilingual Support
Separate model per language — best accuracy but large bundle. XLM-RoBERTa is multilingual model, one for all languages, worse on each individually but much better than nothing. For Russian: DeepPavlov rubert-base-cased-sentiment — good accuracy on CIS data, converts to CoreML/TFLite.
Work Process
Define use case (real-time vs batch, on-device vs cloud), text languages, needed granularity. Choose model, integrate, tune threshold values for business logic, test on representative production data.
Timeline Guidelines
Integration of ready model (Cloud API or pre-trained CoreML/TFLite) with basic positive/negative/neutral — 3–5 days. Custom model with fine-tuning on your data, aspect-based analysis, multilingual support — 3–5 weeks. Pricing is calculated individually.







