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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
metrics:
|
6 |
- accuracy
|
7 |
pipeline_tag: text-generation
|
8 |
+
---
|
9 |
+
# Model card for aiplanet/effi-13b
|
10 |
+
|
11 |
+
effic-13B parameters is a causal decoder-only model built by Aiplanet based on Llama-2-13b-chat-hf and fine tuned using the CoT dataset available in huggingface datasets.It is made available under the Apache 2.0 license.
|
12 |
+
|
13 |
+
This modelcard aims to be a base template for new models. It has been generated using [this raw template](https://github.com/huggingface/huggingface_hub/blob/main/src/huggingface_hub/templates/modelcard_template.md?plain=1).
|
14 |
+
|
15 |
+
## Why use Falcon-40B-Instruct?
|
16 |
+
- This is a ready to use chat/instruct model based on Llama-2-13b-chat-hf which provides a rationale for the context provided.
|
17 |
+
- Llam-2 is the bset open source model available.
|
18 |
+
This is an instruct model, which may not be ideal for further finetuning. If you are interested in building your own instruct/chat model, we recommend starting from **Llama-2-13b-chat-hf**
|
19 |
+
|
20 |
+
You will need at least **85-100GB of memory to swiftly run inference with effi-17b**.
|
21 |
+
|
22 |
+
## Model Details
|
23 |
+
|
24 |
+
### Model Description
|
25 |
+
|
26 |
+
This model has been fine tuned on Chain of Thought datsets which has context from mixed sources with corresponding rationale. The final finetuned Large Language Model(LLM) have shown enhanced capabilities of solving novel tasks by providing a reasoning.
|
27 |
+
|
28 |
+
|
29 |
+
|
30 |
+
- **Developed by:** AiPlanet
|
31 |
+
- **Model type:** Casual Decoder only
|
32 |
+
- **Language(s) (NLP):** English
|
33 |
+
- **License:** Apache 2.0
|
34 |
+
- **Finetuned from model :** Llama-2-13b-chat-hf
|
35 |
+
|
36 |
+
### Model Sources [optional]
|
37 |
+
|
38 |
+
<!-- Provide the basic links for the model. -->
|
39 |
+
|
40 |
+
- **Repository:** [More Information Needed]
|
41 |
+
- **Paper [optional]:** [More Information Needed]
|
42 |
+
- **Demo [optional]:** [More Information Needed]
|
43 |
+
|
44 |
+
## Uses
|
45 |
+
|
46 |
+
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
47 |
+
|
48 |
+
### Direct Use
|
49 |
+
|
50 |
+
effic-17b has been finetuned on a Chain of Thought dataset.
|
51 |
+
|
52 |
+
### Out-of-Scope Use
|
53 |
+
|
54 |
+
Production use without adequate assessment of risks and mitigation; any use cases which may be considered irresponsible or harmful.
|
55 |
+
|
56 |
+
|
57 |
+
## Bias, Risks, and Limitations
|
58 |
+
|
59 |
+
This model has been majorly trained on English data, and will not generalize appropriately to other languages. Furthermore, as it is trained on a large-scale corpora representative of the web, it will carry the stereotypes and biases commonly encountered online.
|
60 |
+
|
61 |
+
### Recommendations
|
62 |
+
|
63 |
+
We recommend users of effic-13b to develop guardrails and to take appropriate precautions for any production use.
|
64 |
+
|
65 |
+
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
66 |
+
|
67 |
+
## How to Get Started with the Model
|
68 |
+
|
69 |
+
Use the code below to get started with the model.
|
70 |
+
|
71 |
+
```
|
72 |
+
from transformers import (AutoModelForCausalLM, AutoTokenizer, pipeline)
|
73 |
+
model_card = "aiplanet/effi-13b"
|
74 |
+
#
|
75 |
+
model = AutoModelForCausalLM.from_pretrained(model_card)
|
76 |
+
tokenizer = AutoTokenizer.from_pretrained(model_card)
|
77 |
+
#
|
78 |
+
generate_text = transformers.pipeline(
|
79 |
+
model=model, tokenizer=tokenizer,
|
80 |
+
return_full_text=True, # langchain expects the full text
|
81 |
+
task='text-generation',
|
82 |
+
# we pass model parameters here too
|
83 |
+
temperature=0.4, # 'randomness' of outputs, 0.0 is the min and 1.0 the max
|
84 |
+
max_new_tokens=512, # mex number of tokens to generate in the output
|
85 |
+
repetition_penalty=1.1 # without this output begins repeating
|
86 |
+
)
|
87 |
+
#
|
88 |
+
promt = """
|
89 |
+
Can you explain this code in detail?
|
90 |
+
|
91 |
+
def generate_stream(tokenizer, model, params, device,
|
92 |
+
context_len=2048, stream_interval=2):
|
93 |
+
|
94 |
+
prompt = params["prompt"]
|
95 |
+
l_prompt = len(prompt)
|
96 |
+
temperature = float(params.get("temperature", 1.0))
|
97 |
+
max_new_tokens = int(params.get("max_new_tokens", 256))
|
98 |
+
stop_str = params.get("stop", None)
|
99 |
+
|
100 |
+
input_ids = tokenizer(prompt).input_ids
|
101 |
+
output_ids = list(input_ids)
|
102 |
+
|
103 |
+
max_src_len = context_len - max_new_tokens - 8
|
104 |
+
input_ids = input_ids[-max_src_len:]
|
105 |
+
|
106 |
+
for i in range(max_new_tokens):
|
107 |
+
if i == 0:
|
108 |
+
out = model(
|
109 |
+
torch.as_tensor([input_ids], device=device), use_cache=True)
|
110 |
+
logits = out.logits
|
111 |
+
past_key_values = out.past_key_values
|
112 |
+
else:
|
113 |
+
attention_mask = torch.ones(
|
114 |
+
1, past_key_values[0][0].shape[-2] + 1, device=device)
|
115 |
+
out = model(input_ids=torch.as_tensor([[token]], device=device),
|
116 |
+
use_cache=True,
|
117 |
+
attention_mask=attention_mask,
|
118 |
+
past_key_values=past_key_values)
|
119 |
+
logits = out.logits
|
120 |
+
past_key_values = out.past_key_values
|
121 |
+
|
122 |
+
last_token_logits = logits[0][-1]
|
123 |
+
|
124 |
+
if device == "mps":
|
125 |
+
# Switch to CPU by avoiding some bugs in mps backend.
|
126 |
+
last_token_logits = last_token_logits.float().to("cpu")
|
127 |
+
|
128 |
+
if temperature < 1e-4:
|
129 |
+
token = int(torch.argmax(last_token_logits))
|
130 |
+
else:
|
131 |
+
probs = torch.softmax(last_token_logits / temperature, dim=-1)
|
132 |
+
token = int(torch.multinomial(probs, num_samples=1))
|
133 |
+
|
134 |
+
output_ids.append(token)
|
135 |
+
|
136 |
+
if token == tokenizer.eos_token_id:
|
137 |
+
stopped = True
|
138 |
+
else:
|
139 |
+
stopped = False
|
140 |
+
|
141 |
+
if i % stream_interval == 0 or i == max_new_tokens - 1 or stopped:
|
142 |
+
output = tokenizer.decode(output_ids, skip_special_tokens=True)
|
143 |
+
pos = output.rfind(stop_str, l_prompt)
|
144 |
+
if pos != -1:
|
145 |
+
output = output[:pos]
|
146 |
+
stopped = True
|
147 |
+
yield output
|
148 |
+
|
149 |
+
if stopped:
|
150 |
+
break
|
151 |
+
|
152 |
+
del past_key_values
|
153 |
+
"""
|
154 |
+
#
|
155 |
+
system_message = "Given your chain of thought reasoning, provide a rationale for the context in the source."
|
156 |
+
prompt = f"[INST] <<SYS>>\n{system_message}\n<</SYS>>\n\n{prompt}. [/INST]" # replace the command here with something relevant to your task
|
157 |
+
#
|
158 |
+
result = generate_text(prompt)
|
159 |
+
print(result[0]['generated_text'].strip().split("[/INST]")[-1])
|
160 |
+
|
161 |
+
```
|
162 |
+
|
163 |
+
## Training Details
|
164 |
+
|
165 |
+
### Training Data
|
166 |
+
|
167 |
+
effic-13b has been finetuned on https://huggingface.co/datasets/kaist-ai/CoT-Collection
|
168 |
+
The data was tokenized with the **meta-llama/Llama-2-13b-chat-hf** tokenizer.
|
169 |
+
|
170 |
+
|
171 |
+
### Training Procedure
|
172 |
+
|
173 |
+
Finetuning approach using PefT and Qlora(https://huggingface.co/blog/4bit-transformers-bitsandbytes)
|
174 |
+
|
175 |
+
#### Preprocessing [optional]
|
176 |
+
|
177 |
+
[More Information Needed]
|
178 |
+
|
179 |
+
|
180 |
+
#### Training Hyperparameters
|
181 |
+
|
182 |
+
- **Training regime:**
|
183 |
+
|
184 |
+
- lora_alpha=32,
|
185 |
+
- lora_dropout=0.05,
|
186 |
+
- r=8,
|
187 |
+
- bias="none",
|
188 |
+
- task_type="CAUSAL_LM"
|
189 |
+
#
|
190 |
+
- load_in_4bit=True,
|
191 |
+
- bnb_4bit_quant_type = "nf4",
|
192 |
+
- bnb_4bit_use_double_quant=True,
|
193 |
+
- bnb_4bit_compute_dtype=torch.bfloat16
|
194 |
+
#
|
195 |
+
- num_train_epochs = 1
|
196 |
+
- fp16 = False
|
197 |
+
- bf16 = False
|
198 |
+
- per_device_train_batch_size = 1
|
199 |
+
- per_device_eval_batch_size = 1
|
200 |
+
- gradient_accumulation_steps = 4
|
201 |
+
- gradient_checkpointing = True
|
202 |
+
- max_grad_norm = 0.3
|
203 |
+
- learning_rate = 2e-4
|
204 |
+
- weight_decay = 0.001
|
205 |
+
- optim = "paged_adamw_32bit"
|
206 |
+
- lr_scheduler_type = "constant"
|
207 |
+
- max_steps = 500
|
208 |
+
- warmup_ratio = 0.03
|
209 |
+
- group_by_length = True
|
210 |
+
- save_steps = 25
|
211 |
+
- logging_steps = 5
|
212 |
+
- max_seq_length = 2048
|
213 |
+
- packing = False
|
214 |
+
- device_map = {"": 0}
|
215 |
+
|
216 |
+
## Evaluation
|
217 |
+
|
218 |
+
Paper coming soon.
|
219 |
+
|
220 |
+
See the OpenLLM Leaderboard(https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard)for early results.
|
221 |
+
|
222 |
+
## Technical Specifications [optional]
|
223 |
+
|
224 |
+
### Model Architecture and Objective
|
225 |
+
|
226 |
+
[More Information Needed]
|
227 |
+
|
228 |
+
### Compute Infrastructure
|
229 |
+
|
230 |
+
[More Information Needed]
|
231 |
+
|
232 |
+
#### Hardware
|
233 |
+
|
234 |
+
[More Information Needed]
|
235 |
+
|
236 |
+
#### Software
|
237 |
+
|
238 |
+
[More Information Needed]
|
239 |
+
|
240 |
+
## Citation
|
241 |
+
|
242 |
+
@article{effic-13b,
|
243 |
+
title={{effic-13b}: an open large language model with state-of-the-art performance},
|
244 |
+
author={aiplanet},
|
245 |
+
year={2023}
|
246 |
+
}
|
247 |
+
|
248 |
+
## Model Card Contact
|
249 |
+
|
250 |
+
community@aiplanet.com
|
251 |
+
|
252 |
+
|