<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    paulwong

    微調(diào)llama3大模型(1) - 使用Llama Factory微調(diào)llama3大模型

    對(duì)于象META的開源大模型,如llama3,由于都是用通用數(shù)據(jù)進(jìn)行預(yù)訓(xùn)練,對(duì)想使用其模型的公司來說,可能會(huì)不適用,因?yàn)檫@大模型對(duì)公司的數(shù)據(jù)不熟悉,因此引入微調(diào)(Fine-Tunning)。
    通過喂給大模型大量數(shù)據(jù),1萬(wàn)條起步,使得大模型也能對(duì)公司的數(shù)據(jù)熟悉,進(jìn)而用于各種對(duì)話場(chǎng)景。

    1.克隆并安裝LLAMA FACTORY庫(kù),install-llamafactory.sh

    BIN_PATH=$(cd `dirname $0`; pwd)
    cd $BIN_PATH/../
    pwd
    git clone --depth 
    1 https://github.com/hiyouga/LLaMA-Factory.git
    cd LLaMA-Factory
    pip install -e 
    ".[torch,metrics,bitsandbytes,modelscope]"

    2.設(shè)置環(huán)境變量

    export USE_MODELSCOPE_HUB=1 #使用modelscop模型庫(kù),非huggingface的
    export CUDA_VISIBLE_DEVICES
    =0 #設(shè)置使用GPU
    export HF_ENDPOINT
    =https://hf-mirror.com #設(shè)置huggingface的替代地址
    export MODELSCOPE_CACHE
    =/root/autodl-tmp/models/modelscope #設(shè)置modelscope中的大模型保存路徑
    export LLAMAFACTORY_HOME=/root/autodl-tmp/LLaMA-Factory

    3.準(zhǔn)備數(shù)據(jù)

    #在data/dataset_info.json中加入此數(shù)據(jù)

    "docker_command_NL": {
        
    "hf_hub_url""MattCoddity/dockerNLcommands"
      }
    ,
    在data目錄中加入訓(xùn)練數(shù)據(jù),MattCoddity/dockerNLcommands.json
    數(shù)據(jù)格式為:
    [
      {
        
    "input""Give me a list of containers that have the Ubuntu image as their ancestor.",
        
    "instruction""translate this sentence in docker command",
        
    "output""docker ps --filter 'ancestor=ubuntu'"
      }
    ,

    ]

    4.訓(xùn)練大模型

    訓(xùn)練的參數(shù)文件:llama3_lora_sft_docker_command.yaml
    ### model
    #md model id
    model_name_or_path: LLM-Research/Meta-Llama-
    3-8B-Instruct
    #huggingface model id
    #model_name_or_path: meta-llama/Meta-Llama-
    3-8B-Instruct

    ### method
    stage: sft
    do_train: true
    finetuning_type: lora
    lora_target: all

    ### dataset
    dataset: docker_command_NL
    template: llama3
    cutoff_len: 
    1024
    max_samples: 
    1000
    overwrite_cache: true
    preprocessing_num_workers: 
    16

    ### output
    output_dir: /root/autodl-tmp/my-test/saves/llama3-8b/lora/sft/docker-commnad-nlp/sft
    logging_steps: 
    10
    save_steps: 
    500
    plot_loss: true
    overwrite_output_dir: true

    ### train
    per_device_train_batch_size: 
    4
    gradient_accumulation_steps: 
    8
    learning_rate: 
    1.0e-4
    num_train_epochs: 
    3.0
    lr_scheduler_type: cosine
    warmup_ratio: 
    0.1
    bf16: true
    ddp_timeout: 
    180000000

    ### eval
    val_size: 
    0.1
    per_device_eval_batch_size: 
    1
    eval_strategy: steps
    eval_steps: 
    500
    訓(xùn)練命令:lora-train-docker-command.sh
    BIN_PATH=$(cd `dirname $0`; pwd)
    cd $BIN_PATH/
    pwd
    cd $LLAMAFACTORY_HOME
    pwd
    llamafactory-cli train $BIN_PATH/conf/llama3_lora_sft_docker_command.yaml
    執(zhí)行此命令即可開始訓(xùn)練大模型。

    5.合并大模型

    合并用的參數(shù)文件,llama3_lora_export_docker_command.yaml
    ### model
    #md model id
    model_name_or_path: LLM-Research/Meta-Llama-
    3-8B-Instruct
    #huggingface model id
    #model_name_or_path: meta-llama/Meta-Llama-
    3-8B-Instruct

    adapter_name_or_path: /root/autodl-tmp/my-test/saves/llama3-8b/lora/docker-commnad-nlp/sft
    template: llama3
    export_dir: /root/autodl-tmp/my-test/saves/llama3-8b/lora/docker-commnad-nlp/export
    finetuning_type: lora
    export_size: 
    2
    export_device: gpu
    export_legacy_format: False
    合并命令,lora-export-docker-command.sh
    BIN_PATH=$(cd `dirname $0`; pwd)
    cd $BIN_PATH/
    pwd
    llamafactory-cli export conf/llama3_lora_export_docker_command.yaml

    posted on 2024-07-08 18:44 paulwong 閱讀(128) 評(píng)論(0)  編輯  收藏 所屬分類: AI-LLMAI-FINE-TUNNING

    主站蜘蛛池模板: 精品亚洲成A人无码成A在线观看| 亚洲成无码人在线观看| 久久99国产亚洲精品观看| 亚洲成人一级电影| 亚洲精品乱码久久久久久蜜桃图片| 美女视频免费看一区二区| 免费无码又爽又刺激网站直播 | 亚洲婷婷第一狠人综合精品| 国产亚洲欧美在线观看| 精品一区二区三区高清免费观看 | 成年大片免费视频播放一级| 中文无码成人免费视频在线观看 | 国产成人免费网站| 日韩精品电影一区亚洲| 亚洲成a人片77777老司机| 亚洲日本人成中文字幕| 一二三区免费视频| 免费人成在线观看69式小视频| 日韩在线视频免费看| 国产亚洲成av人片在线观看 | 久久亚洲AV成人无码国产| 亚洲国产精品自在自线观看| 四虎国产精品免费永久在线| 成人男女网18免费视频| 国产亚洲真人做受在线观看| 亚洲精品午夜国产va久久| www成人免费观看网站| 中文字幕乱码免费视频| 亚洲性久久久影院| 亚洲偷偷自拍高清| 国产性生大片免费观看性| 搡女人免费视频大全| 亚洲精品二区国产综合野狼| 亚洲人成色77777在线观看| 伊人久久大香线蕉免费视频| 免费无码又爽又刺激毛片| 久久亚洲私人国产精品| 一级毛片在线免费播放| 欧美男同gv免费网站观看| 亚洲国产精品无码久久一区二区 | 亚洲成人网在线观看|