Skip to content
All projects
AI/ML

Nepali Sentiment Analysis

Hybrid Transformer + CNN + BiLSTM sentiment model for Nepali text written in both Devanagari and Romanized script, reaching 73.88% accuracy and benchmarked against XLM-RoBERTa and NepaliBERT.

Key result

73.88% accuracyBenchmarked against XLM-RoBERTa and NepaliBERT

01Problem

Nepali is written in two scripts at once — Devanagari and Romanized transliteration — often mixed within a single sentence. Pretrained English models do not transfer, and the two scripts fragment an already small labeled corpus into inconsistent tokens.

02Objective

Build a sentiment classifier that handles both scripts in one model, and benchmark it honestly against the established multilingual and Nepali-specific baselines rather than reporting a single number in isolation.

03Architecture

  1. Bi-Script Nepali Text
  2. Preprocessing
  3. Transformer Encoder
  4. CNN + BiLSTM
  5. Sentiment Classification
Hybrid transformer classification pipeline

04Technology

  • Python
  • PyTorch
  • Transformers
  • CNN
  • BiLSTM
  • NLP
  • XLM-RoBERTa

05Implementation

Key technical decisions

  1. 01Handled Devanagari and Romanized Nepali in a single model rather than training two.
  2. 02Combined a transformer encoder with CNN and BiLSTM branches, so local n-gram and sequential signal are both represented.
  3. 03Benchmarked against XLM-RoBERTa and NepaliBERT to place the result against established baselines.
  4. 04Reported macro-F1 alongside accuracy so minority-class performance stays visible.

What was built

  • Preprocessing pipeline covering both writing systems.
  • Hybrid Transformer + CNN + BiLSTM architecture.
  • Evaluation against XLM-RoBERTa and NepaliBERT baselines.

06Data

Corpus and preprocessing

  • Nepali text corpus in Devanagari and Romanized script
  • Sentiment labels across the classification task
  • Code-mixed text where both scripts appear together
  • Preprocessing applied consistently across both writing systems

07Results

73.88%

Accuracy

0.737

Macro-F1

2 baselines

XLM-RoBERTa and NepaliBERT

10Links

No public repository for this one — happy to walk through the code on request.