ความคล้ายคลึงของคำถามและความถูกต้องทางไวยากรณ์

การประมวลผลภาษาธรรมชาติ (NLP) ด้วย Python

Fouad Trad

Machine Learning Engineer

ความคล้ายคลึงของคำถาม

  • ระบุว่าคำถามสองข้อเป็น paraphrase ของกันหรือไม่
  • ประโยชน์:
    • การลบข้อมูลซ้ำ
    • จัดกลุ่มคำถามที่คล้ายกัน
    • เพิ่มความแม่นยำในการค้นหา
  • ใช้โมเดลที่ฝึกบนชุดข้อมูล Quora Question Pairs (QQP)

ภาพแสดงคน 3 คนกำลังถามคำถาม

การประมวลผลภาษาธรรมชาติ (NLP) ด้วย Python

QQP pipeline

from transformers import pipeline

qqp_pipeline = pipeline( task="text-classification", model="textattack/bert-base-uncased-QQP" )
question1 = "How can I learn Python?" question2 = "What is the best way to study Python?"
result = qqp_pipeline({"text": question1, "text_pair": question2})
print(result)
{'label': 'LABEL_1', 'score': 0.6853412985801697}
การประมวลผลภาษาธรรมชาติ (NLP) ด้วย Python

QQP pipeline

from transformers import pipeline
qqp_pipeline = pipeline(
    task="text-classification", 
    model="textattack/bert-base-uncased-QQP"
    )
question1 = "How can I learn Python?"
question2 = "What is the capital of France?"
result = qqp_pipeline({"text": question1, "text_pair": question2})
print(result)
{'label': 'LABEL_0', 'score': 0.9999338388442993}
การประมวลผลภาษาธรรมชาติ (NLP) ด้วย Python

การประเมินความถูกต้องทางไวยากรณ์

  • ประเมินความถูกต้องทางไวยากรณ์ของข้อความ
  • ประโยชน์:

    • เครื่องมือทางการศึกษา
    • ตัวตรวจสอบไวยากรณ์
    • ผู้ช่วยการเขียน
  • ใช้โมเดลที่ฝึกบนชุดข้อมูล Corpus of Linguistic Acceptability (CoLA)

ภาพแสดงบุคคลกำลังประเมินความถูกต้องของข้อความที่เขียน

การประมวลผลภาษาธรรมชาติ (NLP) ด้วย Python

CoLA pipeline

from transformers import pipeline
cola_classifier = pipeline(
  task="text-classification", 
  model="textattack/distilbert-base-uncased-CoLA"
)

result = cola_classifier("The cat sat on the mat.")
print(result)
[{'label': 'LABEL_1', 'score': 0.9918296933174133}]
การประมวลผลภาษาธรรมชาติ (NLP) ด้วย Python

CoLA pipeline

from transformers import pipeline
cola_classifier = pipeline(
  task="text-classification", 
  model="textattack/distilbert-base-uncased-CoLA"
)
result = cola_classifier("The cat on sat mat the.")
print(result)
[{'label': 'LABEL_0', 'score': 0.9628171324729919}]
การประมวลผลภาษาธรรมชาติ (NLP) ด้วย Python

มาฝึกกันเถอะ!

การประมวลผลภาษาธรรมชาติ (NLP) ด้วย Python

Preparing Video For Download...