A
fastText classifier for
Portuguese language variety identification . Distinguishes European Portuguese (PT-PT) from Brazilian Portuguese (PT-BR)
Designed for high-throughput filtering pipelines (e.g., Common Crawl processing).
1import fasttext
2from huggingface_hub import hf_hub_download
3
4# Full model ~1GB
5model_path = hf_hub_download(repo_id="duarteocarmo/fasttext-euptvid", filename="model.bin")
6model = fasttext.load_model(model_path)
7
8# Or quantized model ~68 MB
9# model_path = hf_hub_download(repo_id="duarteocarmo/fasttext-euptvid", filename="model_quantized.ftz")
10# model = fasttext.load_model(model_path)
11
12texts = [
13 "Bom dia, como é que está?",
14 "Bom dia, como você está?",
15 "O governo português anunciou novas medidas para combater a inflação.",
16 "O presidente Lula viajou para Brasília ontem à noite.",
17]
18
19# You might wanna do this
20# texts = [t.replace("\n", " ") for t in texts]
21
22labels, probs = model.predict(texts)
23
24for text, label, prob in zip(texts, labels, probs):
25 print(f"{label[0]:20s} ({prob[0]:.4f}) | {text}")
26
27# __label__PT_PT (0.9895) | Bom dia, como é que está?
28# __label__PT_BR (0.9794) | Bom dia, como você está?
29# __label__PT_PT (0.8577) | O governo português anunciou novas medidas para combater a inflação.
30# __label__PT_BR (0.9803) | O presidente Lula viajou para Brasília ontem à noite.
Scripts for training, data download, evals, it's
all on GitHub
Trained on ~6M text chunks from
bastao/VeraCruz_PT-BR, balanced across PT-PT and PT-BR.
Evaluated on the same benchmarks as
PTVid paper:
All metrics are
PT-PT F1 scores. Speed measured on Apple M3 Max. Full evaluation script:
eval_all.py.
1@misc{euptvid2026,
2 author = {Duarte O. Carmo},
3 title = {fasttext-euptvid: Fast Portuguese Variety Identification},
4 year = {2026},
5 url = {https://huggingface.co/duarteocarmo/fasttext-euptvid}
6}
1@article{joulin2016bag,
2 title={Bag of Tricks for Efficient Text Classification},
3 author={Joulin, Armand and Grave, Edouard and Bojanowski, Piotr and Mikolov, Tomas},
4 journal={arXiv preprint arXiv:1607.01759},
5 year={2016}
6}