Edit model card

ํ•œ๊ตญ์–ด ์ด๋ฆ„ ์ถ”์ถœ NER ์ž‘์—… ์ˆ˜ํ–‰์— ํŠนํ™”๋œ ๋ชจ๋ธ์ž…๋‹ˆ๋‹ค

๊ธฐ์กด์— ๋งŒ๋“ค์—ˆ๋˜ final_crf ์— ํ•œ ๋‹จ๊ณ„ ๋” fine-tuning ์‹œํ‚จ ๋ชจ๋ธ์ž…๋‹ˆ๋‹ค. ์ข€ ๋” ์งง์€ ์ด๋ฆ„ ๋ฐœํ™”์—๋„ ์ด๋ฆ„์„ ์ž˜ ์žก์•„๋‚ด๋„๋ก fine-tuning ์‹œ์ผฐ์Šต๋‹ˆ๋‹ค ๊ธฐ์กด final_crf๋Š” ์•„๋ž˜ ๋งํฌ์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค https://huggingface.co/jinwoowef/final_crf


cuda 11.4 / python 3.8.19 ์—์„œ ์ž‘์„ฑํ•˜์˜€์Šต๋‹ˆ๋‹ค


๋‹ค์Œ์˜ ์ฝ”๋“œ๋กœ ๋ชจ๋ธ๊ณผ ํ† ํฌ๋‚˜์ด์ €๋ฅผ ๋ถˆ๋Ÿฌ์˜ฌ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค


from transformers import AutoModelForTokenClassification, AutoTokenizer

model_name = "jinwoowef/ner_crf_plus"
model = AutoModelForTokenClassification.from_pretrained(model_name)  
tokenizer = AutoTokenizer.from_pretrained(model_name)

ํ•œ๊ตญ์–ด ์ด๋ฆ„ ๊ฐœ์ฒด๋ช… ์ถ”์ถœ ์˜ˆ์‹œ


from transformers import AutoTokenizer, BertForTokenClassification, logging, pipeline
import torch
import pandas as pd

device = "cuda" if torch.cuda.is_available() else "cpu"
# NER ํŒŒ์ดํ”„๋ผ์ธ ์ƒ์„ฑ 

ner = pipeline("ner", model=model, tokenizer=tokenizer, aggregation_strategy="simple",device=device)

# ๊ฒฐ๊ณผ ์ €์žฅ์„ ์œ„ํ•œ ๋ฆฌ์ŠคํŠธ
ner_results_list = []

sample_data = ## personal data

# NER ์ˆ˜ํ–‰
for example_text in sample_data:
    ner_results = ner(example_text)
    ner_results_list.append(ner_results)

# ๋ณ€ํ™˜๋œ ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅํ•  ๋ฆฌ์ŠคํŠธ
formatted_results = []

# ๋ณ€ํ™˜ ์ž‘์—…
for entry in ner_results_list:
    for entity in entry:
        formatted_results.append({
            'NE_form': entity['word'],
            'NE_label': entity['entity_group'],
            'Score': entity['score'],
            'NE_begin': entity['start'],
            'NE_end': entity['end']
        })

# ๋ณ€ํ™˜๋œ ๊ฒฐ๊ณผ๋ฅผ ์ƒˆ๋กœ์šด DataFrame์œผ๋กœ ์ €์žฅ
ner_crf = pd.DataFrame(formatted_results)

# NER ๊ฒฐ๊ณผ ์ถœ๋ ฅ 
for result in ner_results_list[:5]:  
    for entity in result:
        print(f"NE_form: {entity['word']}, NE_label: {entity['entity_group']}, Score: {entity['score']:.4f}")


์ถœ๋ ฅ๋ฌผ ์˜ˆ์‹œ

NE_form: ๊น€์ˆ˜์˜, NE_label: PS_NAME, Score: 0.9945
NE_form: ํ•˜๊ฒฝ, NE_label: PS_NAME, Score: 0.7682
NE_form: ๊น€๋ฏผ์ •, NE_label: PS_NAME, Score: 0.9740
NE_form: ๊น€์€์ •, NE_label: PS_NAME, Score: 0.9997
NE_form: ๊น€ํฌ๊ฒฝ, NE_label: PS_NAME, Score: 0.8500
NE_form: ๊น€๋ฏธ๊ฒฝ, NE_label: PS_NAME, Score: 0.9741
NE_form: ์œค, NE_label: PS_NAME, Score: 0.6256
NE_form: ์ดํ˜„ํƒœ, NE_label: PS_NAME, Score: 0.9996

Downloads last month
6
Inference Examples
Unable to determine this model's library. Check the docs .