intent-recognition-training/test-bert.ipynb
2025-01-26 02:58:43 +01:00

276 lines
9.8 KiB
Text

{
"cells": [
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Device set to use cuda:0\n"
]
}
],
"source": [
"from transformers import pipeline"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Device set to use cuda:0\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"[{'label': 'DATE', 'score': 0.5580002069473267}]\n",
"[{'label': 'DATE', 'score': 0.5598549842834473}]\n",
"[{'label': 'ETEINDRE_CUISINE', 'score': 0.43001294136047363}]\n",
"[{'label': 'ETEINDRE_CUISINE', 'score': 0.43393829464912415}]\n",
"[{'label': 'METEO', 'score': 0.5053706765174866}]\n",
"[{'label': 'METEO', 'score': 0.4990154802799225}]\n",
"[{'label': 'TEMPERATURE_INTERIEUR', 'score': 0.297404944896698}]\n",
"[{'label': 'ALLUMER_BUREAU', 'score': 0.411824494600296}]\n"
]
}
],
"source": [
"classifier1 = pipeline(\"sentiment-analysis\", model=\"/home/tjiho/info/text-classification/domotique_command_classification/checkpoint-131\")\n",
"print(classifier1(\"quelle heure est-il ?\"))\n",
"print(classifier1(\"Est-ce que tu sais l'heure qu'il est ?\"))\n",
"print(classifier1(\"Peux-tu couper la lumière de la cuisine ?\"))\n",
"print(classifier1(\"Il faut éteindre la lampe de la cuisine.\"))\n",
"print(classifier1(\"Quel temps fait-il ?\"))\n",
"print(classifier1(\"Tu sais quel temps il y a aujourd'hui ?\"))\n",
"print(classifier1(\"Il fait combien dans la maison ?\"))\n",
"print(classifier1(\"Peux-tu allumer la lumière du salon ?\"))"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Device set to use cuda:0\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"[{'label': 'DATE', 'score': 0.5580002069473267}]\n",
"[{'label': 'DATE', 'score': 0.5598549842834473}]\n",
"[{'label': 'ETEINDRE_CUISINE', 'score': 0.43001294136047363}]\n",
"[{'label': 'ETEINDRE_CUISINE', 'score': 0.43393829464912415}]\n",
"[{'label': 'METEO', 'score': 0.5053706765174866}]\n",
"[{'label': 'METEO', 'score': 0.4990154802799225}]\n",
"[{'label': 'TEMPERATURE_INTERIEUR', 'score': 0.297404944896698}]\n",
"[{'label': 'ALLUMER_BUREAU', 'score': 0.411824494600296}]\n"
]
}
],
"source": [
"classifier1 = pipeline(\"sentiment-analysis\", model=\"/home/tjiho/info/text-classification/domotique_command_classification/checkpoint-262\")\n",
"print(classifier1(\"quelle heure est-il ?\"))\n",
"print(classifier1(\"Est-ce que tu sais l'heure qu'il est ?\"))\n",
"print(classifier1(\"Peux-tu couper la lumière de la cuisine ?\"))\n",
"print(classifier1(\"Il faut éteindre la lampe de la cuisine.\"))\n",
"print(classifier1(\"Quel temps fait-il ?\"))\n",
"print(classifier1(\"Tu sais quel temps il y a aujourd'hui ?\"))\n",
"print(classifier1(\"Il fait combien dans la maison ?\"))\n",
"print(classifier1(\"Peux-tu allumer la lumière du salon ?\"))"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Device set to use cuda:0\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"[{'label': 'DATE', 'score': 0.8812636733055115}]\n",
"[{'label': 'DATE', 'score': 0.8821314573287964}]\n",
"[{'label': 'ETEINDRE_CUISINE', 'score': 0.8183162212371826}]\n",
"[{'label': 'ETEINDRE_CUISINE', 'score': 0.8197460174560547}]\n",
"[{'label': 'METEO', 'score': 0.8433207273483276}]\n",
"[{'label': 'METEO', 'score': 0.8456273674964905}]\n",
"[{'label': 'TEMPERATURE_INTERIEUR', 'score': 0.7932029962539673}]\n",
"[{'label': 'ALLUMER_BUREAU', 'score': 0.8105173110961914}]\n"
]
}
],
"source": [
"classifier = pipeline(\"sentiment-analysis\", model=\"/home/tjiho/info/text-classification/domotique_command_classification/checkpoint-524\")\n",
"print(classifier(\"quelle heure est-il ?\"))\n",
"print(classifier(\"Est-ce que tu sais l'heure qu'il est ?\"))\n",
"print(classifier(\"Peux-tu couper la lumière de la cuisine ?\"))\n",
"print(classifier(\"Il faut éteindre la lampe de la cuisine.\"))\n",
"print(classifier(\"Quel temps fait-il ?\"))\n",
"print(classifier(\"Tu sais quel temps il y a aujourd'hui ?\"))\n",
"print(classifier(\"Il fait combien dans la maison ?\"))\n",
"print(classifier(\"Peux-tu allumer la lumière du salon ?\"))"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Device set to use cuda:0\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"[{'label': 'DATE', 'score': 0.9106536507606506}]\n",
"[{'label': 'DATE', 'score': 0.9111823439598083}]\n",
"[{'label': 'ETEINDRE_CUISINE', 'score': 0.8613969087600708}]\n",
"[{'label': 'ETEINDRE_CUISINE', 'score': 0.8620599508285522}]\n",
"[{'label': 'METEO', 'score': 0.8846598863601685}]\n",
"[{'label': 'METEO', 'score': 0.886086642742157}]\n",
"[{'label': 'TEMPERATURE_INTERIEUR', 'score': 0.8476815819740295}]\n",
"[{'label': 'ALLUMER_BUREAU', 'score': 0.8575024604797363}]\n"
]
}
],
"source": [
"classifier = pipeline(\"sentiment-analysis\", model=\"/home/tjiho/info/text-classification/domotique_command_classification/checkpoint-786\")\n",
"print(classifier(\"quelle heure est-il ?\"))\n",
"print(classifier(\"Est-ce que tu sais l'heure qu'il est ?\"))\n",
"print(classifier(\"Peux-tu couper la lumière de la cuisine ?\"))\n",
"print(classifier(\"Il faut éteindre la lampe de la cuisine.\"))\n",
"print(classifier(\"Quel temps fait-il ?\"))\n",
"print(classifier(\"Tu sais quel temps il y a aujourd'hui ?\"))\n",
"print(classifier(\"Il fait combien dans la maison ?\"))\n",
"print(classifier(\"Peux-tu allumer la lumière du salon ?\"))"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Device set to use cuda:0\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"[{'label': 'DATE', 'score': 0.9273341298103333}]\n",
"[{'label': 'DATE', 'score': 0.927768886089325}]\n",
"[{'label': 'ETEINDRE_CUISINE', 'score': 0.8900092840194702}]\n",
"[{'label': 'ETEINDRE_CUISINE', 'score': 0.8914997577667236}]\n",
"[{'label': 'METEO', 'score': 0.908128559589386}]\n",
"[{'label': 'METEO', 'score': 0.9089935421943665}]\n",
"[{'label': 'TEMPERATURE_INTERIEUR', 'score': 0.8813878297805786}]\n",
"[{'label': 'ALLUMER_BUREAU', 'score': 0.8875812888145447}]\n"
]
}
],
"source": [
"classifier = pipeline(\"sentiment-analysis\", model=\"/home/tjiho/info/text-classification/domotique_command_classification/checkpoint-1048\")\n",
"print(classifier(\"quelle heure est-il ?\"))\n",
"print(classifier(\"Est-ce que tu sais l'heure qu'il est ?\"))\n",
"print(classifier(\"Peux-tu couper la lumière de la cuisine ?\"))\n",
"print(classifier(\"Il faut éteindre la lampe de la cuisine.\"))\n",
"print(classifier(\"Quel temps fait-il ?\"))\n",
"print(classifier(\"Tu sais quel temps il y a aujourd'hui ?\"))\n",
"print(classifier(\"Il fait combien dans la maison ?\"))\n",
"print(classifier(\"Peux-tu allumer la lumière du salon ?\"))"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Device set to use cuda:0\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"[{'label': 'DATE', 'score': 0.9388740658760071}]\n",
"[{'label': 'DATE', 'score': 0.9391250610351562}]\n",
"[{'label': 'ETEINDRE_CUISINE', 'score': 0.9062478542327881}]\n",
"[{'label': 'ETEINDRE_CUISINE', 'score': 0.9078525900840759}]\n",
"[{'label': 'METEO', 'score': 0.9233420491218567}]\n",
"[{'label': 'METEO', 'score': 0.9240039587020874}]\n",
"[{'label': 'TEMPERATURE_INTERIEUR', 'score': 0.8987600207328796}]\n",
"[{'label': 'ALLUMER_BUREAU', 'score': 0.9068700671195984}]\n"
]
}
],
"source": [
"classifier = pipeline(\"sentiment-analysis\", model=\"/home/tjiho/info/text-classification/domotique_command_classification/checkpoint-2096\")\n",
"print(classifier(\"quelle heure est-il ?\"))\n",
"print(classifier(\"Est-ce que tu sais l'heure qu'il est ?\"))\n",
"print(classifier(\"Peux-tu couper la lumière de la cuisine ?\"))\n",
"print(classifier(\"Il faut éteindre la lampe de la cuisine.\"))\n",
"print(classifier(\"Quel temps fait-il ?\"))\n",
"print(classifier(\"Tu sais quel temps il y a aujourd'hui ?\"))\n",
"print(classifier(\"Il fait combien dans la maison ?\"))\n",
"print(classifier(\"Peux-tu allumer la lumière du salon ?\"))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "env-spacy",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.16"
}
},
"nbformat": 4,
"nbformat_minor": 2
}