--- library_name: transformers tags: - llama-factory license: apache-2.0 --- ## Model - base model: [meta-llama/Meta-Llama-3-8B-Instruct](https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct) ## Dataset - [youjunhyeok/llama3_train](https://huggingface.co/datasets/youjunhyeok/llama3_train) ## Load Model Use the following Python code to load the model: ```python3 from transformers import AutoTokenizer, AutoModelForCausalLM path = 'youjunhyeok/llama3-8b-ko-sft-v1' model = AutoModelForCausalLM.from_pretrained(path) tokenizer = AutoTokenizer.from_pretrained(path) ``` ## Chat ```python3 def chat(message): messages = [ {"role": "system", "content": "당신은 인공지능 어시트턴트입니다. 친절하고 정확한 답변을 해주세요."}, {"role": "user", "content": message}, ] input_ids = tokenizer.apply_chat_template( messages, add_generation_prompt=True, return_tensors="pt" ).to(model.device) terminators = [ tokenizer.eos_token_id, tokenizer.convert_tokens_to_ids("<|eot_id|>") ] outputs = model.generate( input_ids, max_new_tokens=512, eos_token_id=terminators, do_sample=True, temperature=0.6, top_p=0.9, ) response = outputs[0][input_ids.shape[-1]:] print(tokenizer.decode(response, skip_special_tokens=True)) chat('근로자가 부당해고를 당했을 때 구제받기 위한 절차와 요건은 무엇인가?') ``` ## Output ``` 근로자가 부당해고를 당했을 때 구제받기 위한 절차와 요건은 다음과 같습니다: 1. 근로자: 근로자는 부당해고를 당한 경우, 근로기준법 등 관련 법률에 따라 구제를 받을 수 있습니다. 2. 부당해고: 부당해고란, 근로자에게 적법한 절차를 거치지 않고 해고된 경우를 말합니다. 근로기준법 등 관련 법률에 따라 부당해고의 기준과 구제절차가 정해져 있습니다. 3. 구제절차: 근로자가 부당해고를 당한 경우, 다음과 같은 구제절차를 거칠 수 있습니다: - 근로기준법 제28조에 따라 근로자에게 부당해고를 당한 경우, 근로기준법상 부당해고를 받은 근로자는 근로감독관에게 신고할 수 있습니다. 근로감독관은 근로자에게 구제를 제공하고, 근로자에게 부당해고를 당한 경우에 대한 적법한 절차를 수행합니다. - 근로기준법 제30조에 따라 근로자는 근로감독관에게 구제를 요청할 수 있습니다. 근로감독관은 근로자의 요청에 따라 구제를 제공하고, 근로자에게 부당해고를 당한 경우에 대한 적법한 절차를 수행합니다. 4. 요건: 근로자가 구제를 받기 위해서는 다음과 같은 요건을 충족해야 합니다: - 근로자: 근로자는 근로기준법 등 관련 법률에 따라 근로자로 정의되는 경우에 구제를 받을 수 있습니다. - 부당해고: 근로자는 부당해고를 당한 경우에 구제를 받을 수 있습니다. 부당해고란, 근로기준법 등 관련 법률에 따라 정의된 경우에 해당합니다. - 구제절차: 근로자는 구제절차를 거쳐야 합니다. 구제절차는 근로기준법 등 관련 법률에 따라 정의된 경우에 해당합니다. 요약하면, 근로자가 부당해고를 당했을 때 구제받기 위해서는 근로기준법 등 관련 법률에 따라 구제절차를 거치고, 근로 ``` ## BenchMark (KOR) ``` # alias A = youjunhyeok/llama3-8b-ko-sft-v1 B = DavidAhn/Llama-3-8B-slerp-262k C = meta-llama/Meta-Llama-3-8B D = chihoonlee10/T3Q-ko-solar-dpo-v7.0 (24.05.24 ko 리더보드 1등) ``` | Benchmark (macro_f1) | A | B | C | D | |---------------------------|:----:|:----:|:----:|:----:| | kobest_boolq (0-shot) | 84.7 | 33.5 | 38.2 | 34.1 | | kobest_boolq (5-shot) | 85.4 | 68.8 | 83.8 | 93.1 | | kobest_copa (0-shot) | 60.6 | 58.5 | 63.1 | 81.0 | | kobest_copa (5-shot) | 67.2 | 61.7 | 69.1 | 91.0 | | kobest_hellaswag (0-shot) | 40.0 | 43.2 | 42.1 | 55.1 | | kobest_hellaswag (5-shot) | 42.4 | 45.3 | 44.2 | 55.2 | | kobest_sentineg (0-shot) | 52.1 | 34.8 | 51.5 | 82.7 | | kobest_sentineg (5-shot) | 89.4 | 85.8 | 94.7 | 91.4 | ## BenchMark (ENG) ``` # alias A = youjunhyeok/llama3-8b-ko-sft-v1 B = DavidAhn/Llama-3-8B-slerp-262k C = meta-llama/Meta-Llama-3-8B ``` | | A | B | C | |:--------------|------:|------:|------:| | openbookqa | 0.342 | 0.312 | 0.338 | | hellaswag | 0.555 | 0.587 | 0.576 | | boolq | 0.824 | 0.832 | 0.831 | | arc_easy | 0.758 | 0.808 | 0.815 | | arc_challenge | 0.464 | 0.518 | 0.529 | ## Llama_factory Train Command {data_dir}, {dataset_name}, {output_dir} is variable ``` llamafactory-cli train \ --stage sft \ --do_train True \ --model_name_or_path meta-llama/Meta-Llama-3-8B-Instruct \ --preprocessing_num_workers 16 \ --finetuning_type lora \ --template llama3 \ --flash_attn auto \ --dataset_dir {data_dir} \ --dataset {dataset_name} \ --cutoff_len 1024 \ --learning_rate 5e-05 \ --num_train_epochs 2.0 \ --max_samples 400000 \ --per_device_train_batch_size 8 \ --gradient_accumulation_steps 8 \ --lr_scheduler_type cosine \ --max_grad_norm 1.0 \ --logging_steps 50 \ --save_steps 1000 \ --warmup_steps 1000 \ --optim adamw_torch \ --resize_vocab True \ --packing False \ --report_to none \ --output_dir {output_dir} \ --fp16 True \ --plot_loss True \ --ddp_timeout 180000000 \ --include_num_input_tokens_seen True \ --lora_rank 8 \ --lora_alpha 16 \ --lora_dropout 0.05 \ --lora_target all ```