Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

train_llava数据集构建的问题 #193

Open
weiaicunzai opened this issue Oct 30, 2024 · 1 comment
Open

train_llava数据集构建的问题 #193

weiaicunzai opened this issue Oct 30, 2024 · 1 comment

Comments

@weiaicunzai
Copy link

weiaicunzai commented Oct 30, 2024

请教一下,关于train_llava的代码。为什么[final_inputs_ids] (https://github.com/yuanzhoulvpi2017/zero_nlp/blob/main/train_llava/train_llava/data.py#L128) 使用pad_token_id进行填充,而final_label_ids 使用 ignore_idx进行填充? 为啥不是都用pad_token_id填充呢?

还有为啥ignore_idx 等于-100,模型是怎么知道-100是ignore_idx的呢?每个llm都知道-100是要忽略的值吗?比如llama,qwen之类的。

感谢!

@weiaicunzai
Copy link
Author

ignore_idx到时候应该算loss之类的需要被遮住。特别是stf的时候。

llava原版代码会把ignore_idx传入数据构建的时候。例如

def _mask_targets(target, tokenized_lens, speakers):
    # cur_idx = 0
    cur_idx = tokenized_lens[0]
    tokenized_lens = tokenized_lens[1:]
    target[:cur_idx] = IGNORE_INDEX
    for tokenized_len, speaker in zip(tokenized_lens, speakers):
        if speaker == "human":
            target[cur_idx+2:cur_idx + tokenized_len] = IGNORE_INDEX
        cur_idx += tokenized_len

但是llm是怎么知道-100要被mask掉这个我还不太清楚。
不知道大佬是否有啥高见。
@yuanzhoulvpi2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant