Chatbasierte generative KI-Modelle erklären

Erklärbare KI in Python

Fouad Trad

Machine Learning Engineer

Chatbasierte generative KI-Modelle

  • Dient zur Textgenerierung
  • Sagt anhand von Kontext und Wissen voraus

 

Bild zeigt einen Prompt an ein generatives KI-Modell und die Antwort.

Erklärbare KI in Python

Chain-of-Thought-Prompt

  • Regt das Modell an, sein Denken zu erläutern

Bild zeigt, wie ein Chain-of-Thought-Prompt das Modell bittet, ein Problem Schritt für Schritt zu lösen; die Ausgabe enthält die Begründung je Schritt.

Erklärbare KI in Python

Einen Chain-of-Thought-Prompt erstellen

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.
Erklärbare KI in Python

Self-Consistency

Bewertet die Modell-Sicherheit der Antworten

Bild zeigt, dass ein Self-Consistency-Prompt dasselbe Prompt mehrfach sendet, jeweils mit einer Antwort.

Erklärbare KI in Python

Self-Consistency bei Textklassifikation

Nützlich für Textklassifikation

Bild zeigt ein Self-Consistency-Beispiel, bei dem das Modell eine Nutzerbewertung als positiv oder negativ klassifizieren soll und mehrere Antworten liefert.

Erklärbare KI in Python

Self-Consistency bei Textklassifikation

Nützlich für Textklassifikation

Bild zeigt ein Self-Consistency-Beispiel: Das Modell soll eine Nutzerbewertung als positiv oder negativ klassifizieren und gibt mehrere Antworten. Das Vertrauen wird als Anteil jeder Kategorie an der Gesamtzahl der Antworten berechnet.

Erklärbare KI in Python

Self-Consistency-Prompts erstellen

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) }
Erklärbare KI in Python

Self-Consistency-Prompts erstellen

print(confidence)
{
    'positive': 0.6,
    'negative': 0.4
}
Erklärbare KI in Python

Lass uns üben!

Erklärbare KI in Python

Preparing Video For Download...