Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] ValueError: too many values to unpack (expected 4) #193

Open
nomawni opened this issue Mar 11, 2024 · 1 comment
Open

[BUG] ValueError: too many values to unpack (expected 4) #193

nomawni opened this issue Mar 11, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@nomawni
Copy link

nomawni commented Mar 11, 2024

Hi, I am facing the following error, while trying to simulate and generate dialogues between the user and the system:

To replicate the error, here is the code that I am using:

user_nlu = BERTNLU()
user_dst = RuleDST()
user_policy = RulePolicy(character='usr')
user_nlg = TemplateNLG(is_user=True)
user_agent = PipelineAgent(user_nlu, user_dst, user_policy, user_nlg, name='user')

sys_nlu = BERTNLU()
sys_nlg = TemplateNLG(is_user=False)
sys_dst = RuleDST()
policy_sys = PPO(is_train=True, seed=conf['model']['seed'],
vectorizer=conf['vectorizer_sys_activated'])
sys_policy = PPO(is_train=True, seed=0, dataset_name='multiwoz21')
sys_agent = PipelineAgent(sys_nlu, sys_dst, policy_sys, sys_nlg, name="sys")

evaluator = MultiWozEvaluator()
session = BiSession(sys_agent, user_agent, kb_query=None, evaluator=evaluator)
simulator = PipelineAgent(user_nlu, user_dst, user_policy, user_nlg, name='user')
env = Environment(sys_nlg, simulator, sys_nlu, sys_dst, evaluator=evaluator)

def set_seed(r_seed):
random.seed(r_seed)
np.random.seed(r_seed)
torch.manual_seed(r_seed)

set_seed(20200131)

num_dialogues = 30
dialog_data = []

sys_response = ''
success_threshold = 0
success_labels = []

for i in range(num_dialogues):
session.init_session()
dialog = []
session_over = False
cumulative_reward = 0
print(f"Turn round {i}")
print()
while not session_over:
response = session.next_turn(sys_response)
system_response, user_response, session_over, reward = response
dialog.append((system_response, user_response))
cumulative_reward += reward
print(f"User: {user_response}")
print(f"System: {system_response}")
print(f" Reward: {reward}")
print()
success_label = determine_success(cumulative_reward, success_threshold)
dialog_data.append((dialog, success_label))

success = session.evaluator.task_success()
success_labels.append(success)

Here is the full error that I am getting after running executing the code:

ValueError Traceback (most recent call last)
Cell In[24], line 13
11 print()
12 while not session_over:
---> 13 response = session.next_turn(sys_response)
14 system_response, user_response, session_over, reward = response
15 dialog.append((system_response, user_response))

File c:\users\convlab-3\convlab\dialog_agent\session.py:122, in BiSession.next_turn(self, last_observation)
100 def next_turn(self, last_observation):
101 """Conduct a new turn of dialog, which consists of the system response and user response.
102
103 The variable type of responses can be either 1) str or 2) dialog act, depends on the dialog mode settings of the
(...)
120 The reward given by the user.
121 """
--> 122 user_response = self.next_response(last_observation)
123 if self.evaluator:
124 self.evaluator.add_sys_da(self.user_agent.get_in_da_eval(), self.sys_agent.dst.state['belief_state'])

File c:\users\convlab-3\convlab\dialog_agent\session.py:96, in BiSession.next_response(self, observation)
94 def next_response(self, observation):
95 next_agent = self.next_agent()
---> 96 response = next_agent.response(observation)
...
29 new_acts['categorical'].append(
30 {"intent": intent, "domain": domain, "slot": slot, "value": value})
31 return new_acts

ValueError: too many values to unpack (expected 4)

@nomawni nomawni added the bug Something isn't working label Mar 11, 2024
@nomawni
Copy link
Author

nomawni commented Apr 9, 2024

Hi everyone. I really need help to solve this error. I have spent a lot of time on this error, and I can not solve the project without solving the error, so if anyone knows how solve it, kindly provide the answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant