Commit
·
007695a
1
Parent(s):
b3c710b
Update README.md
Browse files
README.md
CHANGED
|
@@ -39,6 +39,7 @@ Huggingface doesn't support inference token classification for Thai and It will
|
|
| 39 |
```python
|
| 40 |
from transformers import AutoTokenizer
|
| 41 |
from transformers import AutoModelForTokenClassification
|
|
|
|
| 42 |
import torch
|
| 43 |
|
| 44 |
name="pythainlp/thainer-corpus-v2-base-model"
|
|
@@ -46,6 +47,7 @@ tokenizer = AutoTokenizer.from_pretrained(name)
|
|
| 46 |
model = AutoModelForTokenClassification.from_pretrained(name)
|
| 47 |
|
| 48 |
sentence="ฉันชื่อ นางสาวมะลิวา บุญสระดี อาศัยอยู่ที่อำเภอนางรอง จังหวัดบุรีรัมย์ อายุ 23 ปี เพิ่งเรียนจบจาก มหาวิทยาลัยขอนแก่น และนี่คือข้อมูลปลอมชื่อคนไม่มีอยู่จริง อายุ 23 ปี"
|
|
|
|
| 49 |
inputs=tokenizer(cut,is_split_into_words=True,return_tensors="pt")
|
| 50 |
|
| 51 |
ids = inputs["input_ids"]
|
|
|
|
| 39 |
```python
|
| 40 |
from transformers import AutoTokenizer
|
| 41 |
from transformers import AutoModelForTokenClassification
|
| 42 |
+
from pythainlp.tokenize import word_tokenize # pip install pythainlp
|
| 43 |
import torch
|
| 44 |
|
| 45 |
name="pythainlp/thainer-corpus-v2-base-model"
|
|
|
|
| 47 |
model = AutoModelForTokenClassification.from_pretrained(name)
|
| 48 |
|
| 49 |
sentence="ฉันชื่อ นางสาวมะลิวา บุญสระดี อาศัยอยู่ที่อำเภอนางรอง จังหวัดบุรีรัมย์ อายุ 23 ปี เพิ่งเรียนจบจาก มหาวิทยาลัยขอนแก่น และนี่คือข้อมูลปลอมชื่อคนไม่มีอยู่จริง อายุ 23 ปี"
|
| 50 |
+
cut=word_tokenize(sentence.replace(" ", "<_>"))
|
| 51 |
inputs=tokenizer(cut,is_split_into_words=True,return_tensors="pt")
|
| 52 |
|
| 53 |
ids = inputs["input_ids"]
|