Sandiago21 commited on
Commit
25f6e24
1 Parent(s): c11c037

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +174 -14
README.md CHANGED
@@ -1,30 +1,175 @@
1
  ---
2
  license: other
 
 
 
 
3
  tags:
4
- - generated_from_trainer
5
- model-index:
6
- - name: llama-7b-hf-prompt-answering
7
- results: []
8
  ---
9
 
10
- <!-- This model card has been generated automatically according to the information the Trainer had access to. You
11
- should probably proofread and complete it, then remove this comment. -->
12
 
13
- # llama-7b-hf-prompt-answering
14
 
15
- This model is a fine-tuned version of [chainyo/alpaca-lora-7b](https://huggingface.co/chainyo/alpaca-lora-7b) on an unknown dataset.
16
 
17
- ## Model description
18
 
19
- More information needed
20
 
21
- ## Intended uses & limitations
22
 
23
- More information needed
24
 
25
- ## Training and evaluation data
26
 
27
- More information needed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
  ## Training procedure
30
 
@@ -49,3 +194,18 @@ The following hyperparameters were used during training:
49
  - Pytorch 2.0.0+cu117
50
  - Datasets 2.12.0
51
  - Tokenizers 0.12.1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: other
3
+ language:
4
+ - en
5
+ library_name: transformers
6
+ pipeline_tag: conversational
7
  tags:
8
+ - llama
9
+ - decapoda-research-7b-hf
10
+ - prompt answering
11
+ - peft
12
  ---
13
 
14
+ ## Model Card for Model ID
 
15
 
16
+ This repository contains a LLaMA-7B further fine-tuned model on conversations and question answering prompts.
17
 
18
+ This model is a fine-tuned version of [chainyo/alpaca-lora-7b](https://huggingface.co/chainyo/alpaca-lora-7b) on conversations dataset.
19
 
20
+ ⚠️ **I used [LLaMA-7b-hf](https://huggingface.co/decapoda-research/llama-7b-hf) as a base model, so this model is for Research purpose only (See the [license](https://huggingface.co/decapoda-research/llama-7b-hf/blob/main/LICENSE))**
21
 
 
22
 
23
+ ## Model Details
24
 
 
25
 
26
+ ### Model Description
27
 
28
+ The decapoda-research/llama-7b-hf model was finetuned on conversations and question answering prompts.
29
+
30
+ **Developed by:** [More Information Needed]
31
+
32
+ **Shared by:** [More Information Needed]
33
+
34
+ **Model type:** Causal LM
35
+
36
+ **Language(s) (NLP):** English, multilingual
37
+
38
+ **License:** Research
39
+
40
+ **Finetuned from model:** decapoda-research/llama-7b-hf
41
+
42
+
43
+ ## Model Sources [optional]
44
+
45
+ **Repository:** [More Information Needed]
46
+ **Paper:** [More Information Needed]
47
+ **Demo:** [More Information Needed]
48
+
49
+ ## Uses
50
+
51
+ The model can be used for prompt answering
52
+
53
+
54
+ ### Direct Use
55
+
56
+ The model can be used for prompt answering
57
+
58
+
59
+ ### Downstream Use
60
+
61
+ Generating text and prompt answering
62
+
63
+
64
+ ## Recommendations
65
+
66
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
67
+
68
+
69
+ # Usage
70
+
71
+ ## Creating prompt
72
+
73
+ The model was trained on the following kind of prompt:
74
+
75
+ ```python
76
+ def generate_prompt(instruction: str, input_ctxt: str = None) -> str:
77
+ if input_ctxt:
78
+ return f"""Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
79
+
80
+ ### Instruction:
81
+ {instruction}
82
+
83
+ ### Input:
84
+ {input_ctxt}
85
+
86
+ ### Response:"""
87
+ else:
88
+ return f"""Below is an instruction that describes a task. Write a response that appropriately completes the request.
89
+
90
+ ### Instruction:
91
+ {instruction}
92
+
93
+ ### Response:"""
94
+ ```
95
+
96
+ ## How to Get Started with the Model
97
+
98
+ Use the code below to get started with the model.
99
+
100
+ ```python
101
+ from transformers import LlamaTokenizer, LlamaForCausalLM
102
+ from peft import PeftModel
103
+
104
+ MODEL_NAME = "decapoda-research/llama-7b-hf"
105
+ tokenizer = LlamaTokenizer.from_pretrained(MODEL_NAME, add_eos_token=True)
106
+ tokenizer.pad_token_id = 0
107
+
108
+ model = LlamaForCausalLM.from_pretrained(MODEL_NAME, load_in_8bit=True, device_map="auto")
109
+ model = PeftModel.from_pretrained(model, "Sandiago21/llama-7b-hf")
110
+ ```
111
+
112
+ ### Example of Usage
113
+ ```python
114
+ from transformers import GenerationConfig
115
+
116
+ PROMPT = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.\n\n### Instruction:\nWhich is the capital city of Greece and with which countries does Greece border?\n\n### Input:\nQuestion answering\n\n### Response:\n"""
117
+ DEVICE = "cuda"
118
+
119
+ inputs = tokenizer(
120
+ PROMPT,
121
+ return_tensors="pt",
122
+ )
123
+
124
+ input_ids = inputs["input_ids"].to(DEVICE)
125
+
126
+ generation_config = GenerationConfig(
127
+ temperature=0.1,
128
+ top_p=0.95,
129
+ repetition_penalty=1.2,
130
+ )
131
+
132
+ print("Generating Response ... ")
133
+ with torch.no_grad():
134
+ generation_output = model.generate(
135
+ input_ids=input_ids,
136
+ generation_config=generation_config,
137
+ return_dict_in_generate=True,
138
+ output_scores=True,
139
+ max_new_tokens=256,
140
+ )
141
+
142
+ for s in generation_output.sequences:
143
+ print(tokenizer.decode(s))
144
+ ```
145
+
146
+ ### Example Output
147
+ ```python
148
+ Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
149
+
150
+ ### Instruction:
151
+ Which is the capital city of Greece and with which countries does Greece border?
152
+
153
+ ### Input:
154
+ Question answering
155
+
156
+ ### Response:
157
+
158
+
159
+ Generating...
160
+ <unk> Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
161
+
162
+ ### Instruction:
163
+ Which is the capital city of Greece and with which countries does Greece border?
164
+
165
+ ### Input:
166
+ Question answering
167
+
168
+ ### Response:
169
+ <unk>capital city of Athens and it borders Albania to the northwest, North Macedonia and Bulgaria to the northeast, Turkey to the east, and Libya to the southeast across the Mediterranean Sea.
170
+ ```
171
+
172
+ ## Training Details
173
 
174
  ## Training procedure
175
 
 
194
  - Pytorch 2.0.0+cu117
195
  - Datasets 2.12.0
196
  - Tokenizers 0.12.1
197
+
198
+ ### Training Data
199
+
200
+ The decapoda-research/llama-7b-hf was finetuned on conversations and question answering data
201
+
202
+
203
+ ### Training Procedure
204
+
205
+ The decapoda-research/llama-7b-hf model was further trained and finetuned on question answering and prompts data for 1 epoch (approximately 10 hours of training on a single GPU)
206
+
207
+
208
+ ## Model Architecture and Objective
209
+
210
+ The model is based on decapoda-research/llama-7b-hf model and finetuned adapters on top of the main model on conversations and question answering data.
211
+