Giải thích mô hình tạo sinh dựa trên hội thoại

Explainable AI trong Python

Fouad Trad

Machine Learning Engineer

Mô hình AI tạo sinh dựa trên hội thoại

  • Dùng để tạo văn bản
  • Dự đoán dựa trên ngữ cảnh và tri thức

 

Hình minh họa người dùng gửi prompt cho mô hình AI tạo sinh và nhận phản hồi.

Explainable AI trong Python

Prompt chuỗi suy nghĩ (chain-of-thought)

  • Khuyến khích mô hình diễn giải lập luận

Hình minh họa cách prompt chuỗi suy nghĩ yêu cầu mô hình giải từng bước, và đầu ra chứa lập luận cho mỗi bước.

Explainable AI trong Python

Tạo prompt chuỗi suy nghĩ

prompt = """A shop starts with 20 apples. It sells 5 apples and then receives 8 more. 
How many apples does the shop have now? Show your reasoning step-by-step."""

response = get_response(prompt)
print(response)
To find out how many apples the shop has now, let's follow the transactions step-by-step:

1- The shop begins with 20 apples.
2- The shop sells 5 apples. We subtract this number from the starting quantity: 20 - 5 = 15
3- The shop receives 8 apples. We add this number to the remaining apples: 15 + 8 = 23
So, after these transactions, the shop has 23 apples.
Explainable AI trong Python

Tự nhất quán

Đánh giá độ tự tin của mô hình với câu trả lời sinh ra

Hình minh họa: prompt tự nhất quán là gửi cùng một prompt nhiều lần cho mô hình, mỗi lần có một phản hồi.

Explainable AI trong Python

Tự nhất quán trong phân loại văn bản

Hữu ích cho phân loại văn bản

Hình minh họa ví dụ tự nhất quán: mô hình cần phân loại đánh giá là tích cực hay tiêu cực và đưa ra nhiều phản hồi.

Explainable AI trong Python

Tự nhất quán trong phân loại văn bản

Hữu ích cho phân loại văn bản

Hình minh họa ví dụ tự nhất quán: mô hình phân loại đánh giá của người dùng là tích cực hay tiêu cực và đưa ra nhiều phản hồi. Độ tin cậy được tính theo tỷ lệ từng loại so với tổng số phản hồi.

Explainable AI trong Python

Tạo prompt tự nhất quán

prompt = """Classify the following review as positive or negative. 
You should reply with either "positive" or "negative", nothing else.
Review: 'The customer service was great, but the product itself did not meet my expectations.'"""

responses = []
for i in range(5): sentiment = get_response(review)
responses.append(sentiment.lower())
confidence = { 'positive': responses.count('positive') / len(responses), 'negative': responses.count('negative') / len(responses) }
Explainable AI trong Python

Tạo prompt tự nhất quán

print(confidence)
{
    'positive': 0.6,
    'negative': 0.4
}
Explainable AI trong Python

Hãy luyện tập!

Explainable AI trong Python

Preparing Video For Download...