Token Classification
Transformers
Safetensors
Thai
camembert
ner
thai
phayathaibert
job-posting
apple-silicon
Eval Results (legacy)
Instructions to use chayuto/thai-job-ner-phayathaibert with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use chayuto/thai-job-ner-phayathaibert with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("token-classification", model="chayuto/thai-job-ner-phayathaibert")# Load model directly from transformers import AutoTokenizer, AutoModelForTokenClassification tokenizer = AutoTokenizer.from_pretrained("chayuto/thai-job-ner-phayathaibert") model = AutoModelForTokenClassification.from_pretrained("chayuto/thai-job-ner-phayathaibert", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload fine-tuned Thai Job NER model (v3, F1=0.897)
Browse files- .gitattributes +1 -0
- README.md +142 -0
- config.json +62 -0
- model.safetensors +3 -0
- tokenizer.json +3 -0
- tokenizer_config.json +21 -0
- training_args.bin +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- th
|
| 4 |
+
license: mit
|
| 5 |
+
library_name: transformers
|
| 6 |
+
tags:
|
| 7 |
+
- token-classification
|
| 8 |
+
- ner
|
| 9 |
+
- thai
|
| 10 |
+
- phayathaibert
|
| 11 |
+
- job-posting
|
| 12 |
+
- apple-silicon
|
| 13 |
+
datasets:
|
| 14 |
+
- chayuto/thai-job-ner-dataset
|
| 15 |
+
metrics:
|
| 16 |
+
- f1
|
| 17 |
+
- precision
|
| 18 |
+
- recall
|
| 19 |
+
pipeline_tag: token-classification
|
| 20 |
+
model-index:
|
| 21 |
+
- name: thai-job-ner-phayathaibert
|
| 22 |
+
results:
|
| 23 |
+
- task:
|
| 24 |
+
type: token-classification
|
| 25 |
+
name: Named Entity Recognition
|
| 26 |
+
metrics:
|
| 27 |
+
- name: F1
|
| 28 |
+
type: f1
|
| 29 |
+
value: 0.956
|
| 30 |
+
- name: Precision
|
| 31 |
+
type: precision
|
| 32 |
+
value: 0.939
|
| 33 |
+
- name: Recall
|
| 34 |
+
type: recall
|
| 35 |
+
value: 0.974
|
| 36 |
+
---
|
| 37 |
+
|
| 38 |
+
# Thai Job NER — Fine-tuned PhayaThaiBERT
|
| 39 |
+
|
| 40 |
+
Named Entity Recognition model for extracting structured HR data from informal Thai job postings (e.g., Facebook groups, Line chats). Fine-tuned from [PhayaThaiBERT](https://huggingface.co/clicknext/phayathaibert) (~122M params).
|
| 41 |
+
|
| 42 |
+
## Model Description
|
| 43 |
+
|
| 44 |
+
This model extracts 7 entity types from Thai job-related text:
|
| 45 |
+
|
| 46 |
+
| Entity | Description | Example |
|
| 47 |
+
|--------|-------------|---------|
|
| 48 |
+
| `HARD_SKILL` | Skills or procedures | ดูแลผู้สูงอายุ, CPR, Python |
|
| 49 |
+
| `PERSON` | Names | คุณสมชาย, พี่แจน |
|
| 50 |
+
| `LOCATION` | Places | สีลม, ลาดพร้าว, บางนา |
|
| 51 |
+
| `COMPENSATION` | Pay amounts | 18,000 บาท/เดือน |
|
| 52 |
+
| `EMPLOYMENT_TERMS` | Job structure | part-time, กะกลางวัน |
|
| 53 |
+
| `CONTACT` | Phone, Line, email | 081-234-5678, @care123 |
|
| 54 |
+
| `DEMOGRAPHIC` | Age, gender | อายุ 25-40, หญิง |
|
| 55 |
+
|
| 56 |
+
## Usage
|
| 57 |
+
|
| 58 |
+
```python
|
| 59 |
+
from transformers import AutoTokenizer, AutoModelForTokenClassification, pipeline
|
| 60 |
+
|
| 61 |
+
model_name = "chayuto/thai-job-ner-phayathaibert"
|
| 62 |
+
ner = pipeline("ner", model=model_name, aggregation_strategy="simple")
|
| 63 |
+
|
| 64 |
+
text = "รับสมัครคนดูแลผู้สูงอายุ ย่านสีลม เงินเดือน 18,000 บาท โทร 081-234-5678"
|
| 65 |
+
results = ner(text)
|
| 66 |
+
for entity in results:
|
| 67 |
+
print(f"{entity['entity_group']}: {entity['word']} ({entity['score']:.2%})")
|
| 68 |
+
```
|
| 69 |
+
|
| 70 |
+
## Training
|
| 71 |
+
|
| 72 |
+
- **Base model:** `clicknext/phayathaibert` (CamemBERT architecture, ~122M params, XLM-R-derived vocabulary)
|
| 73 |
+
- **Training data:** 1,253 Thai job posts (synthetic silver labels from GPT-4o, fuzzy-aligned to IOB2) — [Dataset on HuggingFace](https://huggingface.co/datasets/chayuto/thai-job-ner-dataset)
|
| 74 |
+
- **Hardware:** Apple Silicon MPS backend, FP32
|
| 75 |
+
- **Hyperparameters:** LR=3e-5, warmup=0.1, batch=2, grad_accum=8, 15 epochs, gradient checkpointing, frozen embeddings
|
| 76 |
+
- **Training time:** ~10 min
|
| 77 |
+
|
| 78 |
+
### Data Pipeline
|
| 79 |
+
|
| 80 |
+
Raw Thai text + GPT-4o entity extractions → fuzzy alignment with rapidfuzz + pythainlp TCC boundary snapping → subword token mapping via offset_mapping → IOB2-formatted HuggingFace Dataset.
|
| 81 |
+
|
| 82 |
+
## Evaluation
|
| 83 |
+
|
| 84 |
+
### Overall (Test Set, 126 examples)
|
| 85 |
+
|
| 86 |
+
| Metric | Score |
|
| 87 |
+
|--------|-------|
|
| 88 |
+
| **F1** | **0.956** |
|
| 89 |
+
| Precision | 0.939 |
|
| 90 |
+
| Recall | 0.974 |
|
| 91 |
+
|
| 92 |
+
### Per-Entity F1
|
| 93 |
+
|
| 94 |
+
| Entity | F1 | Precision | Recall |
|
| 95 |
+
|--------|-----|-----------|--------|
|
| 96 |
+
| CONTACT | 0.987 | 0.983 | 0.991 |
|
| 97 |
+
| PERSON | 0.979 | 0.972 | 0.986 |
|
| 98 |
+
| LOCATION | 0.966 | 0.950 | 0.983 |
|
| 99 |
+
| EMPLOYMENT_TERMS | 0.966 | 0.943 | 0.990 |
|
| 100 |
+
| COMPENSATION | 0.965 | 0.956 | 0.973 |
|
| 101 |
+
| HARD_SKILL | 0.946 | 0.919 | 0.974 |
|
| 102 |
+
| DEMOGRAPHIC | 0.915 | 0.897 | 0.935 |
|
| 103 |
+
|
| 104 |
+
### Comparison vs WangchanBERTa
|
| 105 |
+
|
| 106 |
+
| Entity | WangchanBERTa | PhayaThaiBERT | Delta |
|
| 107 |
+
|--------|---------------|---------------|-------|
|
| 108 |
+
| **Overall F1** | 0.897 | **0.956** | **+0.059** |
|
| 109 |
+
| COMPENSATION | 0.764 | **0.965** | **+0.200** |
|
| 110 |
+
| PERSON | 0.907 | **0.979** | **+0.072** |
|
| 111 |
+
| HARD_SKILL | 0.903 | **0.946** | **+0.043** |
|
| 112 |
+
| EMPLOYMENT_TERMS | 0.926 | **0.966** | +0.040 |
|
| 113 |
+
| DEMOGRAPHIC | 0.875 | **0.915** | +0.041 |
|
| 114 |
+
| CONTACT | 0.962 | **0.987** | +0.025 |
|
| 115 |
+
| LOCATION | 0.959 | **0.966** | +0.008 |
|
| 116 |
+
|
| 117 |
+
PhayaThaiBERT improves on every entity type, with the most dramatic gain on COMPENSATION (+0.200 F1).
|
| 118 |
+
|
| 119 |
+
## Links
|
| 120 |
+
|
| 121 |
+
- **Model:** [chayuto/thai-job-ner-phayathaibert](https://huggingface.co/chayuto/thai-job-ner-phayathaibert)
|
| 122 |
+
- **WangchanBERTa variant:** [chayuto/thai-job-ner-wangchanberta](https://huggingface.co/chayuto/thai-job-ner-wangchanberta)
|
| 123 |
+
- **Dataset:** [chayuto/thai-job-ner-dataset](https://huggingface.co/datasets/chayuto/thai-job-ner-dataset)
|
| 124 |
+
- **Source Code:** [github.com/chayuto/thai-job-nlp-ner](https://github.com/chayuto/thai-job-nlp-ner)
|
| 125 |
+
|
| 126 |
+
## Limitations
|
| 127 |
+
|
| 128 |
+
- Trained on synthetic data — may underperform on real-world posts with heavy emoji usage, OCR errors, or extreme colloquialism
|
| 129 |
+
- Embeddings were frozen during training (MPS memory constraint) — unfreezing on a larger GPU may yield further gains
|
| 130 |
+
- 512 token max sequence length
|
| 131 |
+
- Larger model file size due to 248K vocabulary (vs WangchanBERTa's 25K)
|
| 132 |
+
|
| 133 |
+
## Technical Notes
|
| 134 |
+
|
| 135 |
+
- **FP16 is broken on MPS** — always use FP32 for Apple Silicon training
|
| 136 |
+
- PhayaThaiBERT's 248K vocab (XLM-R-derived) requires frozen embeddings + gradient checkpointing to fit on 18GB MPS
|
| 137 |
+
- Uses `offset_mapping` for tokenizer-agnostic subword-to-character alignment
|
| 138 |
+
- Thai Character Cluster (TCC) boundary snapping prevents Unicode grapheme splitting during alignment
|
| 139 |
+
|
| 140 |
+
## License
|
| 141 |
+
|
| 142 |
+
MIT
|
config.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_cross_attention": false,
|
| 3 |
+
"architectures": [
|
| 4 |
+
"CamembertForTokenClassification"
|
| 5 |
+
],
|
| 6 |
+
"attention_probs_dropout_prob": 0.1,
|
| 7 |
+
"bos_token_id": 0,
|
| 8 |
+
"classifier_dropout": null,
|
| 9 |
+
"dtype": "float32",
|
| 10 |
+
"eos_token_id": 2,
|
| 11 |
+
"hidden_act": "gelu",
|
| 12 |
+
"hidden_dropout_prob": 0.1,
|
| 13 |
+
"hidden_size": 768,
|
| 14 |
+
"id2label": {
|
| 15 |
+
"0": "O",
|
| 16 |
+
"1": "B-HARD_SKILL",
|
| 17 |
+
"2": "I-HARD_SKILL",
|
| 18 |
+
"3": "B-PERSON",
|
| 19 |
+
"4": "I-PERSON",
|
| 20 |
+
"5": "B-LOCATION",
|
| 21 |
+
"6": "I-LOCATION",
|
| 22 |
+
"7": "B-COMPENSATION",
|
| 23 |
+
"8": "I-COMPENSATION",
|
| 24 |
+
"9": "B-EMPLOYMENT_TERMS",
|
| 25 |
+
"10": "I-EMPLOYMENT_TERMS",
|
| 26 |
+
"11": "B-CONTACT",
|
| 27 |
+
"12": "I-CONTACT",
|
| 28 |
+
"13": "B-DEMOGRAPHIC",
|
| 29 |
+
"14": "I-DEMOGRAPHIC"
|
| 30 |
+
},
|
| 31 |
+
"initializer_range": 0.02,
|
| 32 |
+
"intermediate_size": 3072,
|
| 33 |
+
"is_decoder": false,
|
| 34 |
+
"label2id": {
|
| 35 |
+
"B-COMPENSATION": 7,
|
| 36 |
+
"B-CONTACT": 11,
|
| 37 |
+
"B-DEMOGRAPHIC": 13,
|
| 38 |
+
"B-EMPLOYMENT_TERMS": 9,
|
| 39 |
+
"B-HARD_SKILL": 1,
|
| 40 |
+
"B-LOCATION": 5,
|
| 41 |
+
"B-PERSON": 3,
|
| 42 |
+
"I-COMPENSATION": 8,
|
| 43 |
+
"I-CONTACT": 12,
|
| 44 |
+
"I-DEMOGRAPHIC": 14,
|
| 45 |
+
"I-EMPLOYMENT_TERMS": 10,
|
| 46 |
+
"I-HARD_SKILL": 2,
|
| 47 |
+
"I-LOCATION": 6,
|
| 48 |
+
"I-PERSON": 4,
|
| 49 |
+
"O": 0
|
| 50 |
+
},
|
| 51 |
+
"layer_norm_eps": 1e-12,
|
| 52 |
+
"max_position_embeddings": 512,
|
| 53 |
+
"model_type": "camembert",
|
| 54 |
+
"num_attention_heads": 12,
|
| 55 |
+
"num_hidden_layers": 12,
|
| 56 |
+
"pad_token_id": 1,
|
| 57 |
+
"position_embedding_type": "absolute",
|
| 58 |
+
"transformers_version": "5.3.0",
|
| 59 |
+
"type_vocab_size": 1,
|
| 60 |
+
"use_cache": false,
|
| 61 |
+
"vocab_size": 249262
|
| 62 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ea4fc06fbfdc121e07cb9811cf543400c2d959c9585690d8b1593d154f8bb673
|
| 3 |
+
size 1107602956
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a81740837e6a4438c05e3ef1f65f8fdffdd63a81a5e01cb6df06abfbe57ee92d
|
| 3 |
+
size 17048018
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": true,
|
| 3 |
+
"backend": "tokenizers",
|
| 4 |
+
"bos_token": "<s>",
|
| 5 |
+
"clean_up_tokenization_spaces": true,
|
| 6 |
+
"cls_token": "<s>",
|
| 7 |
+
"eos_token": "</s>",
|
| 8 |
+
"extra_special_tokens": [
|
| 9 |
+
"<s>NOTUSED",
|
| 10 |
+
"</s>NOTUSED",
|
| 11 |
+
"<_>"
|
| 12 |
+
],
|
| 13 |
+
"is_local": false,
|
| 14 |
+
"mask_token": "<mask>",
|
| 15 |
+
"model_max_length": 510,
|
| 16 |
+
"pad_token": "<pad>",
|
| 17 |
+
"sep_token": "</s>",
|
| 18 |
+
"sp_model_kwargs": {},
|
| 19 |
+
"tokenizer_class": "CamembertTokenizer",
|
| 20 |
+
"unk_token": "<unk>"
|
| 21 |
+
}
|
training_args.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a4c65168b591d533bc267f32ce96f83b12b364fbce13d9542cebeb73008b74bf
|
| 3 |
+
size 5201
|