匿名用户2024年07月31日
55阅读

技术信息

开源地址
https://modelscope.cn/models/Lanzer/Night-Ode

作品详情

环境安装

'''

    # 设置pip全局镜像
    pip cofig set global.idex-url https://mirrors.aliyu.com/pypi/simple/
    # 安装ms-swift
    git cloe https://github.com/modelscope/swift.git
    cd swift
    pip istall -e .[llm]

    #环境对齐 (如果你运行错误, 可以跑下面的代码, 仓库使用最新环境测试)
    pip istall -r requiremets/framework.txt  -U
    pip istall -r requiremets/llm.txt  -U

'''

超参数设置

模型采用qwe7bchat

微调超参数:

traidatasetsample=500,

eval_steps=20,

loggig_steps=5,

output_dir='output',

loratargetmodules='ALL',

selfcogitiosample=500

微调

提示: 因为自我认知训练涉及到知识编辑, 建议对MLP加loratargetmodules. 可以通过指定--loratargetmodules ALL在所有的liear层(包括qkvo以及mlp)加lora. 这通常是效果最好的.

使用pytho:

    # Experimetal eviromet: A10, 3090, V100, ...
    # 18GB GPU memory
    import os
    os.eviro['CUDA_VISIBLE_DEVICES'] = '0'

    from swift.llm import DatasetName, ModelType, SftArgumets, sft_mai

    sft_args = SftArgumets(
        model_type=ModelType.qwe_7b_chat,
        dataset=[DatasetName.alpaca_zh, DatasetName.alpaca_e],
        trai_dataset_sample=500,
        eval_steps=20,
        loggig_steps=5,
        output_dir='output',
        lora_target_modules='ALL',
        self_cogitio_sample=500,
        model_ame=['夜咏', 'Night Ode'],
        model_author=['李岚泽', 'Lazer'])
    output = sft_mai(sft_args)
    best_model_checkpoit = output['best_model_checkpoit']
    prit(f'best_model_checkpoit: {best_model_checkpoit}')

微调实验记录

Alt text Alt text Alt text

微调后推理

需要设置bestmodelcheckpoit的值, 该值会在sft的最后被打印出来.

使用pytho:

    import os
    os.eviro['CUDA_VISIBLE_DEVICES'] = '0'

    from swift.llm import IferArgumets, merge_lora_mai, ifer_mai

    best_model_checkpoit = 'output/qwe-7b-chat/v0-20240122-205735/checkpoit-62'
    ifer_args = IferArgumets(
        ckpt_dir=best_model_checkpoit,
        eval_huma=True)
    # merge_lora_mai(ifer_args)
    result = ifer_mai(ifer_args)

实验记录

Alt text

功能介绍

环境安装 ''' # 设置pip全局镜像 pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论