Multi turn conversation Alpaca format for instruction fine tuning #579
-
Great book so far, @rasbt ! I'm currently on my second pass at it and exploring further. The appendix links the ShareGPT dataset. One thing not clear to me is how I would go about translating each of those entries to the Alpaca format. I noticed that the format really only assumes 1 question and 1 answer. However, in entries of this dataset, I see there is a back and forth interaction between the human and assistant. Is there anything different to be done when building out the training/val/test data when it comes to formatting input? Do we just build separate Alpaca formatted messages? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
Good question. It was a bit too much for the already (too) long Chapter 7, but multi-turn would be an interesting case for a bonus material section one day... This is true for the training (SFT) stage as well: E.g. if the turn 1 json input is: {
"instruction": "I'm planning a trip to Italy. Can you suggest three cities I should visit?",
"input": "",
"output": "Absolutely! Here are three cities in Italy worth visiting: Rome, Florence, Venice."
} and turn 2 is {
"instruction": "Nice. What’s the best time of year to visit those places?",
"input": "",
"output": "The best times to visit Rome, Florence, and Venice are typically in the spring (April to June) and fall (September to October)."
} For turn 1 the example would be similar to what's in the chapter:
but for turn 2, you'd format it as follows:
I hope this helps! |
Beta Was this translation helpful? Give feedback.
-
Hi @rasbt, Conversations are trained in batches, so what if their lengths are different? Are they padded, or is another conversation concatenated to avoid the wasteful computation of the padding tokens? I think in the Llama3 paper, I read that they concatenate instead of padding (ig for pretraining; Do they do that for SFT?). Also, is padding done on the left or the right? How's it done in Production? Thanks. |
Beta Was this translation helpful? Give feedback.
Good question. It was a bit too much for the already (too) long Chapter 7, but multi-turn would be an interesting case for a bonus material section one day...
How ChatGPT and other LLMs etc handle multi-turn questions is that they simply shove the previous conversation into the prompt.
This is true for the training (SFT) stage as well:
E.g. if the turn 1 json input is:
and turn 2 is