Instructions to use TwoheartsTechnologies/GoiBERT-M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use TwoheartsTechnologies/GoiBERT-M with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="TwoheartsTechnologies/GoiBERT-M")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("TwoheartsTechnologies/GoiBERT-M") model = AutoModel.from_pretrained("TwoheartsTechnologies/GoiBERT-M", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Align model card with the arXiv paper (2610.30067): paper naming, 8-task results, limitations, citation
Browse files
README.md
CHANGED
|
@@ -6,32 +6,34 @@ language:
|
|
| 6 |
- vi
|
| 7 |
---
|
| 8 |
|
| 9 |
-
# GoiBERT-M: a
|
| 10 |
|
| 11 |
-
GoiBERT-M is a **49.4M-parameter** Vietnamese RoBERTa encoder,
|
| 12 |
|
| 13 |
-
|
| 14 |
|
| 15 |
-
> This is the **backbone encoder only**
|
| 16 |
|
| 17 |
## Model details
|
| 18 |
|
| 19 |
| | |
|
| 20 |
|---|---|
|
|
|
|
| 21 |
| Architecture | RoBERTa encoder: 12 layers, hidden size 512, 8 attention heads, FFN size 2,048 |
|
| 22 |
| Parameters | 49,366,016 (encoder, no pooler) |
|
| 23 |
| Tokenizer | BamiBERT tokenizer, vocabulary 20,481; takes raw (unsegmented) Vietnamese text |
|
| 24 |
| Recommended max length | **256 tokens**. Distillation used 256-token sequences, so position embeddings beyond 256 are untrained. |
|
| 25 |
-
|
|
| 26 |
-
| Family | GoiBERT-S (
|
|
|
|
| 27 |
|
| 28 |
## Usage
|
| 29 |
|
| 30 |
```python
|
| 31 |
from transformers import AutoTokenizer, AutoModel
|
| 32 |
|
| 33 |
-
tokenizer = AutoTokenizer.from_pretrained("
|
| 34 |
-
model = AutoModel.from_pretrained("
|
| 35 |
|
| 36 |
inputs = tokenizer("Sản phẩm dùng tốt, giao hàng nhanh.", return_tensors="pt",
|
| 37 |
truncation=True, max_length=256)
|
|
@@ -82,33 +84,35 @@ The 6 × 768 variant has about 2× lower single-sequence GPU latency.
|
|
| 82 |
|
| 83 |
## Evaluation
|
| 84 |
|
| 85 |
-
|
| 86 |
|
| 87 |
**Protocol**
|
| 88 |
|
| 89 |
-
- 3 seeds per task.
|
| 90 |
-
-
|
| 91 |
-
- Test set evaluated **once**, from a manifest locked before test access.
|
| 92 |
|
| 93 |
**Fine-tuning recipe**
|
| 94 |
|
| 95 |
- 30 epochs, batch size 32, layer-wise learning-rate decay (γ = 0.8).
|
| 96 |
-
- Loss: cross-entropy plus knowledge distillation from out-of-fold CafeBERT soft labels (α = 0.5, T = 2).
|
| 97 |
|
| 98 |
-
**BamiBERT baseline.**
|
| 99 |
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
| Dataset | Metric | BamiBERT (103M) | GoiBERT-S (26M) | **GoiBERT-M (50M)** |
|
| 103 |
|---|---|---:|---:|---:|
|
| 104 |
-
|
|
| 105 |
-
|
|
| 106 |
-
|
|
| 107 |
-
| UIT-ABSA Restaurant |
|
| 108 |
-
| UIT-ABSA Hotel |
|
| 109 |
-
|
|
| 110 |
-
|
|
| 111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
|
| 113 |
**Inference efficiency.** Encoder only. GPU: NVIDIA L40S, bf16. CPU: fp32, 8 threads.
|
| 114 |
|
|
@@ -123,6 +127,27 @@ GoiBERT-M was fine-tuned on 7 Vietnamese benchmarks, covering 13 metrics.
|
|
| 123 |
|
| 124 |
GoiBERT-M has the same depth as BamiBERT (12 layers). For single sequences on GPU, latency is bound by per-layer overhead, so it matches BamiBERT. The speed-up appears with batched inference and on CPU.
|
| 125 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
## License and commercial use
|
| 127 |
|
| 128 |
This release is offered under the [GoiBERT Community Model License](LICENSE)
|
|
|
|
| 6 |
- vi
|
| 7 |
---
|
| 8 |
|
| 9 |
+
# GoiBERT-M (GoiBERT-large): a compact Vietnamese encoder
|
| 10 |
|
| 11 |
+
GoiBERT-M is the Hugging Face release of **GoiBERT-large** from the paper [GoiBERT: Compact Vietnamese Language Models via Two-Stage Knowledge Distillation](https://arxiv.org/abs/2610.30067). It is a **49.4M-parameter** Vietnamese RoBERTa encoder, under half the size of BamiBERT, distilled from BamiBERT on a cleaned 329M-token Vietnamese corpus. It uses BamiBERT's tokenizer (20,481 tokens) and takes raw text, with no word segmentation needed.
|
| 12 |
|
| 13 |
+
On 8 Vietnamese benchmarks, GoiBERT-large has the **highest average among non-teacher models** in the paper: **81.13**, against 80.71 for PhoBERT-v2 and 80.65 for BamiBERT. It has about **2× BamiBERT's batched GPU throughput** and uses about **half the GPU memory**.
|
| 14 |
|
| 15 |
+
> This is the **backbone encoder only**, with no task head. Fine-tune it for your task.
|
| 16 |
|
| 17 |
## Model details
|
| 18 |
|
| 19 |
| | |
|
| 20 |
|---|---|
|
| 21 |
+
| Paper name | GoiBERT-large |
|
| 22 |
| Architecture | RoBERTa encoder: 12 layers, hidden size 512, 8 attention heads, FFN size 2,048 |
|
| 23 |
| Parameters | 49,366,016 (encoder, no pooler) |
|
| 24 |
| Tokenizer | BamiBERT tokenizer, vocabulary 20,481; takes raw (unsegmented) Vietnamese text |
|
| 25 |
| Recommended max length | **256 tokens**. Distillation used 256-token sequences, so position embeddings beyond 256 are untrained. |
|
| 26 |
+
| Teachers | Stage 1: [BamiBERT](https://huggingface.co/Qualcomm-AI-Research/BamiBERT) (102.4M), used unchanged. Stage 2 (fine-tuning only): [CafeBERT](https://huggingface.co/uitnlp/CafeBERT) out-of-fold soft labels |
|
| 27 |
+
| Family | [GoiBERT-S](https://huggingface.co/TwoheartsTechnologies/GoiBERT-S) (GoiBERT-base, 26.4M), [GoiBERT-M](https://huggingface.co/TwoheartsTechnologies/GoiBERT-M) (GoiBERT-large, 49.4M) |
|
| 28 |
+
| Paper | [arXiv:2610.30067](https://arxiv.org/abs/2610.30067) |
|
| 29 |
|
| 30 |
## Usage
|
| 31 |
|
| 32 |
```python
|
| 33 |
from transformers import AutoTokenizer, AutoModel
|
| 34 |
|
| 35 |
+
tokenizer = AutoTokenizer.from_pretrained("TwoheartsTechnologies/GoiBERT-M")
|
| 36 |
+
model = AutoModel.from_pretrained("TwoheartsTechnologies/GoiBERT-M")
|
| 37 |
|
| 38 |
inputs = tokenizer("Sản phẩm dùng tốt, giao hàng nhanh.", return_tensors="pt",
|
| 39 |
truncation=True, max_length=256)
|
|
|
|
| 84 |
|
| 85 |
## Evaluation
|
| 86 |
|
| 87 |
+
Results are from Table 1 of the [paper](https://arxiv.org/abs/2610.30067): test sets, mean of 3 fine-tuning seeds, one metric per task (%).
|
| 88 |
|
| 89 |
**Protocol**
|
| 90 |
|
| 91 |
+
- 3 seeds per task; epoch and learning rate chosen on validation.
|
| 92 |
+
- Test set evaluated **once** per model, from a manifest locked before test access.
|
|
|
|
| 93 |
|
| 94 |
**Fine-tuning recipe**
|
| 95 |
|
| 96 |
- 30 epochs, batch size 32, layer-wise learning-rate decay (γ = 0.8).
|
| 97 |
+
- Loss: cross-entropy plus knowledge distillation from out-of-fold [CafeBERT](https://huggingface.co/uitnlp/CafeBERT) soft labels (α = 0.5, T = 2). CafeBERT is used only as a task teacher during fine-tuning; it is not part of the released weights.
|
| 98 |
|
| 99 |
+
**BamiBERT baseline.** Re-run under the same downstream protocol, with its learning rate tuned on validation and standard cross-entropy fine-tuning.
|
| 100 |
|
| 101 |
+
| Task | Metric | BamiBERT (102.4M) | GoiBERT-base (26.4M) | GoiBERT-large (49.4M) |
|
|
|
|
|
|
|
| 102 |
|---|---|---:|---:|---:|
|
| 103 |
+
| ViNLI | macro-F1 | 80.18 | 75.86 | 78.52 |
|
| 104 |
+
| ViSpamReviews | macro-F1 | 77.55 | 76.52 | 78.13 |
|
| 105 |
+
| PhoNER_COVID19 (syllable) | entity F1 | 94.32 | 92.97 | 93.47 |
|
| 106 |
+
| UIT-ABSA Restaurant | aspect-sentiment pair F1 | 73.53 | 74.15 | 76.00 |
|
| 107 |
+
| UIT-ABSA Hotel | aspect-sentiment pair F1 | 73.94 | 75.01 | 75.67 |
|
| 108 |
+
| UIT-VSFC topic | macro-F1 | 78.88 | 80.17 | 80.42 |
|
| 109 |
+
| UIT-VSFC sentiment | macro-F1 | 82.36 | 81.50 | 82.03 |
|
| 110 |
+
| UIT-ViSFD | aspect-sentiment pair F1 | 84.41 | 83.94 | 84.78 |
|
| 111 |
+
| **Average (8 tasks)** | | **80.65** | **80.02** | **81.13** |
|
| 112 |
+
| Parameters | | 102.4M | 26.4M | 49.4M |
|
| 113 |
+
| GFLOPs per 128-token input | | 22.4 | 4.8 | 10.1 |
|
| 114 |
+
|
| 115 |
+
The paper's Table 1 also reports CafeBERT (task teacher), XLM-R, ViSoBERT and PhoBERT-v2 on the same tasks.
|
| 116 |
|
| 117 |
**Inference efficiency.** Encoder only. GPU: NVIDIA L40S, bf16. CPU: fp32, 8 threads.
|
| 118 |
|
|
|
|
| 127 |
|
| 128 |
GoiBERT-M has the same depth as BamiBERT (12 layers). For single sequences on GPU, latency is bound by per-layer overhead, so it matches BamiBERT. The speed-up appears with batched inference and on CPU.
|
| 129 |
|
| 130 |
+
## Limitations
|
| 131 |
+
|
| 132 |
+
As stated in the paper:
|
| 133 |
+
|
| 134 |
+
- GoiBERT trails BamiBERT on ViNLI and PhoNER_COVID19; compression is costlier for inference and entity recognition than for sentiment and classification.
|
| 135 |
+
- The comparison with BamiBERT is not a pure architecture comparison: GoiBERT also uses CafeBERT distillation, layer-wise learning-rate decay and benchmark training text in its distillation corpus.
|
| 136 |
+
- General distillation was run once per model, so seed ranges reflect fine-tuning only.
|
| 137 |
+
- Inputs are limited to 256 tokens; dialects and unseen domains have not been evaluated.
|
| 138 |
+
- Efficiency figures exclude tokenization, task heads and the cost of training the teachers.
|
| 139 |
+
|
| 140 |
+
## Citation
|
| 141 |
+
|
| 142 |
+
```bibtex
|
| 143 |
+
@article{goibert2026,
|
| 144 |
+
title = {GoiBERT: Compact Vietnamese Language Models via Two-Stage Knowledge Distillation},
|
| 145 |
+
author = {Tran, Quang Anh Kiet and Tran, Nam Anh and Trinh, Manh Hung and Le, Thanh Danh and Vo, Khang Nhat Hoang and Tran, Huynh Dai Nhan},
|
| 146 |
+
journal = {arXiv preprint arXiv:2610.30067},
|
| 147 |
+
year = {2026}
|
| 148 |
+
}
|
| 149 |
+
```
|
| 150 |
+
|
| 151 |
## License and commercial use
|
| 152 |
|
| 153 |
This release is offered under the [GoiBERT Community Model License](LICENSE)
|