Aspect-Based Sentiment Analysis for Indonesian Public Opinion
- PyTorch
- Hugging Face
- LoRA
- NLP
- Gradio
An opinion can support one part of a policy and criticize another. Giving the entire text a single sentiment label makes that distinction difficult to see. This prototype explores aspect-based sentiment analysis (ABSA) for Indonesian opinions about fuel prices (BBM) and elections (Pemilu).
The project extends an earlier sentiment-classification study into a small interactive demo. I wanted readers to try an opinion, explore its possible aspects, and see how the analysis changes with the selected topic.
Exploring the Prototype
Choose a Topic and Enter an Opinion
The workspace starts with two topics, Fuel (BBM) and Elections, followed by an opinion textbox. Selecting a topic determines the five specific aspects considered by the demo.
For fuel, those aspects cover price, subsidies, availability, economic impact, and governance. For elections, they cover scheduling, registration, organizer integrity, candidates and parties, and campaigns.

One workspace for choosing a topic, entering Indonesian text, and reading the result.
Open the Example Drawer
The See Examples button opens a panel beside the input. Each example fills in the opinion and selects its corresponding topic, so users can explore both domains without retyping the same text.
These are supplied demonstration sentences, rather than a claim that every example is an independently verified quotation from a real account.

Examples provide a quick starting point for testing the interaction.
Read the Aspect-Level Results
Analyze Opinion produces a list of aspects and sentiment badges. Positive, Negative, and Neutral use distinct colors. Aspects classified as not mentioned are normally omitted; when no aspect produces a result, the demo displays General (Non-specific) — Neutral.
The live example below shows how one opinion can produce multiple aspect labels.

In the tested example about fuel prices, transportation costs, and basic goods, the demo returns two negative aspect labels.
The pairwise task can be expressed as:
(text, aspect) → sentiment
(text, price) → Negative
(text, availability) → Positive
This illustrates the intended task, not a guaranteed prediction for mixed-sentiment sentences. A model still needs to connect each sentiment to the correct aspect.
What Happens Behind the Interface
The app uses Gradio, PyTorch, Transformers, and PEFT. It attempts to load the selected domain's LoRA adapter over indolem/indobertweet-base-uncased, then tokenizes each text–aspect pair and selects one of four classes.
Opinion + topic
↓
Text–aspect pairs
↓
IndoBERTweet + domain LoRA adapter
↓
Result processing
↓
Aspect and sentiment badges
Models are cached after loading. The local loader checks domain folders at the application root or under models/; adapter files must be placed where it expects them. The repository's outputs/ directory alone does not make the demo load those adapters.
Preparing the Aspect Data
The scaled local CSVs contain 1,200 source texts per domain. Each text is expanded across six aspect categories, including lainnya (other), producing 7,200 pairs per domain. The demo currently presents five named aspects with English descriptions; the training CSVs use Indonesian aspect identifiers. Aligning those representations is an important deployment check.
Labels were initially generated through rule-assisted weak labeling, then reviewed and verified by humans.
| Domain | Source texts | Pairs | Not mentioned |
|---|---|---|---|
| BBM | 1,200 | 7,200 | 5,973 |
| Pemilu | 1,200 | 7,200 | 6,297 |
The ABSA runner splits by tweet_id so all aspect pairs belonging to a source text stay together. Its prepared BBM manifest records 4,320 training, 1,440 validation, and 1,440 test pairs, a 60/20/20 partition. The manifest was generated in prepare-only mode and does not establish that training or evaluation completed.
Full Fine-Tuning and LoRA
The ABSA runner supports training all model parameters or applying Low-Rank Adaptation (LoRA). The saved adapters and runner agree on the following configuration:
| Setting | Value |
|---|---|
| Base model | indolem/indobertweet-base-uncased |
| LoRA rank | 8 |
| Alpha | 16 |
| Dropout | 0.1 |
| Target modules | query, value |
LoRA makes domain adaptation possible by training small additional matrices rather than updating every base-model weight. That motivation is separate from demonstrating a measured improvement. The inspected checkout contains adapters and preparation manifests, but no saved ABSA evaluation reports supporting a comparison of F1, GPU memory, or training time. I therefore treat this page as a prototype walkthrough rather than a validated benchmark result.
The earlier whole-text sentiment experiments are also a different task. Their historical scores should not be used as ABSA results or as evidence that LoRA prevents class collapse.
Comments
Share a question or feedback. Sign in with GitHub to comment.