Token sınıflandırma

Python ile Natural Language Processing (NLP)

Fouad Trad

Machine Learning Engineer

Metin ve token sınıflandırma

Metin sınıflandırma

  • Tüm cümleleri veya metin çiftlerini sınıflandırır

Önceki videolarda gösterilen metin sınıflandırma ve QNLI görevlerinin görseli.

Python ile Natural Language Processing (NLP)

Metin ve token sınıflandırma

Metin sınıflandırma

  • Tüm cümleleri veya metin çiftlerini sınıflandırır

Önceki videolarda gösterilen metin sınıflandırma ve QNLI görevlerinin görseli.

Token sınıflandırma

  • Bir cümledeki token'lara etiket atar

Bir cümlenin sözcüklere bölünüp her birinin farklı sınıfı temsil eden renklere sahip olduğu görsel.

  • Adlandırılmış varlık tanıma (NER)
  • Sözcük türü (PoS) etiketleme
Python ile Natural Language Processing (NLP)

Adlandırılmış varlık tanıma (NER)

  • İsimler, konumlar, kurumlar, tarihler vb. varlıkları belirler

"Apple opened a new office in Toronto in March 2023" cümlesinin NER analizini gösteren görsel; Apple kuruluş, Toronto konum, March 2023 tarih olarak tanınmıştır.

  • Şunlarda yararlı:
    • Bilgi getirimi
    • Soru yanıtlama
Python ile Natural Language Processing (NLP)

Koddaki NER

from transformers import pipeline

ner_pipeline = pipeline(task="ner",
model="dslim/bert-base-NER",
grouped_entities=True)
ner_results = ner_pipeline("Zara Venn established NovaCore Dynamics in London.")
print(ner_results)
[{'entity_group': 'PER', 'score': np.float32(0.99840075), 'word': 'Zara Venn', 'start': 0, 'end': 9}, 
 {'entity_group': 'ORG', 'score': np.float32(0.99875560), 'word': 'NovaCore Dynamics', 'start': 21, 'end': 38}, 
 {'entity_group': 'LOC', 'score': np.float32(0.99960726), 'word': 'London', 'start': 42, 'end': 48}]
Python ile Natural Language Processing (NLP)

Sözcük türü (PoS) etiketleme

  • Her sözcüğe dilbilgisel rol atar (isim, fiil, sıfat)

"The quick fox jumps over the lazy dog" cümlesinin Sözcük Türü (PoS) etiketlerini gösteren görsel; "the" belirteç, "quick" ve "lazy" sıfat, "fox" ve "dogs" isim, "jumps" fiil, "over" edat.

  • Şunlarda yararlı:
    • Sözdizimsel ayrıştırma
    • Dilbilgisi düzeltme
    • Metin üretimi
Python ile Natural Language Processing (NLP)

Koddaki PoS etiketleme

pos_pipeline = pipeline(task="token-classification",

model="vblagoje/bert-english-uncased-finetuned-pos",
grouped_entities=True)
pos_results = pos_pipeline("Zara Venn established NovaCore Dynamics in London.") print(pos_results)
[{'entity_group': 'PROPN', 'score': np.float32(0.9982983), 'word': 'zara venn', 'start': 0, 'end': 9},  
 {'entity_group': 'VERB', 'score': np.float32(0.99940944), 'word': 'established', 'start': 10, 'end': 21},  
 {'entity_group': 'PROPN', 'score': np.float32(0.99455726), 'word': 'novacore dynamics', 'start': 22, 'end': 39},  
 {'entity_group': 'ADP', 'score': np.float32(0.99935526), 'word': 'in', 'start': 40, 'end': 42},  
 {'entity_group': 'PROPN', 'score': np.float32(0.99847955), 'word': 'london', 'start': 43, 'end': 49}]
Python ile Natural Language Processing (NLP)

Ayo berlatih!

Python ile Natural Language Processing (NLP)

Preparing Video For Download...