Model Description

  • Developed by: κΉ€μƒν˜„ / SANGHYUN KIM
  • Finetuned from model [klue/roberta-large], trained with [klue/klue] dataset.
  • 상세 μŠ€νŽ™κ³Ό ν•™μŠ΅ ν™˜κ²½μ€ ν›„μˆ 

Usage

Load model and tokenizer

from transformers import AutoTokenizer, AutoModelForTokenClassification

>>> model_path = "skimb22/roberta-large-klue-ner-epoch8"
>>> model = AutoModelForTokenClassification.from_pretrained(model_path)
>>> tokenizer = AutoTokenizer.from_pretrained(model_path)

Define NER Label list

>>> label_list = ['B-DT', 'I-DT', 'B-LC', 'I-LC', 'B-OG', 'I-OG', 'B-PS', 'I-PS', 'B-QT', 'I-QT', 'B-TI', 'I-TI', 'O']
>>> label2id = {label: i for i, label in enumerate(label_list)}
>>> id2label = {i: label for i, label in enumerate(label_list)}

Test with [klue] NER validation datasets.

from datasets import load_dataset
import random
import torch

dataset = load_dataset("klue/klue", "ner")
val_data = dataset["validation"]

samples = random.sample(list(val_data), 10)

for idx, sample in enumerate(samples):
    tokens = sample["tokens"]
    gold_labels = [label_list[tag] for tag in sample["ner_tags"]]

    # tokenizer, model λ³€μˆ˜ 쀀비돼 μžˆμ–΄μ•Ό 함. (Load model and tokenizer μ°Έκ³ )
    inputs = tokenizer(tokens, is_split_into_words=True, return_tensors="pt", truncation=True)
    word_ids = inputs.word_ids()
    with torch.no_grad():
        outputs = model(**inputs).logits
    preds = torch.argmax(outputs, dim=-1)[0].tolist()

    print(f"\nπŸ”Ή Sample {idx + 1}: {' '.join(tokens)}")
    print("Token\tGold\tPred")

    seen = set()
    for i, word_idx in enumerate(word_ids):
        if word_idx is None or word_idx in seen:
            continue
        seen.add(word_idx)

        token = tokens[word_idx]
        gold = gold_labels[word_idx]
        pred_id = preds[i]
        pred = label_list[pred_id] if pred_id < len(label_list) else "O"
        if gold == pred:
            print(f"{token}\t{gold}\t{pred} βœ…")
        else:
            print(f"{token}\t{gold}\t{pred} ❌")

Sample Output

Sample Output
πŸ”Ή Sample 7: 예 μ „ 에 λŠ”   유 느 λ‹˜ λ•œ 에   자 μ£Ό 자 μ£Ό λ΄€ λŠ” 데   이 제 λΆ€ ν„°   μ•ˆ λ³Ό 겁 λ‹ˆ λ‹€ !
Token   Gold    Pred
예      O       O βœ…
μ „      O       O βœ…
에      O       O βœ…
λŠ”      O       O βœ…
유      B-PS    B-PS βœ…
느      I-PS    O ❌
λ‹˜      I-PS    O ❌
λ•œ      O       O βœ…
에      O       O βœ…
자      O       O βœ…
μ£Ό      O       O βœ…
자      O       O βœ…
μ£Ό      O       O βœ…
λ΄€      O       O βœ…
λŠ”      O       O βœ…
데      O       O βœ…
이      O       O βœ…
제      O       O βœ…
λΆ€      O       O βœ…
ν„°      O       O βœ…
μ•ˆ      O       O βœ…
λ³Ό      O       O βœ…
겁      O       O βœ…
λ‹ˆ      O       O βœ…
λ‹€      O       O βœ…
!       O       O βœ…

Training Hyperparameters

The following hyperparameters were used during training:

learning_rate: 3e-5
per_device_train_batch_size: 32
per_device_eval_batch_size: 32
weight_decay: 0.01
num_train_epochs: 8

Evaluation

πŸ“‹ Classification Report
              precision    recall  f1-score   support

          DT       0.84      0.87      0.85      2312
          LC       0.70      0.75      0.73      1649
          OG       0.74      0.78      0.76      2182
          PS       0.88      0.86      0.87      4418
          QT       0.91      0.93      0.92      3151
          TI       0.90      0.92      0.91       545

   micro avg       0.84      0.85      0.84     14257
   macro avg       0.83      0.85      0.84     14257
weighted avg       0.84      0.85      0.84     14257

Testing Data

[https://huggingface.co/datasets/klue/klue] - NER Datasets - validation

Downloads last month
7
Safetensors
Model size
0.3B params
Tensor type
F32
Β·
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for skimb22/roberta-large-klue-ner-epoch8

Base model

klue/roberta-large
Finetuned
(80)
this model

Dataset used to train skimb22/roberta-large-klue-ner-epoch8

Evaluation results