Research and engineering
How SinAi was built, and what the evidence says.
Explore the technical foundation of SinAi—including data pipelines, model architecture, empirical benchmarks, and newsroom field evaluations.
Deep dives by tool
The data
Over a million articles, filtered down to what is worth learning from.
We collected public Sinhala news articles, removed noise and duplicates, and built targeted training sets for each writing tool.
From collected to kept
Articles from Sri Lankan Sinhala news sites, 13 March 2008 – 4 March 2026.
365,569 articles (35.4%) were removed.
An article had to pass all of these
- Exact duplicate articles removed
- Article body between 300 and 10,000 characters
- Title between 10 and 200 characters
- At least 30% of characters are Sinhala Unicode
What the kept articles are about
The mix is very uneven, which matters later (see the headline test leak).
Four training sets, one per tool
Grammar checker
36,006 rows
Correct or incorrect input paired with the corrected text
Headline generator
43,737 training rows
Article, category and reference headline
About 4,795 held out for validation
News summarizer
35,547 articles
Article with short, medium and long summaries
Style rewriter
7,555 rewrites
Article, target style and rewritten article
Kept from 22,236 candidates (34.0%)
Source: Paper, “Corpus and Task Datasets”.
How it fits together
Three apps, one backend, and a model gateway that does not fall over.
All three applications connect to a unified backend that routes requests to specialized models with reliable fallback protection.
Backend API (FastAPI)
- Checks who you are (signed tokens)
- Applies rate limits and feature switches
- Builds the prompt the task was trained on
- Checks and saves the result
Model gateway
Tries each tier in order. If one fails, the next answers.
- Research model. SinLlama base with the task’s LoRA adapter, on the GPU server.
- Hosted backup. A hosted language model (via OpenRouter) when the GPU server is down.
- Rule-based fallback. Deterministic output that never fails, so the product keeps responding.
Database (Supabase Postgres)
- Per-user history under row-level security
- Runtime settings and feature switches
- Audit log and usage telemetry
The AI engine
More than a chatbot wrapper: specialists, fallbacks and fact checks.
Task-specific adapters, high-availability model routing, and automated rule-based fact checks.
The base model
SinAi builds on SinLlama, adapting it with task-specific LoRA weights, curated Sinhala news datasets, automated fact checks, and a production inference gateway.
H. W. K. Aravinda et al., “SinLlama – a large language model for Sinhala”, MERCon 2025, pp. 617–622. Read the SinLlama paper
One shared base, four specialists
Each tool has its own small add-on model.
The system adapts the SinLlama base model with a separate LoRA adapter for each task. The base is loaded once in 4-bit form and the adapter for the requested task is swapped in, so one GPU can serve all four tools.
It keeps working when the GPU is down
If the main model is offline, a backup answers.
Every request goes through a model gateway that tries the research model first, then a hosted backup model, then a deterministic rule-based fallback. Each response reports which one answered so the app can label it.
Prompts match how the models were trained
Each task is asked the way it was taught.
The backend reproduces the exact instruction templates the adapters were trained on. Length is controlled in the prompt, and headlines outside the requested word band are regenerated and, if needed, trimmed.
Headlines are checked against the article
Invented numbers get flagged.
A rule-based check compares the numbers and words in a generated headline with the source article and flags mismatches for a human to review. It runs without retraining the model.
Grammar edits pass a rule validator
Risky edits are caught before you see them.
A validator reviews each grammar correction and can flag or roll back edits that change names or numbers, while keeping the corrections that are right.
Engineering challenges
What went wrong, and what we did about it.
Five critical data, modeling, and evaluation hurdles solved during project development.
A test score that was too good to be true
The headline model’s first evaluation looked twice as good as it really was.
- The problem
- To give small news categories enough examples, articles were duplicated before the data was split into training and test sets.
- What we found
- Copies of the same article ended up on both sides, so the model was partly graded on text it had already seen. ROUGE-1 read 0.2933 with 485 exact matches; on a clean split it was 0.1382 with none.
- What we did
- Repaired the split so no article appears on both sides. The paper reports both sets of numbers so the difference is visible.
A summary test that was 81% contaminated
Most of the “unseen” test articles for the summarizer had actually been seen in training.
- The problem
- Each article was expanded into short, medium and long examples and then shuffled. An article only stays unseen if all three versions land in the test set, which happens about 0.34% of the time.
- What we found
- An audit found about 81% of the nominal held-out articles had already appeared in training under another length.
- What we did
- Rebuilt the split per article (80/10/10), froze a 300-article evaluation set and retrained. The two training recipes then turned out to perform almost identically.
Most generated training data was unusable
For the style rewriter, only about a third of the machine-written examples were good enough to keep.
- The problem
- Generated rewrites often copied the source, repeated phrases, changed facts or broke the script.
- What we found
- Only 7,555 of 22,236 candidates (34.0%) passed the checks for copying, repetition, factual consistency, structure, script and length.
- What we did
- Kept only the passing examples. The v13 adapter trained on them shows a 0% direct-copy rate in the paper’s diagnostic.
Two invisible characters that look the same
Cleaning Sinhala text the usual way can quietly break it.
- The problem
- Scraped Sinhala contains two visually similar invisible characters: a soft hyphen and a zero-width joiner.
- What we found
- The soft hyphen (in 85.8% of rows in one working file) disrupts tokenization and should go. The zero-width joiner is part of valid letter combinations and must stay.
- What we did
- Character-aware cleaning instead of a blanket “strip invisible characters” rule.
A safety net that cost accuracy
A rule-based checker meant to protect grammar edits was blocking good corrections too.
- The problem
- Rules were added to stop the grammar model from changing names or numbers.
- What we found
- The first, blanket-veto version dropped exact match from 66.88% to 57.14% by blocking useful edits.
- What we did
- A selective policy restored 66.88% and removed the one observed unsupported name change. The paper flags this as an ablation on the development set.
Results
What the measurements say, and what they do not.
Quantitative evaluation scores from our benchmark test sets, shown with sample sizes and evaluation caveats.
Grammar checker
Evaluated adapter v27 · r=4, α=456.99%
Output exactly matches the corrected reference
Measured on: 286 hand-reviewed inputs (143 faulty, 143 clean controls)
Strict exact match: a valid fix worded differently still counts as a miss.
63 of 143
Faulty sentences corrected
Measured on: The 143 faulty inputs
Baselines on the same inputs: ByT5-small corrected 12 and mT5-small corrected none.
66.88% → 66.88%
Rule validator added to the grammar model
Measured on: 154 saved development predictions
The validator removed the one observed unsupported name change without losing any correct edits. It was tuned on this set, so the paper calls it an ablation, not an independent benchmark.
Headline generator
Evaluated adapter v19 · r=64, α=12879.7%
Headline lands in the requested length band
Measured on: 900 generated headlines
By band: short 89.7%, medium 74.3%, long 75.0%.
1.1%
Headlines containing scraped-site artifacts
Measured on: 900 generated headlines
The previous version (v18) had 11.2%. The fix was cleaning the training headlines.
0.1824
Overlap with reference headlines (ROUGE-1)
Measured on: 100 articles from an external publisher
Headlines have many valid wordings, so overlap scores are low by nature. Up from 0.1567 for the earlier v17.
Style rewriter
Evaluated adapter v13 · r=24, α=480.784
Overlap with reference rewrites (ROUGE-L)
Measured on: 75 outputs (15 per style)
A development diagnostic, not a style-accuracy score: it ranges from 0.730 (editorial) to 0.892 (formal), and the paper says a production-prompt test is still needed.
0%
Outputs that simply copy the input
Measured on: 75 outputs (15 per style)
Earlier data had serious copying and repetition; the final data pipeline removed it.
News summarizer
Evaluated adapter v06 / v07 · r=32, α=6486.8% – 94.1%
Summary follows the requested length
Measured on: 273 held-out articles, 819 summaries
Range across the short, medium and long bands. More than 94% of outputs also end cleanly.
0.457 – 0.508
Overlap with reference summaries (ROUGE-L)
Measured on: 273 held-out articles, 819 summaries
The cleaned (v07) and raw (v06) training recipes were effectively tied, with a largest gap of 0.0018.
Source: Paper, results sections for each task.
Human evaluation
How 13 people rated each tool
Pilot feedback from 13 journalists, editors, and lecturers who tested all four tools (27–31 August 2026).
Who took part
- Journalism students5
- Editors4
- School teachers2
- Other students2
How often they work with Sinhala news
- Daily5
- Several times a week5
- Sometimes2
- Rarely1
Grammar checker
The system correctly found grammar errors.
4.2 / 5 · 11 of 13 rated 4–5
The suggested corrections were correct and useful.
4.4 / 5 · 11 of 13 rated 4–5
The grammar checker is useful for journalism work.
4.4 / 5 · 11 of 13 rated 4–5
Headline generator
The generated headline matched the news article.
4.2 / 5 · 12 of 13 rated 4–5
The generated headline was suitable for a news article.
4.1 / 5 · 10 of 13 rated 4–5
The headline generator is useful for journalism work.
4.5 / 5 · 12 of 13 rated 4–5
Style rewriter
The rewritten text kept the original meaning.
4.2 / 5 · 11 of 13 rated 4–5
The rewritten text was natural and professional.
4.2 / 5 · 10 of 13 rated 4–5
The style rewriter is useful for journalism work.
4.4 / 5 · 11 of 13 rated 4–5
News summarizer
The summary included the main points of the news article.
4.3 / 5 · 12 of 13 rated 4–5
The summary was clear and easy to understand.
4.3 / 5 · 12 of 13 rated 4–5
The summarizer is useful for journalism work.
4.4 / 5 · 12 of 13 rated 4–5
The system overall
The system was easy to use.
4.4 / 5 · 12 of 13 rated 4–5
The system was useful for journalism-related tasks.
4.4 / 5 · 12 of 13 rated 4–5
- 1 (disagree)
- 2
- 3
- 4
- 5 (agree)
Reading these results honestly
- Highest average: “The headline generator is useful for journalism work.” at 4.5.
- Lowest average: “The generated headline was suitable for a news article.” at 4.1.
- Every statement received at least one rating of 3 or below, so not every tester was satisfied with every result.
- Thirteen responses cannot show statistical significance. Treat these as a signal about where to improve, not a benchmark.
Source: SinAi user evaluation form (Google Forms), 13 responses, 27–31 August 2026.
Security and reliability
Built to be trusted with a newsroom’s drafts.
Built with secure authentication, row-level data privacy, and resilient fallback systems.
Hashed passwords
Passwords are hashed with bcrypt. Plain-text passwords are never stored.
Signed sessions
Sign-in issues signed access and refresh tokens. A refresh token cannot be replayed as an access token.
Per-user history
Saved history is protected by Postgres row-level security, so each person can read only their own records.
Admin-only areas
The admin dashboard and its API require an admin role.
Rate-limited anonymous use
Signed-out requests are limited per hour (20 by default) using a salted hash of the IP address, and their results are not saved.
Audit log
Changes made through the admin settings are recorded in an audit log.
Feature switches
Admins can turn each tool on or off without redeploying.
Tested offline
The backend test suite runs against a fake database and a mock model provider, so it needs no network or GPU.
Technology
The stack, in groups.
Core technologies grouped by architectural role across client, API, model, and data layers.
AI models
- SinLlama (Llama 3 8B extended for Sinhala)
- LoRA adapters, one per task
- 4-bit NF4 base with BF16 compute (QLoRA)
- Hosted fallback via OpenRouter
Backend
- Python
- FastAPI
- Pydantic
- httpx
- PyJWT and bcrypt
- pytest
Data
- Supabase (PostgreSQL)
- Row-level security
- Runtime settings and audit log
Web app
- React 19
- Vite
- Tailwind CSS
- Radix UI
- React Router
- Recharts
Other clients
- Chrome extension (Manifest V3)
- Google Docs add-on (Apps Script)
This website
- Next.js 16
- React 19
- Tailwind CSS 4
- Static export
Deployment
- Docker
- Coolify (self-hosted)
Timeline
How it came together.
Key development milestones tracked across research, implementation, and deployment phases.
Up to March 2026
Building the news corpus
Collected 1,031,456 Sinhala news articles (the latest dated 4 March 2026) and filtered them down to the 665,887-article corpus used for the task datasets.
Source: Paper
1–2 July 2026
Architecture and first clients
Loosely coupled backend, Supabase database, then the Chrome extension and the Google Docs add-on.
Source: git log
18 July 2026
Resilient model gateway
Three-tier fallback so the product keeps working while the GPU server is down, plus a unified history feed.
Source: git log
1–3 August 2026
Accounts, history and admin
Sign-in, per-user history under row-level security, the admin dashboard with feature switches and settings, then self-hosted authentication.
Source: git log
27–31 August 2026
User evaluation
Thirteen editors, journalism students and teachers tried the tools and rated them.
Source: Evaluation form
16–17 September 2026
Plans and interface polish
Plan tiers with usage tracking and a Sinhala/English interface toggle.
Source: git log
Limitations
What this evidence does not show.
Clear boundaries defining the scope and current limits of our research findings.
- Results are from the adapter versions evaluated in the paper. Those are not necessarily the versions currently deployed.
- The grammar benchmark is small (286 inputs) and scored by strict exact match, which under-counts valid alternative fixes.
- The style diagnostic (75 outputs) does not prove every output follows the requested style or keeps every fact. A production-prompt test is still needed.
- The user evaluation is 13 self-selected respondents. It shows early impressions, not a controlled study.
- AI output can be wrong. Editors should review every result before publishing.
Explore further
Check our work.
Explore our open-source codebase, technical documentation, and live demo environments.