Parlai: What is the easiest way to get started with interacting with a Blender model entirely from a simple python script?

Created on 5 Jul 2020  路  2Comments  路  Source: facebookresearch/ParlAI

Hello,

My goal is to set up a blender model so my scripts can easily access it like so:

from something import Blender

model = Blender()

model.context = ["Hello", "how are you?", "Good thanks!"]

user_utt = "What are you doing?"

blender_utt = model.get_utt(user_utt)

print(blender_utt)

From my understanding, this probably isn't the easiest way to do it as we have the worlds and agents and how they all interact together.

So far, my approach was to:

  1. Create a custom config.yml and configure it
  2. Create a human agent
  3. Create a model
  4. import MessengerChatBotTaskWorld & subclass it
  5. Call generate_world
  6. Override parley function

However, I was running into a lot of issues.

  1. Firstly, how do I load the config file? From what I've seen its something like this, but I don't see a config.yml specified anywhere?
from parlai.core.params import ParlaiParser
parser = ParlaiParser(False, False)
parser.add_parlai_data_path()
parser.add_messenger_args()
opt = parser.parse_args()
  1. I am not sure how to "create a model". @klshuster specified here briefly: https://github.com/facebookresearch/ParlAI/issues/2633#issuecomment-632304351, but I am not sure what to do. Would I call the _load_model function?

The rest of the steps seem pretty straight forward.

I was wondering if this is the easiest way to get the sort of/similar functionality I described above? I am mostly interested in being able to automatically feed in utterances to a blender model through a script and capture its output.

Thanks!

Most helpful comment

I am mostly interested in being able to automatically feed in utterances to a blender model through a script and capture its output

If your responses are known in advance, perhaps you could create a ParlAI task/teacher, and then use the parlai/scripts/display_model script with --model zoo:blender/blender_90m/model and then -t your_task.

What is the best way to configure the persona of blender using the interactive.py script?

If you specify a task when running interactive.py, e.g. python parlai/scripts/interactive.py -t convai2, the interactive script will create an InteractiveWorld, if one is defined for that task. This InteractiveWorld handles the parleys between agents, and will load the agent with appropriate context prior to conversation. Using -t convai2 will load up a convai2 interactive world, which provides personas to the model. You can take a look at the linked file or also the InteractiveBaseWorld to see how personas (or context in general) is given to the model.

All 2 comments

Update: I have figured out that I can use the ParlAI/parlai/scripts/interactive.py, subclass LocalHumanAgent and override def act() and replace human_agent = LocalHumanAgent(opt) with human_agent = EvalAgent(opt). Then in the act() method I can control what response to feed the Blender model and when to stop the episode/chat.

I run this method: Interactive.main(model_file='zoo:blender/blender_90M/model')

I have a few new questions:

1. How can I feed the Blender model a specific dialogue history? E.g, say I have 3 turns, (A: Hey, B: how are you?, A: great, how about you?), and then prompt blender to respond to "great, how about you?" but with the context of the first two turns: "A: Hey, B: how are you?". I was thinking I could manually feed in the previous dialog, but I don't want blender to respond to each utterance, I only want blender to respond to the last utterance given the entire context of the conversation. Is this possible? Would I just concatenate the initial responses?. I realized I can use the agent.self_observe(utterance) function.

2. What is the best way to configure the persona of blender using the interactive.py script? I cannot seem to figure this out, it seems different than other referenced posts. I cannot see in the self.opt anywhere that even includes the 'include_persona` option? What am I missing?

Thanks!

I am mostly interested in being able to automatically feed in utterances to a blender model through a script and capture its output

If your responses are known in advance, perhaps you could create a ParlAI task/teacher, and then use the parlai/scripts/display_model script with --model zoo:blender/blender_90m/model and then -t your_task.

What is the best way to configure the persona of blender using the interactive.py script?

If you specify a task when running interactive.py, e.g. python parlai/scripts/interactive.py -t convai2, the interactive script will create an InteractiveWorld, if one is defined for that task. This InteractiveWorld handles the parleys between agents, and will load the agent with appropriate context prior to conversation. Using -t convai2 will load up a convai2 interactive world, which provides personas to the model. You can take a look at the linked file or also the InteractiveBaseWorld to see how personas (or context in general) is given to the model.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

reppolice picture reppolice  路  4Comments

Ufukdogann picture Ufukdogann  路  6Comments

michaelshum picture michaelshum  路  6Comments

Ufukdogann picture Ufukdogann  路  5Comments

mvh57 picture mvh57  路  3Comments