ymcui / Chinese-LLaMA-Alpaca-2

中文LLaMA-2 & Alpaca-2大模型二期项目 + 64K超长上下文模型 (Chinese LLaMA-2 & Alpaca-2 LLMs with 64K long context models)
Apache License 2.0
7.04k stars 581 forks source link

resize_token_embeddings 相关的疑惑 #400

Closed AriKing11 closed 9 months ago

AriKing11 commented 10 months ago

提交前必须检查以下项目

问题类型

模型训练与精调

基础模型

Chinese-LLaMA-2 (7B/13B)

操作系统

Linux

详细描述问题

    if model_vocab_size != len(tokenizer):
        logger.info(f"Resize model vocab size to {len(tokenizer)}")
        model.resize_token_embeddings(len(tokenizer))

我有一点小困惑, 就是如果使用了resize_token_embeddings 在model中的embedding层多加了一行向量, 但是这个向量并没有经过训练, 那么如何确保模型不会受这个添加词表影响 使得整体效果变差.

依赖情况(代码类问题务必提供)

# 请在此处粘贴依赖情况(请粘贴在本代码块里)

运行日志或截图

# 请在此处粘贴运行日志(请粘贴在本代码块里)
ymcui commented 9 months ago

是你自己要在词表里多加一个token吗?这么做的目的是什么? 加了token就肯定是要做进一步训练的,原因你自己也讲了(新加的token对应的词向量是随机初始化的)。

非必要不加新token

github-actions[bot] commented 9 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your consideration.

github-actions[bot] commented 9 months ago

Closing the issue, since no updates observed. Feel free to re-open if you need any further assistance.