How Neam reads a Khmer article
Real news text is full of invisible characters, and articles are longer than the model can read at once. Neam has to cut the text into words, read it in pieces and still point every answer at the exact characters in the original. This page follows an invented, news-style article through those steps.
- Hidden charactersRemove them for the model only, and keep every word's original position.
- Overlapping windowsRead long articles in overlapping windows, and take each word from the window where it has the most context.
- Back to the textTurn word labels into character spans that match the original exactly.
Reading a long article in overlapping windows
Below is an invented news-style article written for this page, about a road-safety campaign in Kampong Cham. The people and the event are fictional. It has words and pieces; the windows, piece counts and tags come from running it through the released Neam model. Each bar is a window. Drag along the article strip, or use the slider, to pick a word. For every window that contains the word, the cards show how much context it has on each side; the window with the larger weaker side wins.
| Method | Words with fewer than 16 pieces of context on their weaker side |
|---|---|
| Back-to-back chunks | |
| Neam's overlapping windows |
Coloured ticks under the strip are the names Neam found: people, organizations, places. The article edges count as full context, because there is nothing more to read.
What it changed
Overall, little: validation F1 moved from 76.28 to 76.50. But organization F1 rose by 4.6 to 6.4 points in all four comparisons, and it recovered a country name that had been missed at the end of a long article. Organization names are long, so they are the most likely to be cut in half. We kept the windows because they remove a systematic blind spot and have no settings to tune.
Where the rule comes from
The "most context on the weaker side" rule is the one Google's original BERT code uses for question answering over long documents (_check_is_max_context in BERT's SQuAD script). Neam applies it to named entity recognition, builds windows from whole words, advances them by about half a window, and right-aligns the last one so it stays full.
Technical detail: the window rule
For word j in window W = [a, b), let LW(j) and RW(j) be the pieces to its left and right inside W, counted as infinite at a document edge. Each word is read from exactly one window:
Windows hold at most 128 pieces including the two special tokens, so 126 for words. In this article that gives the six windows shown above; the last two overlap heavily because the last one is right-aligned.
Back to the exact characters
The scorer was dropping punctuation
Validation F1 54.90 → 69.03, same model weights.
Turning word labels back into spans dropped punctuation inside names, such as the dots in an initialism ("U.S.A." came back as "U.S.A"), and mishandled prefixes. Under exact matching, those correct predictions counted as errors. Fixing it before any retraining raised the baseline by 14 points.
Names that crossed a line break
Held-out F1 86.70 → 86.98, same model (release 0.2.1).
Articles are imported line by line, but a name could still be joined across a line break, gluing the end of one paragraph to the start of the next. Since 0.2.1, a name never spans a line break, and the article importer trims menu lines at the edges of Khmer pages.
The lesson
Check the path from model output to score before training anything new. Every Neam model is scored through exactly the same code the app uses (segmentation, windows, decoding, reconstruction and display rules), so a fix here applies to every model and every number.