模型:
基础模型:replit/replit-code-v1-3b
这是 Replit Code Instruct 模型的第二版。
该模型是在 Sahil2801 的 CodeAlpaca 和 Teknium 的 GPTeacher Code-Instruct 上进行微调,以提供 Replit 的 Code 模型的指导能力。
在 HuggingFace 的演示空间中尝试此模型: https://huggingface.co/spaces/teknium/Replit-v2-CodeInstruct-3B
数据集链接:CodeAlpaca: https://huggingface.co/datasets/sahil2801/CodeAlpaca-20k GPTeacher 子集 - Code Instruct: https://github.com/teknium1/GPTeacher
该模型在 2 个 a100 80gb 的设备上进行了 1 小时的训练,使用 Alpaca 格式的约 25000 个代码指导/回应对进行了微调。
第一个模型只在 512 的序列长度上进行了训练,而该模型则是在 2000 的序列长度上进行的训练,因此可以更好地获取训练数据的知识。
有关运行此模型的基本要求,请参考基础模型的 HuggingFace 模型卡片: https://huggingface.co/replit/replit-code-v1-3b
可以像对待 Alpaca 微调模型一样对此微调模型进行提示:
### Instruction: <prompt> ### Input: <additional context> ### Response:
或者
### Instruction: <prompt> ### Response:
对于模型参数中的设备="auto",该模型似乎存在问题(并且需要 trust_remote_code=True),所以你可以尝试像我这样加载它:
self.tokenizer = AutoTokenizer.from_pretrained("./Replit-CodeInstruct/", trust_remote_code=True)
self.model = AutoModelForCausalLM.from_pretrained(
"./Replit-CodeInstruct",
torch_dtype=torch.bfloat16,
trust_remote_code=True
)
self.model.to('cuda')
对我来说,此模型使用以下采样器设置生成了连贯的输出,但请随意尝试:
max_new_tokens=128, do_sample=True, use_cache=True, temperature=0.2, top_p=0.9, eos_token_id= self.tokenizer.eos_token_id
在 tokenizer 的解码参数中,还需要这些设置:
skip_special_tokens=True, clean_up_tokenization_space=False
使用 HuggingFace 训练器训练模型时使用了以下参数:
--model_name_or_path replit/replit-code-v1-3b --data_path /root/stanford_alpaca/train.json --bf16 True --output_dir /root/stanford_alpaca/model_ckpts --num_train_epochs 3 --per_device_train_batch_size 4 --per_device_eval_batch_size 1 --gradient_accumulation_steps 8 --save_strategy steps --save_steps 200 --save_total_limit 3 --learning_rate 1e-5 --weight_decay 0. --warmup_ratio 0.03 --tf32 True --run_name Replit1