File size: 8,496 Bytes
eefcb72
 
cd683d4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
eefcb72
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
296cf23
 
 
eefcb72
 
 
 
 
cd683d4
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
---
license: mit
model-index:
- name: llama-2-7b-small-model-new
  results:
  - task:
      type: text-generation
      name: Text Generation
    dataset:
      name: AI2 Reasoning Challenge (25-Shot)
      type: ai2_arc
      config: ARC-Challenge
      split: test
      args:
        num_few_shot: 25
    metrics:
    - type: acc_norm
      value: 45.22
      name: normalized accuracy
    source:
      url: https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard?query=vikash06/llama-2-7b-small-model-new
      name: Open LLM Leaderboard
  - task:
      type: text-generation
      name: Text Generation
    dataset:
      name: HellaSwag (10-Shot)
      type: hellaswag
      split: validation
      args:
        num_few_shot: 10
    metrics:
    - type: acc_norm
      value: 72.35
      name: normalized accuracy
    source:
      url: https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard?query=vikash06/llama-2-7b-small-model-new
      name: Open LLM Leaderboard
  - task:
      type: text-generation
      name: Text Generation
    dataset:
      name: MMLU (5-Shot)
      type: cais/mmlu
      config: all
      split: test
      args:
        num_few_shot: 5
    metrics:
    - type: acc
      value: 46.23
      name: accuracy
    source:
      url: https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard?query=vikash06/llama-2-7b-small-model-new
      name: Open LLM Leaderboard
  - task:
      type: text-generation
      name: Text Generation
    dataset:
      name: TruthfulQA (0-shot)
      type: truthful_qa
      config: multiple_choice
      split: validation
      args:
        num_few_shot: 0
    metrics:
    - type: mc2
      value: 42.46
    source:
      url: https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard?query=vikash06/llama-2-7b-small-model-new
      name: Open LLM Leaderboard
  - task:
      type: text-generation
      name: Text Generation
    dataset:
      name: Winogrande (5-shot)
      type: winogrande
      config: winogrande_xl
      split: validation
      args:
        num_few_shot: 5
    metrics:
    - type: acc
      value: 63.93
      name: accuracy
    source:
      url: https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard?query=vikash06/llama-2-7b-small-model-new
      name: Open LLM Leaderboard
  - task:
      type: text-generation
      name: Text Generation
    dataset:
      name: GSM8k (5-shot)
      type: gsm8k
      config: main
      split: test
      args:
        num_few_shot: 5
    metrics:
    - type: acc
      value: 9.55
      name: accuracy
    source:
      url: https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard?query=vikash06/llama-2-7b-small-model-new
      name: Open LLM Leaderboard
---
This model is trained on experimental basis on a small dataset to assess whether training longer on a smaller dataset has a good performance or not.


# Model Details
vikash06/llama-2-7b-small-model--> Finetuned model on llama2

# Uses

# Creative Writing: Write a question or instruction that requires a creative, open-ended written response. 
The instruction should be reasonable to ask of a person with general world knowledge and should not require searching. 
In this task, your prompt should give very specific instructions to follow. 
Constraints, instructions, guidelines, or requirements all work, and the more of them the better.


# Closed QA: Write a question or instruction that requires factually correct response based on a passage of text from Wikipedia. 
The question can be complex and can involve human-level reasoning capabilities, but should not require special knowledge.
To create a question for this task include both the text of the question as well as the reference text in the form.

# Open QA: Write a question that can be answered using general world knowledge or at most a single search. 
This task asks for opinions and facts about the world at large and does not provide any reference text for consultation.

# Summarization: Give a summary of a paragraph from Wikipedia.
Please don't ask questions that will require more than 3-5 minutes to answer.
To create a question for this task include both the text of the question as well as the reference text in the form.

# Information Extraction: These questions involve reading a paragraph from Wikipedia and extracting information from the passage. 
Everything required to produce an answer (e.g. a list, keywords etc) should be included in the passages. 
To create a question for this task include both the text of the question as well as the reference text in the form.


# Classification: These prompts contain lists or examples of entities to be classified, e.g. movie reviews, products, etc. 
In this task the text or list of entities under consideration is contained in the prompt (e.g. there is no reference text.).
You can choose any categories for classification you like, the more diverse the better.

# Brainstorming: Think up lots of examples in response to a question asking to brainstorm ideas

# Direct Use

The model is intnded for direct use

# How to Get Started with the Model

import torch

import pandas as pd

from transformers import AutoModelForCausalLM, AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained("vikash06/llama-2-7b-small-model")

model = AutoModelForCausalLM.from_pretrained("vikash06/llama-2-7b-small-model", torch_dtype=torch.float16, device_map="cuda:0")

print (model)

def generate_training_prompt(instruction,context):

    return f"""
    Below is an instruction that describes a task. Write a response that appropriately completes the request.

    ### Instruction: {instruction}

    ### Context:
    {context.strip()}


    """.strip()

data1 ={"instruction": "When was the first Reading railway station opened?", "context": "Reading railway station is a major transport hub in Reading, Berkshire, England. It is on the northern edge of the town centre, near the main retail and commercial areas and the River Thames, 36 miles (58 km) from London Paddington. The first Reading station was opened on 30 March 1840 as the temporary western terminus of the original line of the Great Western Railway (GWR). Reading is the ninth-busiest station in the UK outside London and the second busiest interchange station outside London with over 3.8 million passengers changing trains at the station annually.", "response": "The first Reading railway station was opened on the 30th of March, 1840.", "category": "closed_qa"}

prompt = generate_training_prompt(data1["instruction"],data1["context"])

input_ids = tokenizer(prompt, return_tensors="pt", truncation=True).input_ids.cuda(0)

outputs = model.generate(input_ids=input_ids, max_new_tokens=128, do_sample=True, top_p=0.9,temperature=0.3)

resp = tokenizer.batch_decode(outputs.detach().cpu().numpy(), skip_special_tokens=True)[0][len(prompt):].split("\n")

resp = [x for x in resp if x!='']

print(resp)
    
# Training Data
1000 samples were carefully selected from each of the category.

# Training Procedure
We used the below libraries to finetune the llama2-7b:
torch==2.1.0 

transformers==4.35.2

peft@git+https://github.com/huggingface/peft.git bitsandbytes==0.41.1 trl @ git+https://github.com/lvwerra/trl.git@34e6948d459540a21f80c5be227fb4da039dd97a 

We used batch size 0f 2 on 50 epochs

# Evaluation

We performed hellaswag task using evaluation library of EleutherAI: https://github.com/EleutherAI/lm-evaluation-harness

below are the results:

![image/png](https://cdn-uploads.huggingface.co/production/uploads/63a7d07154f1d0225b0b9d1c/CKgtAaq55ce30e-Qorzsi.png)


![image/png](https://cdn-uploads.huggingface.co/production/uploads/63a7d07154f1d0225b0b9d1c/Pyy4FpgVPC1loNRO8JA3u.png)


# Environmental Impact
Carbon Emitted: 0.432 kg/kWh Offset: 0% hardware: a6000 48GB(3) hours: 28

# Technical Report

Detail writeup coming soon
# [Open LLM Leaderboard Evaluation Results](https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard)
Detailed results can be found [here](https://huggingface.co/datasets/open-llm-leaderboard/details_vikash06__llama-2-7b-small-model-new)

|             Metric              |Value|
|---------------------------------|----:|
|Avg.                             |46.62|
|AI2 Reasoning Challenge (25-Shot)|45.22|
|HellaSwag (10-Shot)              |72.35|
|MMLU (5-Shot)                    |46.23|
|TruthfulQA (0-shot)              |42.46|
|Winogrande (5-shot)              |63.93|
|GSM8k (5-shot)                   | 9.55|