Hello,
I've checked issues #2644, #2636, #2745, but am continuing to have difficulty in customizing the model persona. I'm editing _load_personas(opt) in worlds.py, but am unsure where in this block to add the custom model persona. I want to set something like ["I work as a therapist","I like to help people"] as a persona for the model. I'm just learning this, so I appreciate your help.
def _load_personas(opt):
print('[ loading personas.. ]')
if opt.get('include_personas', True):
print(
"\n [NOTE: In the BST paper both partners have a persona.\n"
+ ' You can choose to ignore yours, the model never sees it.\n'
+ ' In the Blender paper, this was not used for humans.\n'
+ ' You can also turn personas off with --include-personas False]\n'
)
fname = raw_data_path(opt)
with open(fname) as json_file:
data = json.load(json_file)
contexts = []
for d in data:
context1 = []
context2 = []
if opt.get('include_personas', True):
context1.append('your persona: ' + d['personas'][0][0])
context1.append('your persona: ' + d['personas'][0][1])
context2.append('your persona: ' + d['personas'][1][0])
context2.append('your persona: ' + d['personas'][1][1])
if d['context_dataset'] == 'wizard_of_wikipedia':
context1.append(d['additional_context'])
context2.append(d['additional_context'])
if opt.get('include_initial_utterances', True):
context1.append(d['free_turker_utterance'])
context2.append(d['free_turker_utterance'])
context1.append(d['guided_turker_utterance'])
context2.append(d['guided_turker_utterance'])
c1 = '\n'.join(context1)
c2 = '\n'.join(context2)
contexts.append([c1, c2])
return contexts
The _load_personas function simply returns a list of tuples context strings [(c1, c2), (c3, c4), ...]. The first context string in a tuple is what will be sent to the model as its own persona; the second string in the tuple is the persona of the model's partner, which, in interactive mode, is you. If you'd like to customize which personas to send to the model, simply modify that function to return a list of tuples of persona strings such that the first string is the model's persona.
These context strings become the InteractiveWorld's contexts_data; you can then see in the get_contexts function that we return two personas - one for the model, and one for the human. Note that this get_contexts function is called each time you restart the conversation; in interactive mode, this is achieved by typing [DONE] in your utterance.
Hope that helps.
@klshuster How this can be done in chat services ?
Suppose you're using the chatbot demo task for chat services; presumably you'd want to load these persona strings in the world init function. Then, you would simply construct a context_act and have the agent observe this context_act prior to the first conversation, and whenever a user sends [DONE].
You can see how context_acts are handled here in interactive worlds; and here is where you might have the agent observe this context act.
Hope that helps
@klshuster thank you!! it worked .
I'm going to close this issue as I think I've covered everything asked, please reopen (or file a new issue) if there are additional questions/concerns