Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

How to make BlenderBot generate from an unfinished sentence? #4769

Answered by klshuster
tungnt55 asked this question in Q&A
Discussion options

You must be logged in to vote

One way to do this via command line would be to have BB's "prompt" message in a temp_history key in the observed message:

from parlai.core.agents import create_agent_from_model_file

blenderbot = create_agent_from_model_file()
blenderbot.observe({'text': 'Can you tell me about your job?', 'temp_history': "\nSure, I'm happy to talk about it. I am working as", "episode_done": False})
response = blenderbot.act()['text']

The issue here is that we'll still have an EOS token at the end of the full contextual sentence. A more complex way to go about this, then, is to implement an agent that implements get_prefix_tokens; see e.g. this test agent, which forces the model's generation to begin with …

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@tungnt55
Comment options

@klshuster
Comment options

@tungnt55
Comment options

@klshuster
Comment options

@tungnt55
Comment options

Answer selected by tungnt55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants