英文

基础模型:replit/replit-code-v1-3b

该模型基于Sahil2801的CodeAlpaca和Teknium的GPTeacher Code-Instruct进行微调,以实现Replit的Code模型讲解功能。

在HuggingFace演示空间上体验此模型: https://huggingface.co/spaces/teknium/Replit-v1-CodeInstruct-3B

数据集链接:CodeAlpaca: https://huggingface.co/datasets/sahil2801/CodeAlpaca-20k GPTeacher子集 - Code Instruct: https://github.com/teknium1/GPTeacher

该模型在两个80GB的a100上进行了1小时的训练,使用了约25,000条代码说明/响应对(Alpaca格式)。

有关运行的基本要求,请参阅基础模型的HuggingFace模型卡片: https://huggingface.co/replit/replit-code-v1-3b

这个微调可以像任何alpaca微调一样进行提示:

### Instruction:
<prompt>

### Input:
<additional context>

### Response:

或者

### Instruction:
<prompt>

### Response:

我发现该模型在模型参数中使用device="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