Update app.py
Browse files
app.py
CHANGED
@@ -40,22 +40,29 @@ def classifier_2_predict(text):
|
|
40 |
return result
|
41 |
|
42 |
# ------------------------------
|
43 |
-
# Árbitro decide qual IA acertou e
|
44 |
# ------------------------------
|
45 |
def judge_sentiment(text, result_1, result_2):
|
46 |
prompt = (
|
47 |
f"Sentence: \"{text}\"\n"
|
48 |
f"Model A prediction: {result_1} (uses labels: negative, neutral, positive)\n"
|
49 |
f"Model B prediction: {result_2} (uses labels: neg, neu, pos)\n\n"
|
50 |
-
"Interpret the sentiment expressed in the sentence
|
51 |
-
"
|
52 |
-
"
|
53 |
-
"
|
|
|
|
|
|
|
54 |
"Model A: good | Model B: bad\n"
|
|
|
|
|
|
|
|
|
55 |
"Explanation: [your reasoning here]"
|
56 |
)
|
57 |
-
output = arbitro(prompt, max_new_tokens=
|
58 |
-
return f"Model A: {result_1} | Model B: {result_2}\n🤖 Árbitro
|
59 |
|
60 |
# ------------------------------
|
61 |
# Pipeline principal
|
@@ -73,11 +80,12 @@ iface = gr.Interface(
|
|
73 |
title="AI Sentiment Duel: Classificador de Sentimentos",
|
74 |
description=(
|
75 |
"Compare duas IAs na tarefa de identificar o sentimento de uma frase. "
|
76 |
-
"Uma terceira IA, chamada **árbitro**, decide qual
|
77 |
-
"**
|
78 |
-
"
|
79 |
-
"**
|
80 |
-
"
|
|
|
81 |
"💡 Exemplos:\n"
|
82 |
"- 'I absolutely loved the movie!'\n"
|
83 |
"- 'Not bad, but could be better.'"
|
|
|
40 |
return result
|
41 |
|
42 |
# ------------------------------
|
43 |
+
# Árbitro decide qual IA acertou e mostra os pesos
|
44 |
# ------------------------------
|
45 |
def judge_sentiment(text, result_1, result_2):
|
46 |
prompt = (
|
47 |
f"Sentence: \"{text}\"\n"
|
48 |
f"Model A prediction: {result_1} (uses labels: negative, neutral, positive)\n"
|
49 |
f"Model B prediction: {result_2} (uses labels: neg, neu, pos)\n\n"
|
50 |
+
"Interpret the real sentiment expressed in the sentence.\n"
|
51 |
+
"Judge whether each prediction is good or bad, and explain the parameters (weights) that influenced your decision.\n\n"
|
52 |
+
"Your judgment criteria (weights from 0 to 1):\n"
|
53 |
+
"- Semantic match (meaning alignment with the sentence)\n"
|
54 |
+
"- Tone match (emotional consistency)\n"
|
55 |
+
- Label accuracy (correct label among known sentiment labels)\n\n"
|
56 |
+
"Respond ONLY in this format:\n"
|
57 |
"Model A: good | Model B: bad\n"
|
58 |
+
"Weights used:\n"
|
59 |
+
"- Semantic match: 0.4\n"
|
60 |
+
"- Tone match: 0.4\n"
|
61 |
+
"- Label accuracy: 0.2\n"
|
62 |
"Explanation: [your reasoning here]"
|
63 |
)
|
64 |
+
output = arbitro(prompt, max_new_tokens=150)[0]['generated_text'].strip()
|
65 |
+
return f"Model A: {result_1} | Model B: {result_2}\n🤖 Árbitro:\n{output}"
|
66 |
|
67 |
# ------------------------------
|
68 |
# Pipeline principal
|
|
|
80 |
title="AI Sentiment Duel: Classificador de Sentimentos",
|
81 |
description=(
|
82 |
"Compare duas IAs na tarefa de identificar o sentimento de uma frase. "
|
83 |
+
"Uma terceira IA, chamada **árbitro**, decide qual resposta está mais correta e agora **explica os critérios (pesos) usados para julgar**.\n\n"
|
84 |
+
"**Critérios de julgamento do árbitro:**\n"
|
85 |
+
"- **Semantic match**: o quanto a resposta combina com o significado geral da frase.\n"
|
86 |
+
"- **Tone match**: o quanto a resposta combina com o tom emocional.\n"
|
87 |
+
"- **Label accuracy**: se o rótulo está entre os mais apropriados.\n\n"
|
88 |
+
"⚠️ Melhores resultados com frases em inglês.\n\n"
|
89 |
"💡 Exemplos:\n"
|
90 |
"- 'I absolutely loved the movie!'\n"
|
91 |
"- 'Not bad, but could be better.'"
|