ParlAI icon indicating copy to clipboard operation
ParlAI copied to clipboard

Adding more contextual parameter in the custom jsonfile dataset.

Open muzamil47 opened this issue 3 years ago • 6 comments

Hi,

I am curious if we can add more context parameters in the given json dataset and use in the task: --task jsonfile --jsonfile-datapath json_file_path

For example: Given the following json dataset sample, how can we add further context like context1 and context2 to train the model.

{
	"dialog": [
		{
			"id": "partner1",
			"text": "tell me a joke.",
			"label": "One time, I put strawberry jam on my burger. I thought it was ketchup!",
                        "context1": "context1_val",
                        "context2": "context2_val",
			"personas": [
				"your persona:  I am John",
				"your persona: I live in Ohio."
			],
			"episode_done": true
		},
		{
			"id": "partner1",
			"text": "tell me a joke.",
			"label": "Let me tell you my favorite joke. Why was six afraid of seven? Because seven ate nine!",
                        "context1": "context1_val",
                        "context2": "context2_val",
			"personas": [
				"your persona:  I am Ellie",
				"your persona: I live in New York."
			],
			"episode_done": true
		}
	]
}

As for as jsonfile agent is concerned, it seems like it does not parse the other context values like context1 and context2 for training the model.

Thanks!

muzamil47 avatar Oct 19 '22 07:10 muzamil47

Some of the agents may not do that on their own, but you may have agents that are using the extra context in the message. For example see this observe method for BlenderBot 2 that uses extra context from the message.

mojtaba-komeili avatar Oct 20 '22 03:10 mojtaba-komeili

In addition, I'd recommend creating a custom task file that subclasses the jsonfile agent, and overrides the _get_ep_from_turns function to parse your context accordingly

klshuster avatar Nov 04 '22 14:11 klshuster

Hi @klshuster and @mojtaba-komeili

Thanks for the response.

As suggested by @klshuster , I can add more context apart from text and labels for creating the task?

turn['text'] = xturn.get('text').strip()
turn['labels'] = [yturn.get('text').strip()]

Another question is... And once the task is created with other context, will the blenderbot2 model learn those contexts during training...? Thanks

muzamil47 avatar Nov 07 '22 11:11 muzamil47

As suggested by @klshuster , I can add more context apart from text and labels for creating the task?

you can access those context values (and place them in your observation) in something akin to the following:

turn['text'] = xturn.get('context1').strip() + '\n' + xturn.get('text').strip() 
...

And once the task is created with other context, will the blenderbot2 model learn those contexts during training...?

If you include them in the text and labels fields, ideally yes

klshuster avatar Nov 07 '22 21:11 klshuster

If you include them in the text and labels fields, ideally yes

So we have to include context1 field in the labels as well?

muzamil47 avatar Nov 08 '22 02:11 muzamil47

the text field is the input context, while the labels field is the output target. If you want BB2 to generate the context1 field, put it in labels; if you want it to simply understand it's necessity, put it in text

klshuster avatar Nov 08 '22 15:11 klshuster

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.

github-actions[bot] avatar Dec 09 '22 00:12 github-actions[bot]