Slovak
ju-bezdek commited on
Commit
1a89142
1 Parent(s): bad3092

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +111 -0
README.md ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ datasets:
4
+ - blip-solutions/SlovAlpaca
5
+ language:
6
+ - sk
7
+ ---
8
+
9
+ # SlovAlpaca
10
+
11
+ This repository contains the LORA weights finetuned on the translated version of the original Alpaca dataset (more info on the dataset card)
12
+
13
+ ## Training procedure
14
+
15
+ The training was done on the 7B LLaMA model (decapoda-research/llama-7b-hf) quantized to 8bits with following Hyperparameters:
16
+
17
+ ```
18
+ MICRO_BATCH_SIZE = 3
19
+ BATCH_SIZE = 128
20
+ GRADIENT_ACCUMULATION_STEPS = BATCH_SIZE // MICRO_BATCH_SIZE
21
+ EPOCHS = 2 # paper uses 3
22
+ LEARNING_RATE = 2e-5 # from the original paper
23
+ CUTOFF_LEN = 256 # 256 accounts for about 96% of the data
24
+ LORA_R = 4
25
+ LORA_ALPHA = 16
26
+ LORA_DROPOUT = 0.05
27
+ ```
28
+
29
+ The sole goal of this project is to explore the effects of single language finetuning using the same dataset and methods as the original paper did and comapre the results
30
+
31
+ @misc{alpaca,
32
+ author = {Rohan Taori and Ishaan Gulrajani and Tianyi Zhang and Yann Dubois and Xuechen Li and Carlos Guestrin and Percy Liang and Tatsunori B. Hashimoto },
33
+ title = {Stanford Alpaca: An Instruction-following LLaMA model},
34
+ year = {2023},
35
+ publisher = {GitHub},
36
+ journal = {GitHub repository},
37
+ howpublished = {\url{https://github.com/tatsu-lab/stanford_alpaca}},
38
+ }
39
+
40
+ ## How to use:
41
+
42
+ ### Prerequisites
43
+ ```
44
+ !pip install datasets loralib sentencepiece
45
+ !pip uninstall -y transformers
46
+ !pip install git+https://github.com/zphang/transformers@c3dc391#egg=transformers
47
+ !pip install git+https://github.com/huggingface/peft.git
48
+ !pip install bitsandbytes
49
+ ```
50
+
51
+
52
+ ### Load model:
53
+
54
+ ```
55
+ from peft import PeftModel
56
+ from transformers import LLaMATokenizer, LLaMAForCausalLM, GenerationConfig
57
+
58
+ tokenizer = LLaMATokenizer.from_pretrained("decapoda-research/llama-7b-hf")
59
+
60
+ model = LLaMAForCausalLM.from_pretrained(
61
+ "decapoda-research/llama-7b-hf",
62
+ load_in_8bit=True,
63
+ device_map="auto",
64
+ )
65
+
66
+ model = PeftModel.from_pretrained(model, "blip-solutions/SlovAlpaca")
67
+ ```
68
+
69
+ ### Generation
70
+
71
+ Here is a colab notebook for inference: https://colab.research.google.com/drive/1z4aMG7tGjchLBlg_iXDuqt3sH6bQRuQk?usp=sharing
72
+
73
+ ```
74
+ PROMPT = """Below is an instruction that describes a task. Write a response that appropriately completes the request.
75
+ ### Instruction:
76
+ Kde žijú lamy?
77
+ ### Response:"""
78
+
79
+ inputs = tokenizer(
80
+ PROMPT,
81
+ return_tensors="pt",
82
+ )
83
+ input_ids = inputs["input_ids"].cuda()
84
+
85
+ generation_config = GenerationConfig(
86
+ temperature=0.6,
87
+ top_p=0.95,
88
+ repetition_penalty=1.15,
89
+ )
90
+ print("Generating...")
91
+ generation_output = model.generate(
92
+ input_ids=input_ids,
93
+ generation_config=generation_config,
94
+ return_dict_in_generate=True,
95
+ output_scores=True,
96
+ max_new_tokens=128,
97
+ )
98
+ for s in generation_output.sequences:
99
+ print(tokenizer.decode(s))
100
+ ```
101
+
102
+ ### Response:
103
+
104
+ ```
105
+ Generating...
106
+ Below is an instruction that describes a task. Write a response that appropriately completes the request.
107
+ ### Instruction:
108
+ Kde žijú lamy?
109
+ ### Response:
110
+ Lamy žiju v horách, na poli, alebo v lesoch.
111
+ ```