850 lines
66 KiB
Plaintext
850 lines
66 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"source": [
|
|
"![Logo 1](https://git.wmi.amu.edu.pl/AITech/Szablon/raw/branch/master/Logotyp_AITech1.jpg)\n",
|
|
"<div class=\"alert alert-block alert-info\">\n",
|
|
"<h1> Systemy Dialogowe </h1>\n",
|
|
"<h2> 9. <i>Zarządzanie dialogiem z wykorzystaniem reguł</i> [laboratoria]</h2> \n",
|
|
"<h3> Marek Kubis (2021)</h3>\n",
|
|
"</div>\n",
|
|
"\n",
|
|
"![Logo 2](https://git.wmi.amu.edu.pl/AITech/Szablon/raw/branch/master/Logotyp_AITech2.jpg)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Zarządzanie dialogiem z wykorzystaniem reguł\n",
|
|
"============================================\n",
|
|
"\n",
|
|
"Agent dialogowy wykorzystuje do zarządzanie dialogiem dwa moduły:\n",
|
|
"\n",
|
|
" - monitor stanu dialogu (dialogue state tracker, DST) — moduł odpowiedzialny za śledzenie stanu dialogu.\n",
|
|
"\n",
|
|
" - taktykę prowadzenia dialogu (dialogue policy) — moduł, który na podstawie stanu dialogu\n",
|
|
" podejmuje decyzję o tym jaką akcję (akt systemu) agent ma podjąć w kolejnej turze.\n",
|
|
"\n",
|
|
"Oba moduły mogą być realizowane zarówno z wykorzystaniem reguł jak i uczenia maszynowego.\n",
|
|
"Mogą one zostać również połączone w pojedynczy moduł zwany wówczas *menedżerem dialogu*.\n",
|
|
"\n",
|
|
"Przykład\n",
|
|
"--------\n",
|
|
"\n",
|
|
"Zaimplementujemy regułowe moduły monitora stanu dialogu oraz taktyki dialogowej a następnie\n",
|
|
"osadzimy je w środowisku *[ConvLab-2](https://github.com/thu-coai/ConvLab-2)*,\n",
|
|
"które służy do ewaluacji systemów dialogowych.\n",
|
|
"\n",
|
|
"**Uwaga:** Niektóre moduły środowiska *ConvLab-2* nie są zgodne z najnowszymi wersjami Pythona,\n",
|
|
"dlatego przed uruchomieniem poniższych przykładów należy się upewnić, że mają Państwo interpreter\n",
|
|
"Pythona w wersji 3.7. W przypadku nowszych wersji Ubuntu Pythona 3.7 można zainstalować z\n",
|
|
"repozytorium `deadsnakes`, wykonując polecenia przedstawione poniżej.\n",
|
|
"\n",
|
|
"```\n",
|
|
"sudo add-apt-repository ppa:deadsnakes/ppa\n",
|
|
"sudo apt update\n",
|
|
"sudo apt install python3.7 python3.7-dev python3.7-venv\n",
|
|
"```\n",
|
|
"\n",
|
|
"W przypadku innych systemów można skorzystać np. z narzędzia [pyenv](https://github.com/pyenv/pyenv) lub środowiska [conda](https://conda.io).\n",
|
|
"\n",
|
|
"Ze względu na to, że *ConvLab-2* ma wiele zależności zachęcam również do skorzystania ze środowiska\n",
|
|
"wirtualnego `venv`, w którym moduły zależne mogą zostać zainstalowane.\n",
|
|
"W tym celu należy wykonać następujące polecenia\n",
|
|
"\n",
|
|
"```\n",
|
|
"python3.7 -m venv convenv # utworzenie nowego środowiska o nazwie convenv\n",
|
|
"source convenv/bin/activate # aktywacja środowiska w bieżącej powłoce\n",
|
|
"pip install --ignore-installed jupyter # instalacja jupytera w środowisku convenv\n",
|
|
"```\n",
|
|
"\n",
|
|
"Po skonfigurowaniu środowiska można przystąpić do instalacji *ConvLab-2*, korzystając z\n",
|
|
"następujących poleceń\n",
|
|
"\n",
|
|
"```\n",
|
|
"mkdir -p l08\n",
|
|
"cd l08\n",
|
|
"git clone https://github.com/thu-coai/ConvLab-2.git\n",
|
|
"cd ConvLab-2\n",
|
|
"pip install -e .\n",
|
|
"python -m spacy download en_core_web_sm\n",
|
|
"cd ../..\n",
|
|
"```\n",
|
|
"\n",
|
|
"Po zakończeniu instalacji należy ponownie uruchomić notatnik w powłoce, w której aktywne jest\n",
|
|
"środowisko wirtualne *convenv*.\n",
|
|
"\n",
|
|
"```\n",
|
|
"jupyter notebook 08-zarzadzanie-dialogiem-reguly.ipynb\n",
|
|
"```\n",
|
|
"\n",
|
|
"Działanie zaimplementowanych modułów zilustrujemy, korzystając ze zbioru danych\n",
|
|
"[MultiWOZ](https://github.com/budzianowski/multiwoz) (Budzianowski i in., 2018), który zawiera\n",
|
|
"wypowiedzi dotyczące m.in. rezerwacji pokoi hotelowych, zamawiania biletów kolejowych oraz\n",
|
|
"rezerwacji stolików w restauracji.\n",
|
|
"\n",
|
|
"### Monitor Stanu Dialogu\n",
|
|
"\n",
|
|
"Do reprezentowania stanu dialogu użyjemy struktury danych wykorzystywanej w *ConvLab-2*."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"{'user_action': [],\n",
|
|
" 'system_action': [],\n",
|
|
" 'belief_state': {'police': {'book': {'booked': []}, 'semi': {}},\n",
|
|
" 'hotel': {'book': {'booked': [], 'people': '', 'day': '', 'stay': ''},\n",
|
|
" 'semi': {'name': '',\n",
|
|
" 'area': '',\n",
|
|
" 'parking': '',\n",
|
|
" 'pricerange': '',\n",
|
|
" 'stars': '',\n",
|
|
" 'internet': '',\n",
|
|
" 'type': ''}},\n",
|
|
" 'attraction': {'book': {'booked': []},\n",
|
|
" 'semi': {'type': '', 'name': '', 'area': ''}},\n",
|
|
" 'restaurant': {'book': {'booked': [], 'people': '', 'day': '', 'time': ''},\n",
|
|
" 'semi': {'food': '', 'pricerange': '', 'name': '', 'area': ''}},\n",
|
|
" 'hospital': {'book': {'booked': []}, 'semi': {'department': ''}},\n",
|
|
" 'taxi': {'book': {'booked': []},\n",
|
|
" 'semi': {'leaveAt': '',\n",
|
|
" 'destination': '',\n",
|
|
" 'departure': '',\n",
|
|
" 'arriveBy': ''}},\n",
|
|
" 'train': {'book': {'booked': [], 'people': ''},\n",
|
|
" 'semi': {'leaveAt': '',\n",
|
|
" 'destination': '',\n",
|
|
" 'day': '',\n",
|
|
" 'arriveBy': '',\n",
|
|
" 'departure': ''}}},\n",
|
|
" 'request_state': {},\n",
|
|
" 'terminated': False,\n",
|
|
" 'history': []}"
|
|
]
|
|
},
|
|
"execution_count": 1,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"from convlab2.util.multiwoz.state import default_state\n",
|
|
"default_state()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Metoda `update` naszego monitora stanu dialogu będzie przyjmować akty użytkownika i odpowiednio\n",
|
|
"modyfikować stan dialogu.\n",
|
|
"W przypadku aktów typu `inform` wartości slotów zostaną zapamiętane w słownikach odpowiadających\n",
|
|
"poszczególnym dziedzinom pod kluczem `belief_state`.\n",
|
|
"W przypadku aktów typu `request` sloty, o które pyta użytkownik zostaną zapisane pod kluczem\n",
|
|
"`request_state`.\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 2,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json\n",
|
|
"import os\n",
|
|
"from convlab2.dst.dst import DST\n",
|
|
"from convlab2.dst.rule.multiwoz.dst_util import normalize_value\n",
|
|
"from convlab2.util.multiwoz.multiwoz_slot_trans import REF_SYS_DA\n",
|
|
"\n",
|
|
"\n",
|
|
"class SimpleRuleDST(DST):\n",
|
|
" def __init__(self):\n",
|
|
" DST.__init__(self)\n",
|
|
" self.state = default_state()\n",
|
|
" self.value_dict = json.load(open('ConvLab-2/data/multiwoz/value_dict.json'))\n",
|
|
"\n",
|
|
" def update(self, user_act=None):\n",
|
|
" for intent, domain, slot, value in user_act:\n",
|
|
" domain = domain.lower()\n",
|
|
" intent = intent.lower()\n",
|
|
"\n",
|
|
" if domain in ['unk', 'general', 'booking']:\n",
|
|
" continue\n",
|
|
"\n",
|
|
" if intent == 'inform':\n",
|
|
" k = REF_SYS_DA[domain.capitalize()].get(slot, slot)\n",
|
|
"\n",
|
|
" if k is None:\n",
|
|
" continue\n",
|
|
"\n",
|
|
" domain_dic = self.state['belief_state'][domain]\n",
|
|
"\n",
|
|
" if k in domain_dic['semi']:\n",
|
|
" nvalue = normalize_value(self.value_dict, domain, k, value)\n",
|
|
" self.state['belief_state'][domain]['semi'][k] = nvalue\n",
|
|
" elif k in domain_dic['book']:\n",
|
|
" self.state['belief_state'][domain]['book'][k] = value\n",
|
|
" elif k.lower() in domain_dic['book']:\n",
|
|
" self.state['belief_state'][domain]['book'][k.lower()] = value\n",
|
|
" elif intent == 'request':\n",
|
|
" k = REF_SYS_DA[domain.capitalize()].get(slot, slot)\n",
|
|
"\n",
|
|
" if domain not in self.state['request_state']:\n",
|
|
" self.state['request_state'][domain] = {}\n",
|
|
" if k not in self.state['request_state'][domain]:\n",
|
|
" self.state['request_state'][domain][k] = 0\n",
|
|
"\n",
|
|
" return self.state\n",
|
|
"\n",
|
|
" def init_session(self):\n",
|
|
" self.state = default_state()\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"W definicji metody `update` zakładamy, że akty dialogowe przekazywane do monitora stanu dialogu z\n",
|
|
"modułu NLU są czteroelementowymi listami złożonymi z:\n",
|
|
"\n",
|
|
" - nazwy aktu użytkownika,\n",
|
|
" - nazwy dziedziny, której dotyczy wypowiedź,\n",
|
|
" - nazwy slotu,\n",
|
|
" - wartości slotu.\n",
|
|
"\n",
|
|
"Zobaczmy na kilku prostych przykładach jak stan dialogu zmienia się pod wpływem przekazanych aktów\n",
|
|
"użytkownika."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 3,
|
|
"metadata": {
|
|
"lines_to_next_cell": 0
|
|
},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"{'user_action': [],\n",
|
|
" 'system_action': [],\n",
|
|
" 'belief_state': {'police': {'book': {'booked': []}, 'semi': {}},\n",
|
|
" 'hotel': {'book': {'booked': [], 'people': '', 'day': '', 'stay': ''},\n",
|
|
" 'semi': {'name': '',\n",
|
|
" 'area': '',\n",
|
|
" 'parking': '',\n",
|
|
" 'pricerange': '',\n",
|
|
" 'stars': '',\n",
|
|
" 'internet': '',\n",
|
|
" 'type': ''}},\n",
|
|
" 'attraction': {'book': {'booked': []},\n",
|
|
" 'semi': {'type': '', 'name': '', 'area': ''}},\n",
|
|
" 'restaurant': {'book': {'booked': [], 'people': '', 'day': '', 'time': ''},\n",
|
|
" 'semi': {'food': '', 'pricerange': '', 'name': '', 'area': ''}},\n",
|
|
" 'hospital': {'book': {'booked': []}, 'semi': {'department': ''}},\n",
|
|
" 'taxi': {'book': {'booked': []},\n",
|
|
" 'semi': {'leaveAt': '',\n",
|
|
" 'destination': '',\n",
|
|
" 'departure': '',\n",
|
|
" 'arriveBy': ''}},\n",
|
|
" 'train': {'book': {'booked': [], 'people': ''},\n",
|
|
" 'semi': {'leaveAt': '',\n",
|
|
" 'destination': '',\n",
|
|
" 'day': '',\n",
|
|
" 'arriveBy': '',\n",
|
|
" 'departure': ''}}},\n",
|
|
" 'request_state': {},\n",
|
|
" 'terminated': False,\n",
|
|
" 'history': []}"
|
|
]
|
|
},
|
|
"execution_count": 3,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"dst = SimpleRuleDST()\n",
|
|
"dst.state"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 4,
|
|
"metadata": {
|
|
"lines_to_next_cell": 0
|
|
},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"{'book': {'booked': [], 'people': '', 'day': '', 'stay': ''},\n",
|
|
" 'semi': {'name': '',\n",
|
|
" 'area': '',\n",
|
|
" 'parking': 'yes',\n",
|
|
" 'pricerange': 'cheap',\n",
|
|
" 'stars': '',\n",
|
|
" 'internet': '',\n",
|
|
" 'type': ''}}"
|
|
]
|
|
},
|
|
"execution_count": 4,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"dst.update([['Inform', 'Hotel', 'Price', 'cheap'], ['Inform', 'Hotel', 'Parking', 'yes']])\n",
|
|
"dst.state['belief_state']['hotel']"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 5,
|
|
"metadata": {
|
|
"lines_to_next_cell": 0
|
|
},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"{'book': {'booked': [], 'people': '', 'day': '', 'stay': ''},\n",
|
|
" 'semi': {'name': '',\n",
|
|
" 'area': 'north',\n",
|
|
" 'parking': 'yes',\n",
|
|
" 'pricerange': 'cheap',\n",
|
|
" 'stars': '',\n",
|
|
" 'internet': '',\n",
|
|
" 'type': ''}}"
|
|
]
|
|
},
|
|
"execution_count": 5,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"dst.update([['Inform', 'Hotel', 'Area', 'north']])\n",
|
|
"dst.state['belief_state']['hotel']"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 6,
|
|
"metadata": {
|
|
"lines_to_next_cell": 0
|
|
},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"{'hotel': {'area': 0}}"
|
|
]
|
|
},
|
|
"execution_count": 6,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"dst.update([['Request', 'Hotel', 'Area', '?']])\n",
|
|
"dst.state['request_state']"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 7,
|
|
"metadata": {
|
|
"lines_to_next_cell": 0
|
|
},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"{'book': {'booked': [], 'people': '2', 'day': 'tuesday', 'stay': '4'},\n",
|
|
" 'semi': {'name': '',\n",
|
|
" 'area': 'north',\n",
|
|
" 'parking': 'yes',\n",
|
|
" 'pricerange': 'cheap',\n",
|
|
" 'stars': '',\n",
|
|
" 'internet': '',\n",
|
|
" 'type': ''}}"
|
|
]
|
|
},
|
|
"execution_count": 7,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"dst.update([['Inform', 'Hotel', 'Day', 'tuesday'], ['Inform', 'Hotel', 'People', '2'], ['Inform', 'Hotel', 'Stay', '4']])\n",
|
|
"dst.state['belief_state']['hotel']"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 8,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"{'user_action': [],\n",
|
|
" 'system_action': [],\n",
|
|
" 'belief_state': {'police': {'book': {'booked': []}, 'semi': {}},\n",
|
|
" 'hotel': {'book': {'booked': [],\n",
|
|
" 'people': '2',\n",
|
|
" 'day': 'tuesday',\n",
|
|
" 'stay': '4'},\n",
|
|
" 'semi': {'name': '',\n",
|
|
" 'area': 'north',\n",
|
|
" 'parking': 'yes',\n",
|
|
" 'pricerange': 'cheap',\n",
|
|
" 'stars': '',\n",
|
|
" 'internet': '',\n",
|
|
" 'type': ''}},\n",
|
|
" 'attraction': {'book': {'booked': []},\n",
|
|
" 'semi': {'type': '', 'name': '', 'area': ''}},\n",
|
|
" 'restaurant': {'book': {'booked': [], 'people': '', 'day': '', 'time': ''},\n",
|
|
" 'semi': {'food': '', 'pricerange': '', 'name': '', 'area': ''}},\n",
|
|
" 'hospital': {'book': {'booked': []}, 'semi': {'department': ''}},\n",
|
|
" 'taxi': {'book': {'booked': []},\n",
|
|
" 'semi': {'leaveAt': '',\n",
|
|
" 'destination': '',\n",
|
|
" 'departure': '',\n",
|
|
" 'arriveBy': ''}},\n",
|
|
" 'train': {'book': {'booked': [], 'people': ''},\n",
|
|
" 'semi': {'leaveAt': '',\n",
|
|
" 'destination': '',\n",
|
|
" 'day': '',\n",
|
|
" 'arriveBy': '',\n",
|
|
" 'departure': ''}}},\n",
|
|
" 'request_state': {'hotel': {'area': 0}},\n",
|
|
" 'terminated': False,\n",
|
|
" 'history': []}"
|
|
]
|
|
},
|
|
"execution_count": 8,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"dst.state"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"### Taktyka Prowadzenia Dialogu\n",
|
|
"\n",
|
|
"Prosta taktyka prowadzenia dialogu dla systemu rezerwacji pokoi hotelowych może składać się z następujących reguł:\n",
|
|
"\n",
|
|
" 1. Jeżeli użytkownik przekazał w ostatniej turze akt typu `Request`, to udziel odpowiedzi na jego\n",
|
|
" pytanie.\n",
|
|
"\n",
|
|
" 2. Jeżeli użytkownik przekazał w ostatniej turze akt typu `Inform`, to zaproponuj mu hotel\n",
|
|
" spełniający zdefiniowane przez niego kryteria.\n",
|
|
"\n",
|
|
" 3. Jeżeli użytkownik przekazał w ostatniej turze akt typu `Inform` zawierający szczegóły\n",
|
|
" rezerwacji, to zarezerwuj pokój.\n",
|
|
"\n",
|
|
"Metoda `predict` taktyki `SimpleRulePolicy` realizuje reguły przedstawione powyżej."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 10,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"from collections import defaultdict\n",
|
|
"import copy\n",
|
|
"import json\n",
|
|
"from copy import deepcopy\n",
|
|
"\n",
|
|
"from convlab2.policy.policy import Policy\n",
|
|
"from convlab2.util.multiwoz.dbquery import Database\n",
|
|
"from convlab2.util.multiwoz.multiwoz_slot_trans import REF_SYS_DA, REF_USR_DA\n",
|
|
"\n",
|
|
"\n",
|
|
"class SimpleRulePolicy(Policy):\n",
|
|
" def __init__(self):\n",
|
|
" Policy.__init__(self)\n",
|
|
" self.db = Database()\n",
|
|
"\n",
|
|
" def predict(self, state):\n",
|
|
" self.results = []\n",
|
|
" system_action = defaultdict(list)\n",
|
|
" user_action = defaultdict(list)\n",
|
|
"\n",
|
|
" for intent, domain, slot, value in state['user_action']:\n",
|
|
" user_action[(domain, intent)].append((slot, value))\n",
|
|
"\n",
|
|
" for user_act in user_action:\n",
|
|
" self.update_system_action(user_act, user_action, state, system_action)\n",
|
|
"\n",
|
|
" # Reguła 3\n",
|
|
" if any(True for slots in user_action.values() for (slot, _) in slots if slot in ['Stay', 'Day', 'People']):\n",
|
|
" if self.results:\n",
|
|
" system_action = {('Booking', 'Book'): [[\"Ref\", self.results[0].get('Ref', 'N/A')]]}\n",
|
|
"\n",
|
|
" system_acts = [[intent, domain, slot, value] for (domain, intent), slots in system_action.items() for slot, value in slots]\n",
|
|
" state['system_action'] = system_acts\n",
|
|
" return system_acts\n",
|
|
"\n",
|
|
" def update_system_action(self, user_act, user_action, state, system_action):\n",
|
|
" domain, intent = user_act\n",
|
|
" constraints = [(slot, value) for slot, value in state['belief_state'][domain.lower()]['semi'].items() if value != '']\n",
|
|
" self.results = deepcopy(self.db.query(domain.lower(), constraints))\n",
|
|
"\n",
|
|
" # Reguła 1\n",
|
|
" if intent == 'Request':\n",
|
|
" if len(self.results) == 0:\n",
|
|
" system_action[(domain, 'NoOffer')] = []\n",
|
|
" else:\n",
|
|
" for slot in user_action[user_act]:\n",
|
|
" kb_slot_name = REF_SYS_DA[domain].get(slot[0], slot[0])\n",
|
|
"\n",
|
|
" if kb_slot_name in self.results[0]:\n",
|
|
" system_action[(domain, 'Inform')].append([slot[0], self.results[0].get(kb_slot_name, 'unknown')])\n",
|
|
"\n",
|
|
" # Reguła 2\n",
|
|
" elif intent == 'Inform':\n",
|
|
" if len(self.results) == 0:\n",
|
|
" system_action[(domain, 'NoOffer')] = []\n",
|
|
" else:\n",
|
|
" system_action[(domain, 'Inform')].append(['Choice', str(len(self.results))])\n",
|
|
" choice = self.results[0]\n",
|
|
"\n",
|
|
" if domain in [\"Hotel\", \"Attraction\", \"Police\", \"Restaurant\"]:\n",
|
|
" system_action[(domain, 'Recommend')].append(['Name', choice['name']])"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Podobnie jak w przypadku aktów użytkownika akty systemowe przekazywane do modułu NLG są czteroelementowymi listami złożonymi z:\n",
|
|
"\n",
|
|
" - nazwy aktu systemowe,\n",
|
|
" - nazwy dziedziny, której dotyczy wypowiedź,\n",
|
|
" - nazwy slotu,\n",
|
|
" - wartości slotu.\n",
|
|
"\n",
|
|
"Sprawdźmy jakie akty systemowe zwraca taktyka `SimpleRulePolicy` w odpowiedzi na zmieniający się stan dialogu."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 11,
|
|
"metadata": {
|
|
"lines_to_next_cell": 0
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"from convlab2.dialog_agent import PipelineAgent\n",
|
|
"dst.init_session()\n",
|
|
"policy = SimpleRulePolicy()\n",
|
|
"agent = PipelineAgent(nlu=None, dst=dst, policy=policy, nlg=None, name='sys')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 12,
|
|
"metadata": {
|
|
"lines_to_next_cell": 0
|
|
},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"[['Inform', 'Hotel', 'Choice', '10'],\n",
|
|
" ['Recommend', 'Hotel', 'Name', 'alexander bed and breakfast']]"
|
|
]
|
|
},
|
|
"execution_count": 12,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"agent.response([['Inform', 'Hotel', 'Price', 'cheap'], ['Inform', 'Hotel', 'Parking', 'yes']])"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 13,
|
|
"metadata": {
|
|
"lines_to_next_cell": 0
|
|
},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"[['Inform', 'Hotel', 'Choice', '2'],\n",
|
|
" ['Recommend', 'Hotel', 'Name', 'city centre north b and b']]"
|
|
]
|
|
},
|
|
"execution_count": 13,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"agent.response([['Inform', 'Hotel', 'Area', 'north']])"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 14,
|
|
"metadata": {
|
|
"lines_to_next_cell": 0
|
|
},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"[['Inform', 'Hotel', 'Area', 'north']]"
|
|
]
|
|
},
|
|
"execution_count": 14,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"agent.response([['Request', 'Hotel', 'Area', '?']])"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 15,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"[['Book', 'Booking', 'Ref', '00000013']]"
|
|
]
|
|
},
|
|
"execution_count": 15,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"agent.response([['Inform', 'Hotel', 'Day', 'tuesday'], ['Inform', 'Hotel', 'People', '2'], ['Inform', 'Hotel', 'Stay', '4']])"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"### Testy End-to-End\n",
|
|
"\n",
|
|
"Na koniec przeprowadźmy dialog łącząc w potok nasze moduły\n",
|
|
"z modułami NLU i NLG dostępnymi dla MultiWOZ w środowisku `ConvLab-2`."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 20,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"[<convlab2.nlu.svm.Features.nbest object at 0x0000028BDD2032C8>]\n",
|
|
"loading saved Classifier\n",
|
|
"loaded.\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"from convlab2.nlu.svm.multiwoz import SVMNLU\n",
|
|
"from convlab2.nlg.template.multiwoz import TemplateNLG\n",
|
|
"\n",
|
|
"nlu = SVMNLU()\n",
|
|
"nlg = TemplateNLG(is_user=False)\n",
|
|
"agent = PipelineAgent(nlu=nlu, dst=dst, policy=policy, nlg=nlg, name='sys')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 17,
|
|
"metadata": {
|
|
"lines_to_next_cell": 0
|
|
},
|
|
"outputs": [
|
|
{
|
|
"ename": "AttributeError",
|
|
"evalue": "'SVC' object has no attribute '_impl'",
|
|
"output_type": "error",
|
|
"traceback": [
|
|
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
|
|
"\u001b[1;31mAttributeError\u001b[0m Traceback (most recent call last)",
|
|
"\u001b[1;32m~\\AppData\\Local\\Temp\\ipykernel_13500\\3260802613.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0magent\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mresponse\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"I need a cheap hotel with free parking .\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
|
|
"\u001b[1;32mc:\\develop\\wmi\\aitech\\sem1\\systemy dialogowe\\lab\\convlab-2\\convlab2\\dialog_agent\\agent.py\u001b[0m in \u001b[0;36mresponse\u001b[1;34m(self, observation)\u001b[0m\n\u001b[0;32m 120\u001b[0m \u001b[1;31m# get dialog act\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 121\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mnlu\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 122\u001b[1;33m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0minput_action\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mnlu\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mpredict\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mobservation\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcontext\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mx\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mhistory\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m-\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 123\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 124\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0minput_action\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mobservation\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
|
"\u001b[1;32mc:\\develop\\wmi\\aitech\\sem1\\systemy dialogowe\\lab\\convlab-2\\convlab2\\nlu\\svm\\multiwoz\\nlu.py\u001b[0m in \u001b[0;36mpredict\u001b[1;34m(self, utterance, context)\u001b[0m\n\u001b[0;32m 74\u001b[0m ]\n\u001b[0;32m 75\u001b[0m }\n\u001b[1;32m---> 76\u001b[1;33m \u001b[0mslu_hyps\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mc\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdecode_sent\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0msentinfo\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mconfig\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"decode\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m\"output\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 77\u001b[0m \u001b[0mact_list\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m[\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 78\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mhyp\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mslu_hyps\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
|
"\u001b[1;32mc:\\develop\\wmi\\aitech\\sem1\\systemy dialogowe\\lab\\convlab-2\\convlab2\\nlu\\svm\\Classifier.py\u001b[0m in \u001b[0;36mdecode_sent\u001b[1;34m(self, sentinfo, output_fname, config)\u001b[0m\n\u001b[0;32m 320\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 321\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mextractFeatures2\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0msentinfo\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mlog_input_key\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mlog_input_key\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 322\u001b[1;33m \u001b[0mdecode_results\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdecode\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 323\u001b[0m \u001b[0mcounter\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mdefaultdict\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mint\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 324\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
|
|
"\u001b[1;32mc:\\develop\\wmi\\aitech\\sem1\\systemy dialogowe\\lab\\convlab-2\\convlab2\\nlu\\svm\\Classifier.py\u001b[0m in \u001b[0;36mdecode\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 258\u001b[0m \u001b[0mbaseXs\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m[\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mbaseXs\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mindex\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mindex\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mbaseX_pointers\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mthis_tuple\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 259\u001b[0m \u001b[0mX\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mtoSparse\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mbaseXs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mX\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mthis_tuple\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdictionary\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 260\u001b[1;33m \u001b[0mresults\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mthis_tuple\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mclassifiers\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mthis_tuple\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mpredict\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mX\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 261\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mresults\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 262\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
|
|
"\u001b[1;32mc:\\develop\\wmi\\aitech\\sem1\\systemy dialogowe\\lab\\convlab-2\\convlab2\\nlu\\svm\\Classifier.py\u001b[0m in \u001b[0;36mpredict\u001b[1;34m(self, X)\u001b[0m\n\u001b[0;32m 496\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 497\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mpredict\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mX\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 498\u001b[1;33m \u001b[0my\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmodel\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mpredict_proba\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mX\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 499\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0my\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 500\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
|
|
"\u001b[1;32mc:\\Develop\\wmi\\AITECH\\sem1\\Systemy dialogowe\\lab\\venv\\lib\\site-packages\\sklearn\\svm\\base.py\u001b[0m in \u001b[0;36mpredict_proba\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 588\u001b[0m \u001b[0mdatasets\u001b[0m\u001b[1;33m.\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 589\u001b[0m \"\"\"\n\u001b[1;32m--> 590\u001b[1;33m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_check_proba\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 591\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_predict_proba\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 592\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
|
|
"\u001b[1;32mc:\\Develop\\wmi\\AITECH\\sem1\\Systemy dialogowe\\lab\\venv\\lib\\site-packages\\sklearn\\svm\\base.py\u001b[0m in \u001b[0;36m_check_proba\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 557\u001b[0m raise AttributeError(\"predict_proba is not available when \"\n\u001b[0;32m 558\u001b[0m \" probability=False\")\n\u001b[1;32m--> 559\u001b[1;33m \u001b[1;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_impl\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[1;32min\u001b[0m \u001b[1;33m(\u001b[0m\u001b[1;34m'c_svc'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'nu_svc'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 560\u001b[0m raise AttributeError(\"predict_proba only implemented for SVC\"\n\u001b[0;32m 561\u001b[0m \" and NuSVC\")\n",
|
|
"\u001b[1;31mAttributeError\u001b[0m: 'SVC' object has no attribute '_impl'"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"agent.response(\"I need a cheap hotel with free parking .\")"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 18,
|
|
"metadata": {
|
|
"lines_to_next_cell": 0
|
|
},
|
|
"outputs": [
|
|
{
|
|
"ename": "AttributeError",
|
|
"evalue": "'SVC' object has no attribute '_impl'",
|
|
"output_type": "error",
|
|
"traceback": [
|
|
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
|
|
"\u001b[1;31mAttributeError\u001b[0m Traceback (most recent call last)",
|
|
"\u001b[1;32m~\\AppData\\Local\\Temp\\ipykernel_13500\\2723043776.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0magent\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mresponse\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Where it is located ?\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
|
|
"\u001b[1;32mc:\\develop\\wmi\\aitech\\sem1\\systemy dialogowe\\lab\\convlab-2\\convlab2\\dialog_agent\\agent.py\u001b[0m in \u001b[0;36mresponse\u001b[1;34m(self, observation)\u001b[0m\n\u001b[0;32m 120\u001b[0m \u001b[1;31m# get dialog act\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 121\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mnlu\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 122\u001b[1;33m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0minput_action\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mnlu\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mpredict\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mobservation\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcontext\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mx\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mhistory\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m-\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 123\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 124\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0minput_action\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mobservation\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
|
"\u001b[1;32mc:\\develop\\wmi\\aitech\\sem1\\systemy dialogowe\\lab\\convlab-2\\convlab2\\nlu\\svm\\multiwoz\\nlu.py\u001b[0m in \u001b[0;36mpredict\u001b[1;34m(self, utterance, context)\u001b[0m\n\u001b[0;32m 74\u001b[0m ]\n\u001b[0;32m 75\u001b[0m }\n\u001b[1;32m---> 76\u001b[1;33m \u001b[0mslu_hyps\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mc\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdecode_sent\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0msentinfo\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mconfig\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"decode\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m\"output\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 77\u001b[0m \u001b[0mact_list\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m[\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 78\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mhyp\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mslu_hyps\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
|
"\u001b[1;32mc:\\develop\\wmi\\aitech\\sem1\\systemy dialogowe\\lab\\convlab-2\\convlab2\\nlu\\svm\\Classifier.py\u001b[0m in \u001b[0;36mdecode_sent\u001b[1;34m(self, sentinfo, output_fname, config)\u001b[0m\n\u001b[0;32m 320\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 321\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mextractFeatures2\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0msentinfo\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mlog_input_key\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mlog_input_key\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 322\u001b[1;33m \u001b[0mdecode_results\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdecode\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 323\u001b[0m \u001b[0mcounter\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mdefaultdict\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mint\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 324\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
|
|
"\u001b[1;32mc:\\develop\\wmi\\aitech\\sem1\\systemy dialogowe\\lab\\convlab-2\\convlab2\\nlu\\svm\\Classifier.py\u001b[0m in \u001b[0;36mdecode\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 258\u001b[0m \u001b[0mbaseXs\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m[\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mbaseXs\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mindex\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mindex\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mbaseX_pointers\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mthis_tuple\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 259\u001b[0m \u001b[0mX\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mtoSparse\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mbaseXs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mX\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mthis_tuple\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdictionary\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 260\u001b[1;33m \u001b[0mresults\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mthis_tuple\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mclassifiers\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mthis_tuple\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mpredict\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mX\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 261\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mresults\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 262\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
|
|
"\u001b[1;32mc:\\develop\\wmi\\aitech\\sem1\\systemy dialogowe\\lab\\convlab-2\\convlab2\\nlu\\svm\\Classifier.py\u001b[0m in \u001b[0;36mpredict\u001b[1;34m(self, X)\u001b[0m\n\u001b[0;32m 496\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 497\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mpredict\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mX\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 498\u001b[1;33m \u001b[0my\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmodel\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mpredict_proba\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mX\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 499\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0my\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 500\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
|
|
"\u001b[1;32mc:\\Develop\\wmi\\AITECH\\sem1\\Systemy dialogowe\\lab\\venv\\lib\\site-packages\\sklearn\\svm\\base.py\u001b[0m in \u001b[0;36mpredict_proba\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 588\u001b[0m \u001b[0mdatasets\u001b[0m\u001b[1;33m.\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 589\u001b[0m \"\"\"\n\u001b[1;32m--> 590\u001b[1;33m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_check_proba\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 591\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_predict_proba\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 592\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
|
|
"\u001b[1;32mc:\\Develop\\wmi\\AITECH\\sem1\\Systemy dialogowe\\lab\\venv\\lib\\site-packages\\sklearn\\svm\\base.py\u001b[0m in \u001b[0;36m_check_proba\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 557\u001b[0m raise AttributeError(\"predict_proba is not available when \"\n\u001b[0;32m 558\u001b[0m \" probability=False\")\n\u001b[1;32m--> 559\u001b[1;33m \u001b[1;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_impl\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[1;32min\u001b[0m \u001b[1;33m(\u001b[0m\u001b[1;34m'c_svc'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'nu_svc'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 560\u001b[0m raise AttributeError(\"predict_proba only implemented for SVC\"\n\u001b[0;32m 561\u001b[0m \" and NuSVC\")\n",
|
|
"\u001b[1;31mAttributeError\u001b[0m: 'SVC' object has no attribute '_impl'"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"agent.response(\"Where it is located ?\")"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 19,
|
|
"metadata": {
|
|
"lines_to_next_cell": 0
|
|
},
|
|
"outputs": [
|
|
{
|
|
"ename": "AttributeError",
|
|
"evalue": "'SVC' object has no attribute '_impl'",
|
|
"output_type": "error",
|
|
"traceback": [
|
|
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
|
|
"\u001b[1;31mAttributeError\u001b[0m Traceback (most recent call last)",
|
|
"\u001b[1;32m~\\AppData\\Local\\Temp\\ipykernel_13500\\871593950.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0magent\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mresponse\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"I would prefer the hotel be in the north part of town .\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
|
|
"\u001b[1;32mc:\\develop\\wmi\\aitech\\sem1\\systemy dialogowe\\lab\\convlab-2\\convlab2\\dialog_agent\\agent.py\u001b[0m in \u001b[0;36mresponse\u001b[1;34m(self, observation)\u001b[0m\n\u001b[0;32m 120\u001b[0m \u001b[1;31m# get dialog act\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 121\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mnlu\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 122\u001b[1;33m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0minput_action\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mnlu\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mpredict\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mobservation\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcontext\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mx\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mhistory\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m-\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 123\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 124\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0minput_action\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mobservation\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
|
"\u001b[1;32mc:\\develop\\wmi\\aitech\\sem1\\systemy dialogowe\\lab\\convlab-2\\convlab2\\nlu\\svm\\multiwoz\\nlu.py\u001b[0m in \u001b[0;36mpredict\u001b[1;34m(self, utterance, context)\u001b[0m\n\u001b[0;32m 74\u001b[0m ]\n\u001b[0;32m 75\u001b[0m }\n\u001b[1;32m---> 76\u001b[1;33m \u001b[0mslu_hyps\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mc\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdecode_sent\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0msentinfo\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mconfig\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"decode\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m\"output\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 77\u001b[0m \u001b[0mact_list\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m[\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 78\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mhyp\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mslu_hyps\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
|
"\u001b[1;32mc:\\develop\\wmi\\aitech\\sem1\\systemy dialogowe\\lab\\convlab-2\\convlab2\\nlu\\svm\\Classifier.py\u001b[0m in \u001b[0;36mdecode_sent\u001b[1;34m(self, sentinfo, output_fname, config)\u001b[0m\n\u001b[0;32m 320\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 321\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mextractFeatures2\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0msentinfo\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mlog_input_key\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mlog_input_key\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 322\u001b[1;33m \u001b[0mdecode_results\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdecode\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 323\u001b[0m \u001b[0mcounter\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mdefaultdict\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mint\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 324\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
|
|
"\u001b[1;32mc:\\develop\\wmi\\aitech\\sem1\\systemy dialogowe\\lab\\convlab-2\\convlab2\\nlu\\svm\\Classifier.py\u001b[0m in \u001b[0;36mdecode\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 258\u001b[0m \u001b[0mbaseXs\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m[\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mbaseXs\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mindex\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mindex\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mbaseX_pointers\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mthis_tuple\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 259\u001b[0m \u001b[0mX\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mtoSparse\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mbaseXs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mX\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mthis_tuple\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdictionary\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 260\u001b[1;33m \u001b[0mresults\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mthis_tuple\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mclassifiers\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mthis_tuple\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mpredict\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mX\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 261\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mresults\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 262\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
|
|
"\u001b[1;32mc:\\develop\\wmi\\aitech\\sem1\\systemy dialogowe\\lab\\convlab-2\\convlab2\\nlu\\svm\\Classifier.py\u001b[0m in \u001b[0;36mpredict\u001b[1;34m(self, X)\u001b[0m\n\u001b[0;32m 496\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 497\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mpredict\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mX\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 498\u001b[1;33m \u001b[0my\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmodel\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mpredict_proba\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mX\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 499\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0my\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 500\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
|
|
"\u001b[1;32mc:\\Develop\\wmi\\AITECH\\sem1\\Systemy dialogowe\\lab\\venv\\lib\\site-packages\\sklearn\\svm\\base.py\u001b[0m in \u001b[0;36mpredict_proba\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 588\u001b[0m \u001b[0mdatasets\u001b[0m\u001b[1;33m.\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 589\u001b[0m \"\"\"\n\u001b[1;32m--> 590\u001b[1;33m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_check_proba\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 591\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_predict_proba\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 592\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
|
|
"\u001b[1;32mc:\\Develop\\wmi\\AITECH\\sem1\\Systemy dialogowe\\lab\\venv\\lib\\site-packages\\sklearn\\svm\\base.py\u001b[0m in \u001b[0;36m_check_proba\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 557\u001b[0m raise AttributeError(\"predict_proba is not available when \"\n\u001b[0;32m 558\u001b[0m \" probability=False\")\n\u001b[1;32m--> 559\u001b[1;33m \u001b[1;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_impl\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[1;32min\u001b[0m \u001b[1;33m(\u001b[0m\u001b[1;34m'c_svc'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'nu_svc'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 560\u001b[0m raise AttributeError(\"predict_proba only implemented for SVC\"\n\u001b[0;32m 561\u001b[0m \" and NuSVC\")\n",
|
|
"\u001b[1;31mAttributeError\u001b[0m: 'SVC' object has no attribute '_impl'"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"agent.response(\"I would prefer the hotel be in the north part of town .\")"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"agent.response(\"Yeah , could you book me a room for 2 people for 4 nights starting Tuesday ?\")"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Zauważmy, ze nasza prosta taktyka dialogowa zawiera wiele luk, do których należą m.in.:\n",
|
|
"\n",
|
|
" 1. Niezdolność do udzielenia odpowiedzi na przywitanie, prośbę o pomoc lub restart.\n",
|
|
"\n",
|
|
" 2. Brak reguł dopytujących użytkownika o szczegóły niezbędne do dokonania rezerwacji takie, jak długość pobytu czy liczba osób.\n",
|
|
"\n",
|
|
"Bardziej zaawansowane moduły zarządzania dialogiem zbudowane z wykorzystaniem reguł można znaleźć w\n",
|
|
"środowisku `ConvLab-2`. Należą do nich m.in. monitor [RuleDST](https://github.com/thu-coai/ConvLab-2/blob/master/convlab2/dst/rule/multiwoz/dst.py) oraz taktyka [RuleBasedMultiwozBot](https://github.com/thu-coai/ConvLab-2/blob/master/convlab2/policy/rule/multiwoz/rule_based_multiwoz_bot.py).\n",
|
|
"\n",
|
|
"Zadania\n",
|
|
"-------\n",
|
|
" 1. Zaimplementować w projekcie monitor stanu dialogu.\n",
|
|
"\n",
|
|
" 2. Zaimplementować w projekcie taktykę prowadzenia dialogu.\n",
|
|
"\n",
|
|
"Termin: 24.05.2021, godz. 23:59.\n",
|
|
"\n",
|
|
"Literatura\n",
|
|
"----------\n",
|
|
" 1. Pawel Budzianowski, Tsung-Hsien Wen, Bo-Hsiang Tseng, Iñigo Casanueva, Stefan Ultes, Osman Ramadan, Milica Gasic, MultiWOZ - A Large-Scale Multi-Domain Wizard-of-Oz Dataset for Task-Oriented Dialogue Modelling. EMNLP 2018, pp. 5016-5026\n",
|
|
" 2. Cathy Pearl, Basic principles for designing voice user interfaces, https://www.oreilly.com/content/basic-principles-for-designing-voice-user-interfaces/ data dostępu: 21 marca 2021\n",
|
|
" 3. Cathy Pearl, Designing Voice User Interfaces, Excerpts from Chapter 5: Advanced Voice User Interface Design, https://www.uxmatters.com/mt/archives/2018/01/designing-voice-user-interfaces.php data dostępu: 21 marca 2021"
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"author": "Marek Kubis",
|
|
"email": "mkubis@amu.edu.pl",
|
|
"interpreter": {
|
|
"hash": "91e2b0d1baa6ebb76863bdb1d11380bf032a6a1fc1b919194f041a5133852891"
|
|
},
|
|
"jupytext": {
|
|
"cell_metadata_filter": "-all",
|
|
"main_language": "python",
|
|
"notebook_metadata_filter": "-all"
|
|
},
|
|
"kernelspec": {
|
|
"display_name": "Python 3.7.9 ('venv': venv)",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"lang": "pl",
|
|
"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.7.9"
|
|
},
|
|
"subtitle": "9.Zarządzanie dialogiem z wykorzystaniem reguł[laboratoria]",
|
|
"title": "Systemy Dialogowe",
|
|
"year": "2021"
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 4
|
|
}
|