A Tiny BERT Model Hits 93% F1 Tagging Centuries of Portuguese Archives
A fine-tuned Portuguese BERT hits 93% F1 on named entity recognition for archival text, pulling nearly 900K downloads on Hugging Face.
Takeaways
- Portuguese BERT fine-tuned for NER hits 93.12% F1 and 97% accuracy on archival documents.
- Built on BERTimbau, tags Person, Place, Date, Profession, Organization.
- MIT licensed, works with the standard Transformers
token-classificationpipeline out of the box. - Trained in just 4 epochs with batch size 16 and learning rate 2e-05.
- Best-in-class results on archival text but drops to ~68% F1 on unseen domains.
- Full methodology published in Machine Learning and Knowledge Extraction.
A quiet Hugging Face checkpoint has become one of the more heavily used Portuguese NLP tools in circulation. lfcc/bert-portuguese-ner is a fine-tuned token classifier that tags people, places, dates, professions, and organizations in Portuguese text, and it has racked up hundreds of thousands of downloads despite being a small academic release rather than a big-lab launch.
What the model actually does
The checkpoint fine-tunes neuralmind/bert-base-portuguese-cased for token classification on Portuguese archival documents, with annotated labels for Date, Profession, Person, Place, and Organization. It ships under an MIT license and works out of the box with the standard Transformers token-classification pipeline.
Loading it is a two-line affair:
from transformers import pipeline
pipe = pipeline("token-classification", model="lfcc/bert-portuguese-ner")
print(pipe("D. Fernando nasceu em Lisboa em 1345."))
The numbers behind the hype
On its evaluation set the model reports a loss of 0.1140, precision of 0.9147, recall of 0.9483, an F1 of 0.9312, and accuracy of 0.9700. Training was short and cheap: a learning rate of 2e-05, batch size 16 for both train and eval, seed 42, Adam optimizer with betas (0.9, 0.999) and epsilon 1e-08, a linear scheduler, and just 4 epochs. F1 essentially peaked at epoch 3 and held steady, which suggests the model saturates fast on this domain.
Archives, not tweets
Most Portuguese NER work has piggybacked on generic corpora like HAREM or SIGARRA, which draw from newspapers and university web content. The authors describe in their paper a different target: archival finding aids, the descriptive documents that catalog holdings in institutions like the Arquivo Distrital de Braga and the Arquivo Nacional da Torre do Tombo. These records span centuries of Portuguese history but historically lacked annotation, making their content hard to analyze at scale.
Because generic pre-trained models underperformed on this material, the team built their own annotated corpora across eight archival datasets and trained several architectures to compare. The training data contains 164,478 tokens across 6,302 phrases, annotated with Person, Profession or Title, Place, Date, and Organization entities.
How it stacks up
The paper benchmarked three approaches: Apache OpenNLP (Maximum Entropy), spaCy (CNN-based transition parser), and a BI-LSTM-CRF built with TensorFlow. On individual corpora the deep learning approaches dominated, and on a generalized model trained across all datasets, BI-LSTM-CRF averaged 93.64% F1, spaCy 90.76%, and OpenNLP 86.96%. The BERT release on Hugging Face pushes the ceiling further by leveraging BERTimbau, the Portuguese-language BERT base from Neuralmind.
Where it works and where it breaks
The honest limitation surfaces when the model meets genuinely unseen text. In the paper's out-of-domain test on a Braga streets corpus, the generalized models scored much lower, with the best one reaching only an F1 of 68.42, well below the in-domain results. The authors trace this to sparse training coverage of Organization and Profession entities, and to vocabulary drift in centuries-old documents.
A few practical notes if you plan to use it:
- It shines on archival, genealogical, and historical Portuguese text where entities are people, places, dates, organizations, and professions.
- Expect degradation on modern conversational Portuguese, tweets, or technical prose, since the training data skews to formal archival descriptions.
- Old orthography and pre-modern place names may still trip it up given how much Portuguese vocabulary has shifted over the centuries.
- It emits BIO tags at the token level, so you will likely want an aggregation strategy (
aggregation_strategy="simple"in the pipeline) to merge subwords back into full entity spans.
Why it matters
Portuguese remains under-served in NER compared to English, and specialized domains within it even more so. A checkpoint that clears 93% F1 on a well-defined domain, ships under MIT, plugs directly into the Transformers pipeline, and requires no fine-tuning to get going is a rare combination. For anyone building search, entity linking, or knowledge graph tooling over Portuguese historical records, digital humanities projects, or Lusophone government archives, this is a strong drop-in baseline that would otherwise require assembling a labeled dataset and training from scratch.