Hello,
I am trying to do a supervised Fine Tune using amy own dataset, I am stuck on this error:
RuntimeError: Youâre using assistant_only_loss=True, but at least one example has no assistant tokens. This usually means the tokenizerâs chat template doesnât generate assistant masks â it may be missing the {% generation %} keyword. Please check the template and ensure itâs correctly configured to support assistant masking.
Here is my tokenized conversation sample:
{âmessagesâ: [{âroleâ: âuserâ, âcontentâ: âHi everyone! Please help with this API. Context: adding new URLs to an existing custom category. Could anybody explain the difference between "url"and "dbcategorizedurls"in this context, please?â}, {âroleâ: âassistantâ, âcontentâ: âItâs the difference between URLâs retaining categories and those over-riding the category.â}], âformatted_chatâ: {âassistant_masksâ: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], âinput_idsâ: [128000, 128006, 882, 128007, 271, 13347, 5127, 0, 1988, 9002, 1901, 5987, 5446, 13, 9805, 25, 7999, 502, 36106, 311, 459, 6484, 2587, 5699, 13, 16910, 21739, 10552, 279, 6811, 1990, 330, 1103, 1, 438, 330, 15245, 58711, 21141, 55501, 420, 2317, 11, 4587, 30, 578, 2930, 2027, 9904, 320, 16564, 279, 5446, 5905, 8, 3250, 956, 3493, 904, 16540, 922, 420, 13, 11361, 304, 12178, 0, 128009, 128006, 78191, 128007, 271, 2181, 596, 279, 6811, 1990, 5665, 596, 51110, 11306, 323, 1884, 927, 12, 50780, 279, 5699, 13, 11361, 13678, 1131, 779, 36106, 3984, 304, 279, 330, 1103, 1, 798, 19625, 6857, 690, 14389, 904, 1023, 5699, 814, 617, 320, 258, 5369, 311, 279, 2587, 5699, 8, 24797, 369, 36106, 3984, 304, 279, 330, 15245, 58711, 21141, 1, 906, 2351, 927, 12, 50780, 904, 1023, 22824, 2065, 3984, 555, 1901, 5987, 323, 690, 617, 279, 2587, 5699, 439, 872, 353, 3323, 9, 5699, 7366, 4741, 1131, 2209, 420, 4495, 30, 350, 5987, 0, 7566, 11, 499, 2351, 30230, 902, 315, 1521, 43212, 701, 7999, 2288, 25, 11361, 0, 5112, 1701, 279, 330, 1103, 1, 798, 19625, 6857, 304, 279, 5446, 374, 13890, 311, 7999, 279, 5665, 311, 279, 2587, 5699, 1701, 279, 330, 10480, 36106, 1, 2054, 304, 279, 16840, 11, 1314, 30, 5659, 279, 1520, 3189, 83, 279, 330, 9342, 36106, 1, 2054, 25, 721, 6403, 279, 5665, 1161, 8, 499, 1390, 311, 923, 311, 420, 4194, 9342, 5699, 4194, 438, 4299, 4194, 9, 2261, 19974, 20517, 8572, 36106, 527, 1193, 9960, 555, 10396, 430, 5905, 420, 3230, 2587, 5699, 13, 1789, 3187, 11, 422, 499, 3810, 366, 1277, 1129, 2185, 18771, 916, 91, 2185, 18771, 916, 29, 1618, 11, 433, 690, 912, 5129, 387, 9960, 555, 10396, 430, 5905, 8267, 30064, 11, 1202, 2748, 5665, 5699, 1462, 358, 4510, 779, 11, 499, 2643, 1205, 311, 1296, 433, 11, 743, 709, 1772, 1543, 11, 2713, 264, 5743, 36106, 1518, 1405, 814, 4363, 13, 10619, 11, 1690, 9523, 0, 128009]}}
What am I missing?
Stack trace from python:
File "/home/ubuntu/train_llama3.py", line 417, in doing
trainer = SFTTrainer(
^^^^^^^^^^^
File "/home/ubuntu/.local/lib/python3.12/site-packages/trl/trainer/sft_trainer.py", line 855, in __init__
train_dataset = self._prepare_dataset(
^^^^^^^^^^^^^^^^^^^^^^
File "/home/ubuntu/.local/lib/python3.12/site-packages/trl/trainer/sft_trainer.py", line 1090, in _prepare_dataset
dataset = dataset.map(
^^^^^^^^^^^^
File "/home/ubuntu/.local/lib/python3.12/site-packages/datasets/arrow_dataset.py", line 562, in wrapper
out: Union["Dataset", "DatasetDict"] = func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ubuntu/.local/lib/python3.12/site-packages/datasets/arrow_dataset.py", line 3343, in map
for rank, done, content in Dataset._map_single(**unprocessed_kwargs):
File "/home/ubuntu/.local/lib/python3.12/site-packages/datasets/arrow_dataset.py", line 3675, in _map_single
for i, example in iter_outputs(shard_iterable):
File "/home/ubuntu/.local/lib/python3.12/site-packages/datasets/arrow_dataset.py", line 3649, in iter_outputs
yield i, apply_function(example, i, offset=offset)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ubuntu/.local/lib/python3.12/site-packages/datasets/arrow_dataset.py", line 3572, in apply_function
processed_inputs = function(*fn_args, *additional_args, **fn_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ubuntu/.local/lib/python3.12/site-packages/trl/trainer/sft_trainer.py", line 1082, in tokenize_fn
raise RuntimeError(
RuntimeError: You're using `assistant_only_loss=True`, but at least one example has no assistant tokens. This usually means the tokenizer's chat template doesn't generate assistant masks â it may be missing the `{% generation %}` keyword. Please check the template and ensure it's correctly configured to support assistant masking.