
# tokenizer文件修改
在训练开始前根据所选训练框架针对模型的tokenizer文件进行修改。
当前仅涉及Llama-Factory框架下glm4-9b模型和InternVL2_5系列模型的tokenizer文件修改，具体修改内容如下，您可对tokenizer文件进行编辑。
#### Llama-Factory
- **glm4-9b模型**
  在训练开始前，需要修改glm4-9b模型中的tokenizer文件modeling_chatglm.py内容，具体步骤如下：
  进入到tokenizer（权重）目录下，修改modeling_chatglm.py文件内容。
  ```
  vim modeling_chatglm.py
  # 注释掉以下两行内容
  # if attention_mask is not None
        # attention_mask = ~attention_mask
  ```
  样例图：
  ![](https://support.huaweicloud.com/bestpractice-modelarts/figure/zh-cn_image_0000002397247054.png "点击放大")
  
- **InternVL2_5系列模型**
  InternVL2_5系列模型均未在Transformers仓注册，需提前手动打patch，详细步骤如下：
  - InternVL2_5-8B:
    ```
    # git clone 方式下载模型文件，如果已下载忽略此git clone步骤
    git clone https://huggingface.co/OpenGVLab/InternVL2_5-8B
    # 进入权重目录下打patch文件，${work_dir}为工作目录根据实际修改
    cd InternVL2_5-8B && git apply ${work_dir}/llm_train/AscendFactory/third-party/internvl25-8b.patch
    ```
    
  
  - InternVL2_5-38B:
    ```
    # git clone 方式下载模型文件，如果已下载忽略此git clone步骤
    git clone https://huggingface.co/OpenGVLab/InternVL2_5-38B
    # 进入权重目录下打patch文件，${work_dir}为工作目录根据实际修改
    cd InternVL2_5-38B && git apply ${work_dir}/llm_train/AscendFactory/third-party/internvl25-38b.patch
    ```
    
  
  - InternVL2_5-78B:
    ```
    # git clone 方式下载模型文件，如果已下载忽略此git clone步骤
    git clone https://huggingface.co/OpenGVLab/InternVL2_5-78B
    # 进入权重目录下打patch文件，${work_dir}为工作目录根据实际修改
    cd InternVL2_5-78B && git apply ${work_dir}/llm_train/AscendFactory/third-party/internvl25-8b.patch
    ```
    
   
 
