Coder Social home page Coder Social logo

cot-llama2's Introduction

CoT-llama2

CoT-llama2
Chain-of-thought 방식을 활용하여 llama2를 fine-tuning

CoT-llama-2k-7b: Hugging Face
KoCoT-2000: Hugging Face

Introduction

  • LLM 관련 프로젝트를 진행하면서, "LLM의 근본적인 성능의 문제는 파라미터보다 데이터셋의 품질에 더 의미가 있지 않을까?"라는 생각을 하게 되었습니다.

  • Kaist-CoTLIMA를 통해서 데이터의 개수보다 품질이 모델의 성능에 어느정도 기여한다는 사실을 깨닫게 되었습니다.

  • 이것을 동기부여로 삼아서, LIMA에서 1000~2000개의 데이터셋을 활용한 것을 기반으로 Kaist-CoT 데이터셋 중 2000개를 추출하여 학습하기로 하였습니다!🙂🙂

  • DeepL를 활용하여 번역하였고, 그 이후에 따로 직접적인 전처리를 하진 않고 바로 훈련에 도입했습니다.

  • 이렇게 만들어진 🥮KoCoT-2000🥮 데이터셋을 활용하여 beomi님의 llama-2-ko 모델을 fine-tuning 하였습니다.

  • 결과적으로 CoT-llama-2k-7b 모델을 만들게 되었고✌, 성능평가를 위해 Polyglot-Ko와 llama-2-ko 모델과 비교를 진행했습니다.🙂🙃

  • 본 연구는 (주)마커와 (주)미디어그룹사람과숲의 오픈소스 LLM 연구 컨소시엄에서 진행되었습니다.

Model Description

CoT-llama2-2k-7b

  • llama-2-ko-7B를 fine-tuning한 모델
  • 🥮CoT-llama2-2k-7b🥮 모델은 LIMA의 방법론을 이용하여 Kaist에서 제작한 데이터셋을 기반으로 Chain-Of-Thought를 잘 수행할 수 있도록 튜닝한 모델입니다✌✌

Training Hyperparameters (as LIMA)

Hyperparameters Value
batch_size 64
micro_batch_size 1
Epochs 15
learning_rate 1e-5
cutoff_len 2048
lr_scheduler linear
base_model beomi/llama-2-ko-7b

Quick start

Colab Code: Open In Colab

Datasets

KoCoT_2000

Using DeepL Pro API, translate about Kaist-CoT.

Performance

When I evaluated Ko-Platy, I used this repo.
And, implement below code.

# In colab,
!python main.py \
    --model gpt2 \ 
    --model_args pretrained=..your_model_name.. \
    --tasks kobest_hellaswag,kobest_copa,kobest_boolq,kobest_sentineg \
    --device cuda:0 \
    --num_fewshot 0 # 5, 10, 25, ...

COPA (F1)

Model 0-shot 5-shot 10-shot 50-shot
Polyglot-ko-1.3b 0.7196 0.7193 0.7204 0.7206
Polyglot-ko-3.8b 0.7595 0.7608 0.7638 0.7788
Polyglot-ko-5.8b 0.7745 0.7676 0.7775 0.7887
Polyglot-ko-12.8b 0.7937 0.8108 0.8037 0.8369
Llama-2-Ko-7b 20B 0.7388 0.7626 0.7808 0.7979
Llama-2-Ko-7b 40B 0.7436 0.7927 0.8037 0.8259
KO-platypus2-7B-EX(ours) 0.7509 0.7899 0.8029 0.8290
CoT-llama-2(ours) 0.7528 0.7888 0.7998 0.8210

HellaSwag (F1)

Model 0-shot 5-shot 10-shot 50-shot
Polyglot-ko-1.3b 0.5247 0.5260 0.5278 0.5427
Polyglot-ko-3.8b 0.5707 0.5830 0.5670 0.5787
Polyglot-ko-5.8b 0.5976 0.5998 0.5979 0.6208
Polyglot-ko-12.8b 0.5954 0.6306 0.6098 0.6118
Llama-2-Ko-7b 20B 0.4518 0.4668 0.4726 0.4828
Llama-2-Ko-7b 40B 0.4562 0.4657 0.4698 0.4774
KO-platypus2-7B-EX(ours) 0.4571 0.4461 0.4371 0.4525
CoT-llama-2(ours) 0.4543 0.4554 0.4606 0.4579

BoolQ (F1)

Model 0-shot 5-shot 10-shot 50-shot
Polyglot-ko-1.3b 0.3552 0.4751 0.4109 0.4038
Polyglot-ko-3.8b 0.4320 0.5263 0.4930 0.4038
Polyglot-ko-5.8b 0.4356 0.5698 0.5187 0.5236
Polyglot-ko-12.8b 0.4818 0.6041 0.6289 0.6448
Llama-2-Ko-7b 20B 0.3607 0.6797 0.6801 0.6622
Llama-2-Ko-7b 40B 0.5786 0.6977 0.7084 0.7144
KO-platypus2-7B-EX(ours) 0.6028 0.6979 0.7016 0.6988
CoT-llama-2(ours) 0.5852 0.6947 0.7059 0.7213

SentiNeg (F1)

Model 0-shot 5-shot 10-shot 50-shot
Polyglot-ko-1.3b 0.6790 0.6257 0.5514 0.7851
Polyglot-ko-3.8b 0.4858 0.7950 0.7320 0.7851
Polyglot-ko-5.8b 0.3394 0.8841 0.8808 0.9521
Polyglot-ko-12.8b 0.9117 0.9015 0.9345 0.9723
Llama-2-Ko-7b 20B 0.4855 0.8295 0.8711 0.8513
Llama-2-Ko-7b 40B 0.4594 0.7611 0.7276 0.9370
KO-platypus2-7B-EX(ours) 0.5821 0.7653 0.7991 0.8643
CoT-llama-2(ours) 0.5045 0.8054 0.7942 0.9446

References

Kaist-COT CoT-llama
KoCoT-2000
llama-2-ko
ko-lm-evaluation-harness

TODO

  • Make CoT-llama2-7b
  • Share huggingface repo
  • Share evaluation results
  • Share sample code

cot-llama2's People

Contributors

kyujinhan avatar

Stargazers

Yoon, Seungje avatar Jumong Lee avatar Wonyoung Jung avatar Yeong-Joon Ju (주영준) avatar SUN YOUNG HWANG avatar Jeffrey (Dongkyu) Kim avatar Myungchul Shin avatar Jiwoo Chris Jung avatar Michael Y. Choi avatar

Watchers

cheolisable2 avatar  avatar

Forkers

plum7ree

cot-llama2's Issues

vocab issue 발생의 문제 해결을 위한 문의의 건 입니다..!

안녕하세요.
좋은 학습 자료 감사 드립니다.
platypus 깃헙 레포에서 requirements를 모두 잘 설치하고 업로드 주신 노트북 파라미터로 학습을 시키려고 했으나, 지속적으로,

아래와 같이 traceback 메세지가 발생하여

Traceback (most recent call last):
File "/home/sosohaja/anaconda3/envs/playllama/Platypus/finetune.py", line 312, in
fire.Fire(train)
File "/home/sosohaja/anaconda3/envs/playllama/lib/python3.10/site-packages/fire/core.py", line 141, in Fire
component_trace = _Fire(component, args, parsed_flag_args, context, name)
File "/home/sosohaja/anaconda3/envs/playllama/lib/python3.10/site-packages/fire/core.py", line 475, in _Fire
component, remaining_args = _CallAndUpdateTrace(
File "/home/sosohaja/anaconda3/envs/playllama/lib/python3.10/site-packages/fire/core.py", line 691, in _CallAndUpdateTrace
component = fn(*varargs, **kwargs)
File "/home/sosohaja/anaconda3/envs/playllama/Platypus/finetune.py", line 150, in train
tokenizer = LlamaTokenizer.from_pretrained("beomi/llama-2-ko-7b")
File "/home/sosohaja/anaconda3/envs/playllama/lib/python3.10/site-packages/transformers/tokenization_utils_base.py", line 1825, in from_pretrained
return cls._from_pretrained(
File "/home/sosohaja/anaconda3/envs/playllama/lib/python3.10/site-packages/transformers/tokenization_utils_base.py", line 1988, in _from_pretrained
tokenizer = cls(*init_inputs, **init_kwargs)
File "/home/sosohaja/anaconda3/envs/playllama/lib/python3.10/site-packages/transformers/models/llama/tokenization_llama.py", line 96, in init
self.sp_model.Load(vocab_file)
File "/home/sosohaja/anaconda3/envs/playllama/lib/python3.10/site-packages/sentencepiece/init.py", line 905, in Load
return self.LoadFromFile(model_file)
File "/home/sosohaja/anaconda3/envs/playllama/lib/python3.10/site-packages/sentencepiece/init.py", line 310, in LoadFromFile
return _sentencepiece.SentencePieceProcessor_LoadFromFile(self, arg)
TypeError: not a string

다 방면으로 리서치 해본 결과, tokenizer.model 파일이 베이스 모델인 beomi/llama-2-ko-7b 에 없어 실행이 안되는 것으로 판단하였습니다..

해결을 어떻게 하신 후 올려주신 노트북으로 학습을 하셨는지 궁금합니다..!

감사합니다.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.