Menjelaskan model AI generatif berbasis chat

Explainable AI in Python

Fouad Trad

Machine Learning Engineer

Model AI generatif berbasis chat

  • Digunakan untuk membuat teks
  • Memprediksi berdasarkan konteks dan pengetahuan

 

Gambar yang menunjukkan pengguna mengirim prompt ke model AI generatif dan menerima jawaban.

Explainable AI in Python

Prompt chain-of-thought

  • Mendorong model menjabarkan penalarannya

Gambar yang menunjukkan bagaimana prompt chain-of-thought meminta model menyelesaikan masalah langkah demi langkah, dan keluaran berisi penalaran tiap langkah.

Explainable AI in Python

Membuat prompt chain-of-thought

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 in Python

Self-consistency

Menilai keyakinan model pada jawaban yang dihasilkan

Gambar yang menunjukkan bahwa prompt self-consistency mengirim prompt yang sama ke model beberapa kali, masing-masing dengan jawaban.

Explainable AI in Python

Self-consistency pada klasifikasi teks

Berguna untuk tugas klasifikasi teks

Gambar yang menunjukkan contoh self-consistency saat model harus mengklasifikasikan ulasan pengguna sebagai positif atau negatif dan model memberi beberapa jawaban.

Explainable AI in Python

Self-consistency pada klasifikasi teks

Berguna untuk tugas klasifikasi teks

Gambar yang menunjukkan contoh self-consistency saat model harus mengklasifikasikan ulasan pengguna sebagai positif atau negatif dan model memberi beberapa jawaban. Kepercayaan dihitung sebagai proporsi tiap kategori terhadap total jumlah jawaban.

Explainable AI in Python

Membuat prompt self-consistency

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 in Python

Membuat prompt self-consistency

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

Ayo berlatih!

Explainable AI in Python

Preparing Video For Download...