Implementing Natural Language Processing in a Mobile Application
Your mobile app processes user reviews, support chats, or document scans. Sooner or later you need to add sentiment analysis, entity recognition, or automatic translation. We've been integrating NLP into mobile apps for five years. Our engineers are certified by Apple and Google, and every project starts with an audit of your data. Whether you're diving into mobile NLP development or comparing online vs offline NLP, this article provides practical advice. Choosing the right NLP architecture determines not only accuracy but also response time, app size, and user privacy. In this article, we share practical experience: how to avoid mistakes and save time and money.
Which Approach to Choose for NLP in a Mobile Application?
The choice between on-device and cloud NLP depends on the scenario. On-device is faster, more private, works offline. Cloud is more accurate, supports more languages, requires internet. We help you pick the optimal solution for your task.
| Criteria | On-device NLP | Cloud NLP |
|---|---|---|
| Inference speed | < 100 ms | 200–500 ms + network latency |
| Privacy | Data stays on device | Data sent to server |
| Offline operation | Yes | No |
| Accuracy | Lower (quantized models) | Higher (full models) |
| Integration complexity | Medium (model setup) | Low (REST API) |
Comparison: On-device NLP processes text 5–10 times faster than cloud provided the model is optimized for mobile. Our practice confirms this.
Mobile NLP Platform APIs: iOS Tokenization and NaturalLanguage Framework
Start with what's already on the device — it's resource-free and works offline.
iOS — NaturalLanguage framework:
import NaturalLanguage
// Language identification
let recognizer = NLLanguageRecognizer()
recognizer.processString("Hello, how are you?")
let language = recognizer.dominantLanguage // .english
// Tokenization
let tokenizer = NLTokenizer(unit: .word)
tokenizer.string = text
tokenizer.enumerateTokens(in: text.startIndex..<text.endIndex) { range, _ in
print(String(text[range]))
return true
}
// Sentiment analysis
let tagger = NLTagger(tagSchemes: [.sentimentScore])
tagger.string = text
let (sentiment, _) = tagger.tag(at: text.startIndex,
unit: .paragraph,
scheme: .sentimentScore)
let score = Double(sentiment?.rawValue ?? "0") ?? 0.0
// score: -1.0 (negative) ... +1.0 (positive)
Android — ML Kit Text APIs:
EntityExtraction (ML Kit) can find addresses, phones, dates, tracking numbers, money — offline, model downloads once (~8 MB). LanguageIdentification — analogous to NLLanguageRecognizer. The SmartReply model is covered in another service.
Apple NaturalLanguage Framework and ML Kit for Android are proven tools we use in every second project.
| Feature | iOS NaturalLanguage | Android ML Kit |
|---|---|---|
| Tokenization | Yes (NLTokenizer) | Yes (TextSegmentation) |
| NER | Yes (NLTag) | Yes (EntityExtraction) |
| Sentiment analysis | Yes (sentimentScore) | Yes (DocumentSentiment) |
| Language | Identification + tokens | Identification + classification |
| Size | Built-in | ~8 MB for entities |
When is Cloud API Better than On-Device? Online vs Offline NLP Comparison
If you need support for rare languages or maximum accuracy (e.g., legal documents), cloud services (OpenAI, YandexGPT, Google Cloud NLP) deliver better quality. We connect them as fallback or main engine when speed requirements are not critical.
Text Classification with TFLite for Mobile NLP
Platform APIs don't handle domain classification — they won't say "this is a food review" or "this is a technical support request." You need your own model.
Typical pipeline for a mobile NLP classifier:
- Training: BERT-tiny or MobileBERT (8 MB vs 100 MB for full BERT) on PyTorch/TF
- Conversion:
torch.onnx.export()→ ONNX →onnxruntime-mobile, ortf2tflite→.tflite - Quantization: int8 via TFLite Converter gives ~4x compression with minimal accuracy loss
More about quantization
Quantization to int8 reduces model size 4x and accelerates inference by 20-30% on CPU. On devices with DSP/NPU (Android 8.1+), acceleration can reach 10x. Important: classification accuracy may drop by 1-3%, which is usually acceptable for mobile scenarios.class TextClassifier(context: Context) {
private val interpreter: Interpreter
private val tokenizer: BertTokenizer
init {
val modelBuffer = loadModelFile(context, "bert_tiny_classifier.tflite")
interpreter = Interpreter(modelBuffer, Interpreter.Options().apply {
addDelegate(NnApiDelegate()) // Android Neural Networks API
})
tokenizer = BertTokenizer.fromAssets(context, "vocab.txt")
}
fun classify(text: String): ClassificationResult {
val tokens = tokenizer.encode(text, maxLength = 128, truncate = true)
val inputIds = Array(1) { tokens.inputIds.toIntArray() }
val attentionMask = Array(1) { tokens.attentionMask.toIntArray() }
val output = Array(1) { FloatArray(NUM_LABELS) }
interpreter.runForMultipleInputsOutputs(
arrayOf(inputIds, attentionMask),
mapOf(0 to output)
)
return output[0].argmax().let { ClassificationResult(label = LABELS[it], confidence = output[0][it]) }
}
}
NNAPI delegate on Android 8.1+ speeds up inference through DSP/NPU. On Pixel 7+ — up to 10x acceleration. On budget devices NNAPI may be slower than CPU — test on real hardware.
Named Entity Recognition
NER extracts named entities from text (persons, organizations, locations, dates). Use cases: auto-creating calendar events from messages, pre-filling forms from CVs, parsing receipts.
ML Kit EntityExtraction covers standard entities without training. For custom domains — own NER model based on BiLSTM+CRF or BERT. Model size: BiLSTM — 5–15 MB, DistilBERT-NER — ~60 MB in fp16.
On iOS NL framework returns NLTag with types: .personalName, .placeName, .organizationName. Works on-device offline.
Summarization and Translation
On-device summarization requires heavy models (BART, T5 at least 60–100 MB). For mobile — either extractive summarization (key sentence selection via TF-IDF + MMR, ~100 KB of logic) or cloud API (OpenAI, YandexGPT).
Machine translation: ML Kit Translation supports 59 languages, models download on demand (~30 MB per language pair). On iOS — MLTranslation via Apple Intelligence (iOS 18+) or cloud APIs.
User Input Processing: Cleaning and Normalization
A frequently overlooked step — text preprocessing before the NLP model. Typos, slang, emojis, mixed keyboard layouts (e.g., typing Russian words in Latin letters) all reduce accuracy. Apache Lucene Analyzers on Android or NLTokenizer with custom rules on iOS help normalize the text.
What Our Work Includes
We ensure a transparent process and deliver results with these steps:
- Analysis of your data and NLP requirements (accuracy, speed, languages)
- Selection of approach: platform APIs, custom on-device model, or cloud service
- Model development and training (if needed)
- Integration into the app with clean architecture (MVVM, MVI)
- Testing on real devices (30+ iOS/Android models)
- Documentation and training for your team
- Post-launch support (3-month warranty period)
Deliverables: API documentation, model access, team training, and 3-month support. Typical investment for platform APIs starts at $5,000, while custom model integration ranges from $15,000 to $50,000, delivering an average 40% time savings.
Why Trust Us with NLP Integration?
- 5+ years in mobile development
- 30+ projects with NLP (from review analysis to voice assistants)
- Certified engineers (iOS, Android, ML)
- Solutions run on 500+ million devices
- Time-to-market acceleration by 2x on average thanks to reusable components
- Our solutions have saved clients an average of 35% on development time
We will evaluate your project in 1 day. Contact us — we'll discuss your task and propose the optimal solution. Order NLP integration today.
Timeline Estimates
Integration of platform NLP APIs (sentiment, tokenization, NER) — 3–5 days. Custom classifier with training and mobile optimization — 3–6 weeks. Timelines are for turnkey work.







