Skip to content

eval_twomode中取embedding 位置的方法为什么要+1 #8

@SkyFishMoon

Description

@SkyFishMoon

您好,想请问一下关于evaluation中代码的问题,我看到在SFT和RL训练的时候,都是直接取special token对应index的hidden state,为什么在evaluation的时候这里有个+1

def get_embedding_idx(generated_ids_trimmed, EMBEDDING_TOKEN_ID):

embedding_idx = []
# Search from the last token forward
for i, out_ids in enumerate(generated_ids_trimmed):
    embed_exist = False
    for j in range(len(out_ids) - 1, -1, -1):
        if out_ids[j] == EMBEDDING_TOKEN_ID:
            if j + 1 >= len(out_ids) - 1:
                embedding_idx.append(-1)
            else:
                embedding_idx.append(j + 1)
            embed_exist = True
            break
    if not embed_exist:
        embedding_idx.append(-1)
    
    # embedding_idx.append(-1)

return embedding_idx

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions