Độ tương đồng câu hỏi và tính đúng ngữ pháp

Natural Language Processing (NLP) bằng Python

Fouad Trad

Machine Learning Engineer

Độ tương đồng câu hỏi

  • Xác định khi hai câu hỏi là diễn đạt lại
  • Hữu ích cho:
    • Khử trùng lặp
    • Gom cụm câu hỏi tương tự
    • Cải thiện độ chính xác tìm kiếm
  • Dùng các mô hình huấn luyện trên bộ dữ liệu Quora Question Pairs (QQP)

Hình ảnh ba người đang đặt câu hỏi.

Natural Language Processing (NLP) bằng Python

Pipeline QQP

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}
Natural Language Processing (NLP) bằng Python

Pipeline QQP

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}
Natural Language Processing (NLP) bằng Python

Đánh giá tính đúng ngữ pháp

  • Đánh giá mức độ đúng ngữ pháp của văn bản
  • Hữu ích cho:

    • Công cụ giáo dục
    • Trình kiểm tra ngữ pháp
    • Trợ lý viết
  • Dùng các mô hình huấn luyện trên bộ dữ liệu Corpus of Linguistic Acceptability (CoLA)

Hình ảnh một người đánh giá độ đúng đắn của văn bản viết.

Natural Language Processing (NLP) bằng Python

Pipeline CoLA

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}]
Natural Language Processing (NLP) bằng Python

Pipeline CoLA

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}]
Natural Language Processing (NLP) bằng Python

Ayo berlatih!

Natural Language Processing (NLP) bằng Python

Preparing Video For Download...