Instructions to use hoaan/phobert-product-ner with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use hoaan/phobert-product-ner with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("token-classification", model="hoaan/phobert-product-ner")# Load model directly from transformers import AutoTokenizer, AutoModelForTokenClassification tokenizer = AutoTokenizer.from_pretrained("hoaan/phobert-product-ner") model = AutoModelForTokenClassification.from_pretrained("hoaan/phobert-product-ner", device_map="auto") - Notebooks
- Google Colab
- Kaggle
phobert-product-ner
This model is a fine-tuned version of vinai/phobert-base-v2 on the None dataset. It achieves the following results on the evaluation set:
- Loss: 1.0037
- Precision: 0.5
- Recall: 0.7
- F1: 0.5833
- Accuracy: 0.8077
Model description
Input
Important: The input text must already be word-segmented.
For example:
Tรดi muแปn mua sแปฏa_chua vinamilk
not:
Tรดi muแปn mua sแปฏa chua vinamilk
The model does not perform Vietnamese word segmentation itself.
Usage
The easiest way to use the model is with the Hugging Face pipeline API.
from transformers import pipeline
ner = pipeline(
"token-classification",
model="hoaan/phobert-product-ner",
aggregation_strategy="simple"
)
text = "tรดi muแปn mua sแปฏa_chua vinamilk"
result = ner(text)
print(result)
The model will return a list of detected entities:
[
{
'entity': 'B-PRODUCT_NAME',
'score': np.float32(0.4434441),
'index': 4,
'word': 'sแปฏa_chua',
'start': None,
'end': None
},
{
'entity': 'B-PRODUCT_NAME',
'score': np.float32(0.1281703),
'index': 5,
'word': 'vin@@',
'start': None,
'end': None
},
{
'entity': 'B-PRODUCT_NAME',
'score': np.float32(0.13579331),
'index': 6,
'word': 'amil@@',
'start': None,
'end': None
}
]
The exact scores depend on the input and model prediction.
Entity Labels
The model uses BIO-style labels internally, for example:
B-PRODUCT
I-PRODUCT
B-CATEGORY_NAME
I-CATEGORY_NAME
O
When using:
aggregation_strategy="simple"
Hugging Face automatically aggregates the token-level predictions into entity-level results.
For example:
B-PRODUCT I-PRODUCT
is returned as a single:
PRODUCT
entity.
Example
from transformers import pipeline
ner = pipeline(
"token-classification",
model="hoaan/phobert-product-ner",
aggregation_strategy="simple"
)
text = "tรดi ฤang tรฌm sแปฏa_chua vinamilk"
entities = ner(text)
for entity in entities:
print(
entity["entity_group"],
entity["word"],
entity["score"]
)
Using the Model Directly
If you need lower-level access, you can load the tokenizer and model directly:
from transformers import (
AutoTokenizer,
AutoModelForTokenClassification
)
model_id = "hoaan/phobert-product-ner"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForTokenClassification.from_pretrained(
model_id
)
For most users, however, the pipeline API is recommended.
Notes
- The model is designed for Vietnamese text.
- Input should be Vietnamese text that has already been word-segmented.
- The model performs token classification / NER; it does not perform word segmentation.
aggregation_strategy="simple"is recommended when you want entity-level results instead of individual token predictions.
Intended uses & limitations
More information needed
Training and evaluation data
More information needed
Training procedure
Training hyperparameters
The following hyperparameters were used during training:
- learning_rate: 5e-05
- train_batch_size: 4
- eval_batch_size: 4
- seed: 42
- optimizer: Use OptimizerNames.ADAMW_TORCH_FUSED with betas=(0.9,0.999) and epsilon=1e-08 and optimizer_args=No additional optimizer arguments
- lr_scheduler_type: linear
- num_epochs: 50
Training results
| Training Loss | Epoch | Step | Validation Loss | Precision | Recall | F1 | Accuracy |
|---|---|---|---|---|---|---|---|
| No log | 1.0 | 7 | 1.9580 | 0.0 | 0.0 | 0.0 | 0.6923 |
| No log | 2.0 | 14 | 1.7075 | 0.0 | 0.0 | 0.0 | 0.6923 |
| No log | 3.0 | 21 | 1.6631 | 0.0 | 0.0 | 0.0 | 0.6923 |
| No log | 4.0 | 28 | 1.6466 | 0.0 | 0.0 | 0.0 | 0.6923 |
| No log | 5.0 | 35 | 1.5872 | 0.0 | 0.0 | 0.0 | 0.6923 |
| No log | 6.0 | 42 | 1.4829 | 0.0 | 0.0 | 0.0 | 0.6923 |
| No log | 7.0 | 49 | 1.4084 | 0.0 | 0.0 | 0.0 | 0.6923 |
| No log | 8.0 | 56 | 1.3170 | 0.125 | 0.1 | 0.1111 | 0.7115 |
| No log | 9.0 | 63 | 1.3044 | 0.25 | 0.3 | 0.2727 | 0.75 |
| No log | 10.0 | 70 | 1.2475 | 0.25 | 0.3 | 0.2727 | 0.75 |
| No log | 11.0 | 77 | 1.2179 | 0.2143 | 0.3 | 0.25 | 0.75 |
| No log | 12.0 | 84 | 1.1870 | 0.2143 | 0.3 | 0.25 | 0.75 |
| No log | 13.0 | 91 | 1.1580 | 0.2857 | 0.4 | 0.3333 | 0.75 |
| No log | 14.0 | 98 | 1.1199 | 0.3571 | 0.5 | 0.4167 | 0.7692 |
| No log | 15.0 | 105 | 1.0870 | 0.3571 | 0.5 | 0.4167 | 0.7692 |
| No log | 16.0 | 112 | 1.1182 | 0.4286 | 0.6 | 0.5 | 0.7692 |
| No log | 17.0 | 119 | 1.0651 | 0.4286 | 0.6 | 0.5 | 0.7885 |
| No log | 18.0 | 126 | 1.0378 | 0.4286 | 0.6 | 0.5 | 0.7692 |
| No log | 19.0 | 133 | 1.0537 | 0.4286 | 0.6 | 0.5 | 0.7885 |
| No log | 20.0 | 140 | 1.0368 | 0.4286 | 0.6 | 0.5 | 0.7885 |
| No log | 21.0 | 147 | 1.0037 | 0.5 | 0.7 | 0.5833 | 0.8077 |
| No log | 22.0 | 154 | 1.0368 | 0.4667 | 0.7 | 0.56 | 0.7885 |
| No log | 23.0 | 161 | 1.0143 | 0.5 | 0.7 | 0.5833 | 0.8077 |
| No log | 24.0 | 168 | 1.0121 | 0.4667 | 0.7 | 0.56 | 0.7885 |
| No log | 25.0 | 175 | 0.9948 | 0.5 | 0.7 | 0.5833 | 0.8077 |
| No log | 26.0 | 182 | 0.9946 | 0.5 | 0.7 | 0.5833 | 0.8077 |
| No log | 27.0 | 189 | 0.9840 | 0.5 | 0.7 | 0.5833 | 0.8077 |
| No log | 28.0 | 196 | 0.9727 | 0.5 | 0.7 | 0.5833 | 0.8077 |
| No log | 29.0 | 203 | 0.9724 | 0.5 | 0.7 | 0.5833 | 0.8077 |
| No log | 30.0 | 210 | 0.9705 | 0.5 | 0.7 | 0.5833 | 0.8077 |
| No log | 31.0 | 217 | 0.9850 | 0.4667 | 0.7 | 0.56 | 0.7885 |
| No log | 32.0 | 224 | 0.9834 | 0.4667 | 0.7 | 0.56 | 0.7885 |
| No log | 33.0 | 231 | 0.9795 | 0.4667 | 0.7 | 0.56 | 0.7885 |
| No log | 34.0 | 238 | 0.9681 | 0.4667 | 0.7 | 0.56 | 0.7885 |
| No log | 35.0 | 245 | 0.9727 | 0.4375 | 0.7 | 0.5385 | 0.7885 |
| No log | 36.0 | 252 | 0.9733 | 0.4667 | 0.7 | 0.56 | 0.7885 |
| No log | 37.0 | 259 | 0.9714 | 0.4667 | 0.7 | 0.56 | 0.7885 |
| No log | 38.0 | 266 | 0.9659 | 0.4667 | 0.7 | 0.56 | 0.7885 |
| No log | 39.0 | 273 | 0.9725 | 0.4667 | 0.7 | 0.56 | 0.7885 |
| No log | 40.0 | 280 | 0.9794 | 0.4667 | 0.7 | 0.56 | 0.7885 |
| No log | 41.0 | 287 | 0.9656 | 0.4667 | 0.7 | 0.56 | 0.7885 |
| No log | 42.0 | 294 | 0.9524 | 0.5 | 0.7 | 0.5833 | 0.8077 |
| No log | 43.0 | 301 | 0.9548 | 0.5 | 0.7 | 0.5833 | 0.8077 |
| No log | 44.0 | 308 | 0.9585 | 0.4667 | 0.7 | 0.56 | 0.7885 |
| No log | 45.0 | 315 | 0.9587 | 0.4667 | 0.7 | 0.56 | 0.7885 |
| No log | 46.0 | 322 | 0.9608 | 0.4667 | 0.7 | 0.56 | 0.7885 |
| No log | 47.0 | 329 | 0.9567 | 0.4667 | 0.7 | 0.56 | 0.7885 |
| No log | 48.0 | 336 | 0.9533 | 0.4667 | 0.7 | 0.56 | 0.7885 |
| No log | 49.0 | 343 | 0.9520 | 0.4667 | 0.7 | 0.56 | 0.7885 |
| No log | 50.0 | 350 | 0.9520 | 0.4667 | 0.7 | 0.56 | 0.7885 |
Framework versions
- Transformers 5.16.1
- Pytorch 2.11.0+cu128
- Datasets 4.0.0
- Tokenizers 0.23.1
- Downloads last month
- -
Model tree for hoaan/phobert-product-ner
Base model
vinai/phobert-base-v2