[Wizard of Wikipedia] Questions about how to used the trained agent
Hi, I got some questions about how to use the agent. I trained a blenderbot_400Mdistill on the task='wizard_of_wikipedia' and saved the model. I am wondering how to pass the chosen topic to the bot. I see on some issues you give a small example of how to give personas to the bot. However, I am confused about how to pass the topic. My code is below. However, it seemed not correct. Thank you!
opt = {
"model_file": "tmp/test_train_400M",
"model": "transformer/generator",
"dict_file": "tmp/test_train_400M.dict",
"embedding_size": 1280,
}
blender_agent = create_agent(opt)
blender_agent.skip_generation = False
blender_agent.dict.load(opt["dict_file"])
blender_agent.dict.lower = True
# forget everything. Important if you run this multiple times.
# blender_agent.reset()
# concatenate the persona and the first thing the human says
first_turn = "\n".join(
[
"your persona: I hate cheese",
"your persona: I love potatoes",
"Hi, can you tell me about yourself?",
]
)
# Model actually witnesses the human's text
obs = blender_agent.observe(
{
"text": first_turn,
"episode_done": False,
"chosen topic": "Movies",
}
)
print(f"You said: {first_turn}")
# model produces a response
response = blender_agent.act()
print("BlenderBot replied: {}".format(response["text"]))
print()
# now another turn
second_turn = "We like eating cheese, it is very nice."
print(f"You said: {second_turn}")
blender_agent.observe(
{
"text": second_turn,
"episode_done": False,
"chosen topic": "Movies",
}
)
response2 = blender_agent.act()
print("BlenderBot replied: {}".format(response2["text"]))
print()
print("-" * 40)
print()
print("BlenderBot's history view:")
print(blender_agent.history.get_history_str())
We typically pass the topic in as the very first message in the dialogue history; so, your first turn would instead be:
first_turn = "\n".join(
[
"Movies",
"your persona: I hate cheese",
"your persona: I love potatoes",
"Hi, can you tell me about yourself?",
]
)
Hi, Thanks for your reply. That is quite clear to me. I got another question about the persona. I see there are two personas here. However, I am quite curious that which persona is for the bot. Should be the second line "your persona: I hate cheese", or the third line "your persona: I love potatoes"? Thanks
Each "your persona: " line is a persona you would want the bot to emulate. If you wanted to specify the partner's persona, you would have "partner's persona: "
This issue has not had activity in 30 days. Please feel free to reopen if you have more issues. You may apply the "never-stale" tag to prevent this from happening.