RichardErkhov commited on
Commit
1359262
·
verified ·
1 Parent(s): d564c18

uploaded readme

Browse files
Files changed (1) hide show
  1. README.md +387 -0
README.md ADDED
@@ -0,0 +1,387 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Quantization made by Richard Erkhov.
2
+
3
+ [Github](https://github.com/RichardErkhov)
4
+
5
+ [Discord](https://discord.gg/pvy7H8DZMG)
6
+
7
+ [Request more models](https://github.com/RichardErkhov/quant_request)
8
+
9
+
10
+ Llama-3.1-Storm-8B - bnb 4bits
11
+ - Model creator: https://huggingface.co/unsloth/
12
+ - Original model: https://huggingface.co/unsloth/Llama-3.1-Storm-8B/
13
+
14
+
15
+
16
+
17
+ Original model description:
18
+ ---
19
+ base_model: meta-llama/Meta-Llama-3.1-8B
20
+ language:
21
+ - en
22
+ library_name: transformers
23
+ license: llama3.1
24
+ tags:
25
+ - llama-3
26
+ - llama
27
+ - meta
28
+ - facebook
29
+ - unsloth
30
+ - transformers
31
+ ---
32
+
33
+ # Finetune Llama 3.1, Gemma 2, Mistral 2-5x faster with 70% less memory via Unsloth!
34
+
35
+ We have a free Google Colab Tesla T4 notebook for Llama 3.1 (8B) here: https://colab.research.google.com/drive/1Ys44kVvmeZtnICzWz0xgpRnrIOjZAuxp?usp=sharing
36
+
37
+ ## ✨ Finetune for Free
38
+
39
+ All notebooks are **beginner friendly**! Add your dataset, click "Run All", and you'll get a 2x faster finetuned model which can be exported to GGUF, vLLM or uploaded to Hugging Face.
40
+
41
+ | Unsloth supports | Free Notebooks | Performance | Memory use |
42
+ |-----------------|--------------------------------------------------------------------------------------------------------------------------|-------------|----------|
43
+ | **Llama-3.1 8b** | [▶️ Start on Colab](https://colab.research.google.com/drive/1Ys44kVvmeZtnICzWz0xgpRnrIOjZAuxp?usp=sharing) | 2.4x faster | 58% less |
44
+ | **Phi-3.5 (mini)** | [▶️ Start on Colab](https://colab.research.google.com/drive/1lN6hPQveB_mHSnTOYifygFcrO8C1bxq4?usp=sharing) | 2x faster | 50% less |
45
+ | **Gemma-2 9b** | [▶️ Start on Colab](https://colab.research.google.com/drive/1vIrqH5uYDQwsJ4-OO3DErvuv4pBgVwk4?usp=sharing) | 2.4x faster | 58% less |
46
+
47
+ ## Llama 3.1 Storm
48
+
49
+ ![image/jpeg](https://cdn-uploads.huggingface.co/production/uploads/64c75c1237333ccfef30a602/tmOlbERGKP7JSODa6T06J.jpeg)
50
+
51
+ Authors: [Ashvini Kumar Jindal](https://www.linkedin.com/in/ashvini-jindal-26653262/), [Pawan Kumar Rajpoot](https://www.linkedin.com/in/pawanrajpoot/), [Ankur Parikh](https://www.linkedin.com/in/ankurnlpexpert/), [Akshita Sukhlecha](https://www.linkedin.com/in/akshita-sukhlecha/)
52
+
53
+ **🤗 Hugging Face Announcement Blog**: https://huggingface.co/blog/akjindal53244/llama31-storm8b
54
+
55
+ **🚀Ollama:** `ollama run ajindal/llama3.1-storm:8b`
56
+
57
+
58
+ ## TL;DR
59
+
60
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/64c75c1237333ccfef30a602/mDtDeiHwnBupw1k_n99Lf.png)
61
+
62
+ We present the [**Llama-3.1-Storm-8B**](https://huggingface.co/akjindal53244/Llama-3.1-Storm-8B) model that outperforms Meta AI's [Llama-3.1-8B-Instruct](https://huggingface.co/meta-llama/Meta-Llama-3.1-8B-Instruct) and [Hermes-3-Llama-3.1-8B](https://huggingface.co/NousResearch/Hermes-3-Llama-3.1-8B) models significantly across diverse benchmarks as shown in the performance comparison plot in the next section. Our approach consists of three key steps:
63
+ 1. **Self-Curation**: We applied two self-curation methods to select approximately 1 million high-quality examples from a pool of ~2.8 million open-source examples. **Our curation criteria focused on educational value and difficulty level, using the same SLM for annotation instead of larger models (e.g. 70B, 405B).**
64
+ 2. **Targeted fine-tuning**: We performed [Spectrum](https://arxiv.org/abs/2406.06623)-based targeted fine-tuning over the Llama-3.1-8B-Instruct model. The Spectrum method accelerates training by selectively targeting layer modules based on their signal-to-noise ratio (SNR), and freezing the remaining modules. In our work, 50% of layers are frozen.
65
+ 3. **Model Merging**: We merged our fine-tuned model with the [Llama-Spark](https://huggingface.co/arcee-ai/Llama-Spark) model using [SLERP](https://huggingface.co/blog/mlabonne/merge-models#1-slerp) method. The merging method produces a blended model with characteristics smoothly interpolated from both parent models, ensuring the resultant model captures the essence of both its parents. [Llama-3.1-Storm-8B](https://huggingface.co/akjindal53244/Llama-3.1-Storm-8B) improves Llama-3.1-8B-Instruct across 10 diverse benchmarks. These benchmarks cover areas such as instruction-following, knowledge-driven QA, reasoning, truthful answer generation, and function calling.
66
+
67
+ ## 🏆 Introducing Llama-3.1-Storm-8B
68
+ [**Llama-3.1-Storm-8B**](https://huggingface.co/akjindal53244/Llama-3.1-Storm-8B) builds upon the foundation of Llama-3.1-8B-Instruct, aiming to enhance both conversational and function calling capabilities within the 8B parameter model class.
69
+
70
+ As shown in the left subplot of the above figure, [**Llama-3.1-Storm-8B**](https://huggingface.co/akjindal53244/Llama-3.1-Storm-8B) model improves Meta-Llama-3.1-8B-Instruct across various benchmarks - Instruction-following ([IFEval](https://arxiv.org/abs/2311.07911)), Knowledge-driven QA benchmarks ([GPQA](https://arxiv.org/abs/2311.12022), [MMLU-Pro](https://arxiv.org/pdf/2406.01574)), Reasoning ([ARC-C](https://arxiv.org/abs/1803.05457), [MuSR](https://arxiv.org/abs/2310.16049), [BBH](https://arxiv.org/pdf/2210.09261)), Reduced Hallucinations ([TruthfulQA](https://arxiv.org/abs/2109.07958)), and Function-Calling ([BFCL](https://huggingface.co/datasets/gorilla-llm/Berkeley-Function-Calling-Leaderboard)). This improvement is particularly significant for AI developers and enthusiasts who work with limited computational resources.
71
+
72
+ We also benchmarked our model with the recently published model [Hermes-3-Llama-3.1-8B](https://huggingface.co/NousResearch/Hermes-3-Llama-3.1-8B) built on top of the Llama-3.1-8B-Instruct model. As shown in the right subplot of the above figure, **Llama-3.1-Storm-8B outperforms Hermes-3-Llama-3.1-8B on 7 out of 9 benchmarks**, with Hermes-3-Llama-3.1-8B surpassing Llama-3.1-Storm-8B on the MuSR benchmark and both models showing comparable performance on the BBH benchmark.
73
+
74
+
75
+ ## Llama-3.1-Storm-8B Model Strengths
76
+ Llama-3.1-Storm-8B is a powerful generalist model useful for diverse applications. We invite the AI community to explore [Llama-3.1-Storm-8B](https://huggingface.co/collections/akjindal53244/storm-66ba6c96b7e24ecb592787a9) and look forward to seeing how it will be utilized in various projects and applications.
77
+
78
+ <table>
79
+ <tr>
80
+ <td><strong>Model Strength</strong>
81
+ </td>
82
+ <td><strong>Relevant Benchmarks</strong>
83
+ </td>
84
+ <tr>
85
+ <tr>
86
+ <td>🎯 Improved Instruction Following
87
+ </td>
88
+ <td>IFEval Strict (+3.93%)
89
+ </td>
90
+ <tr>
91
+ <tr>
92
+ <td>🌐 Enhanced Knowledge Driven Question Answering
93
+ </td>
94
+ <td>GPQA (+7.21%), MMLU-Pro (+0.55%), AGIEval (+3.77%)
95
+ </td>
96
+ <tr>
97
+ <tr>
98
+ <td>🧠 Better Reasoning
99
+ </td>
100
+ <td>ARC-C (+3.92%), MuSR (+2.77%), BBH (+1.67%), AGIEval (+3.77%)
101
+ </td>
102
+ <tr>
103
+ <tr>
104
+ <td>🤖 Superior Agentic Capabilities
105
+ </td>
106
+ <td>BFCL: Overall Acc (+7.92%), BFCL: AST Summary (+12.32%)
107
+ </td>
108
+ <tr>
109
+ <tr>
110
+ <td>🚫 Reduced Hallucinations
111
+ </td>
112
+ <td>TruthfulQA (+9%)
113
+ </td>
114
+ <tr>
115
+ </table>
116
+
117
+ **Note**: All improvements are absolute gains over Meta-Llama-3.1-8B-Instruct.
118
+
119
+
120
+ ## Llama-3.1-Storm-8B Models
121
+ 1. `BF16`: [Llama-3.1-Storm-8B](https://huggingface.co/akjindal53244/Llama-3.1-Storm-8B)
122
+ 2. ⚡ `FP8`: [Llama-3.1-Storm-8B-FP8-Dynamic](https://huggingface.co/akjindal53244/Llama-3.1-Storm-8B-FP8-Dynamic)
123
+ 3. ⚡ `GGUF`: [Llama-3.1-Storm-8B-GGUF](https://huggingface.co/akjindal53244/Llama-3.1-Storm-8B-GGUF)
124
+ 4. 🚀 Ollama: `ollama run ajindal/llama3.1-storm:8b`
125
+
126
+
127
+ ## 💻 How to Use the Model
128
+ The Hugging Face `transformers` library loads the model in `bfloat16` by default. This is the type used by the [Llama-3.1-Storm-8B](https://huggingface.co/akjindal53244/Llama-3.1-Storm-8B) checkpoint, so it’s the recommended way to run to ensure the best results.
129
+
130
+ ### Installation
131
+ ```bash
132
+ pip install --upgrade "transformers>=4.43.2" torch==2.3.1 accelerate vllm==0.5.3.post1
133
+ ```
134
+
135
+ Developers can easily integrate Llama-3.1-Storm-8B into their projects using popular libraries like Transformers and vLLM. The following sections illustrate the usage with simple hands-on examples:
136
+
137
+ ### Conversational Use-case
138
+ #### Use with [🤗 Transformers](https://github.com/huggingface/transformers)
139
+ ##### Using `transformers.pipeline()` API
140
+ ```python
141
+ import transformers
142
+ import torch
143
+
144
+ model_id = "akjindal53244/Llama-3.1-Storm-8B"
145
+ pipeline = transformers.pipeline(
146
+ "text-generation",
147
+ model=model_id,
148
+ model_kwargs={"torch_dtype": torch.bfloat16},
149
+ device_map="auto",
150
+ )
151
+
152
+ messages = [
153
+ {"role": "system", "content": "You are a helpful assistant."},
154
+ {"role": "user", "content": "What is 2+2?"}
155
+ ]
156
+
157
+ outputs = pipeline(messages, max_new_tokens=128, do_sample=True, temperature=0.01, top_k=100, top_p=0.95)
158
+ print(outputs[0]["generated_text"][-1]) # Expected Output: {'role': 'assistant', 'content': '2 + 2 = 4'}
159
+ ```
160
+
161
+ ##### Using `model.generate()` API
162
+ ```bash
163
+ pip install flash_attn==2.6.3
164
+ ```
165
+
166
+ ```python
167
+ import torch
168
+ from transformers import AutoTokenizer, LlamaForCausalLM
169
+
170
+ # Apply Llama3.1 chat-template
171
+ def format_prompt(user_query):
172
+ template = """<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are a helpful assistant.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\n{}<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n"""
173
+ return template.format(user_query)
174
+
175
+
176
+ model_id = 'akjindal53244/Llama-3.1-Storm-8B'
177
+ tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
178
+ model = LlamaForCausalLM.from_pretrained(
179
+ model_id,
180
+ torch_dtype=torch.bfloat16,
181
+ device_map="auto",
182
+ load_in_8bit=False,
183
+ load_in_4bit=False,
184
+ use_flash_attention_2=True
185
+ )
186
+
187
+ # Build final input prompt after applying chat-template
188
+ prompt = format_prompt("What is 2+2?")
189
+
190
+ input_ids = tokenizer(prompt, return_tensors="pt").input_ids.to("cuda")
191
+ generated_ids = model.generate(input_ids, max_new_tokens=128, temperature=0.01, do_sample=True, eos_token_id=tokenizer.eos_token_id)
192
+ response = tokenizer.decode(generated_ids[0][input_ids.shape[-1]:], skip_special_tokens=True)
193
+ print(response) # Expected Output: '2 + 2 = 4'
194
+ ```
195
+
196
+ #### Use with [vLLM](https://github.com/vllm-project/vllm)
197
+ ```python
198
+ from vllm import LLM, SamplingParams
199
+ from transformers import AutoTokenizer
200
+
201
+ model_id = "akjindal53244/Llama-3.1-Storm-8B" # FP8 model: "akjindal53244/Llama-3.1-Storm-8B-FP8-Dynamic"
202
+ num_gpus = 1
203
+
204
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
205
+ llm = LLM(model=model_id, tensor_parallel_size=num_gpus)
206
+ sampling_params = SamplingParams(max_tokens=128, temperature=0.01, top_k=100, top_p=0.95)
207
+
208
+ messages = [
209
+ {"role": "system", "content": "You are a helpful assistant."},
210
+ {"role": "user", "content": "What is 2+2?"}
211
+ ]
212
+ prompt = tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize = False)
213
+ print(llm.generate([prompt], sampling_params)[0].outputs[0].text.strip()) # Expected Output: 2 + 2 = 4
214
+ ```
215
+
216
+ #### Use with [LitGPT](https://github.com/Lightning-AI/litgpt)
217
+ ```bash
218
+ pip install 'litgpt[all]'
219
+ litgpt download akjindal53244/Llama-3.1-Storm-8B --model_name meta-llama/Meta-Llama-3.1-8B
220
+ ```
221
+
222
+ ```python
223
+ from litgpt import LLM
224
+
225
+ llm = LLM.load(model="akjindal53244/Llama-3.1-Storm-8B")
226
+ llm.generate("What do Llamas eat?")
227
+ ```
228
+
229
+ ### Function Calling Use-case
230
+
231
+ [**Llama-3.1-Storm-8B**](https://huggingface.co/collections/akjindal53244/storm-66ba6c96b7e24ecb592787a9) has impressive function calling capabilities compared to Meta-Llama-3.1-8B-Instruct as demonstrated by the BFCL benchmark.
232
+
233
+ #### Prompt Format for Function Calling
234
+ Llama-3.1-Storm-8B is trained with specific system prompt for Function Calling:
235
+ ```
236
+ You are a function calling AI model. You may call one or more functions to assist with the user query. Don't make assumptions about what values to plug into function. The user may use the terms function calling or tool use interchangeably.
237
+
238
+ Here are the available functions:
239
+ <tools>LIST_OF_TOOLS</tools>
240
+
241
+ For each function call return a json object with function name and arguments within <tool_call></tool_call> XML tags in the format:
242
+ <tool_call>{"tool_name": <function-name>, "tool_arguments": <args-dict>}</tool_call>
243
+ ```
244
+ Above system prompt should be used with passing `LIST_OF_TOOLS` as input.
245
+
246
+
247
+ #### Use with [vLLM](https://github.com/vllm-project/vllm)
248
+ ```python
249
+ import json
250
+ from vllm import LLM, SamplingParams
251
+ from transformers import AutoTokenizer
252
+
253
+ model_id = "akjindal53244/Llama-3.1-Storm-8B" # FP8 model: "akjindal53244/Llama-3.1-Storm-8B-FP8-Dynamic"
254
+ num_gpus = 1
255
+
256
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
257
+ llm = LLM(model=model_id, tensor_parallel_size=num_gpus)
258
+ sampling_params = SamplingParams(max_tokens=128, temperature=0.01, top_k=100, top_p=0.95)
259
+
260
+
261
+ def create_system_prompt(tools_list):
262
+ system_prompt_format = """You are a function calling AI model. You may call one or more functions to assist with the user query. Don't make assumptions about what values to plug into function. The user may use the terms function calling or tool use interchangeably.
263
+
264
+ Here are the available functions:
265
+ <tools>{}</tools>
266
+
267
+ For each function call return a json object with function name and arguments within <tool_call></tool_call> XML tags in the format:
268
+ <tool_call>{"tool_name": <function-name>, "tool_arguments": <args-dict>}</tool_call>"""
269
+
270
+ # Convert the tools list to a string representation
271
+ tools_str = json.dumps(tools_list, ensure_ascii=False)
272
+ # Format the system prompt with the tools list
273
+ system_prompt = system_prompt_format.format(tools_str)
274
+ return system_prompt
275
+
276
+
277
+ # Example tools list
278
+ tools_list = [
279
+ {
280
+ "name": "peers",
281
+ "description": "Retrieves a list of company peers given a stock symbol.",
282
+ "parameters": {
283
+ "symbol": {
284
+ "description": "The stock symbol for the company.",
285
+ "type": "str",
286
+ "default": ""
287
+ }
288
+ }
289
+ },
290
+ {
291
+ "name": "web_chain_details",
292
+ "description": "python",
293
+ "parameters": {
294
+ "chain_slug": {
295
+ "description": "The slug identifier for the blockchain (e.g., 'ethereum' for Ethereum mainnet).",
296
+ "type": "str",
297
+ "default": "ethereum"
298
+ }
299
+ }
300
+ }
301
+ ]
302
+
303
+ # Create the system prompt with the tools list
304
+ system_prompt = create_system_prompt(tools_list)
305
+
306
+ messages = [
307
+ {"role": "system", "content": system_prompt},
308
+ {"role": "user", "content": "I need to understand the details of the Ethereum blockchain for my cryptocurrency project. Can you fetch the details for 'ethereum'?"}
309
+ ]
310
+
311
+ prompt = tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize = False)
312
+ print(llm.generate([prompt], sampling_params)[0].outputs[0].text.strip()) # Expected Output: <tool_call>{'tool_name': 'web_chain_details', 'tool_arguments': {'chain_slug': 'ethereum'}}</tool_call>
313
+ ```
314
+
315
+ #### Use with [Ollama](https://ollama.com/)
316
+ ```
317
+ import ollama
318
+
319
+ tools = [{
320
+ 'type': 'function',
321
+ 'function': {
322
+ 'name': 'get_current_weather',
323
+ 'description': 'Get the current weather for a city',
324
+ 'parameters': {
325
+ 'type': 'object',
326
+ 'properties': {
327
+ 'city': {
328
+ 'type': 'string',
329
+ 'description': 'The name of the city',
330
+ },
331
+ },
332
+ 'required': ['city'],
333
+ },
334
+ },
335
+ },
336
+ {
337
+ 'type': 'function',
338
+ 'function': {
339
+ 'name': 'get_places_to_vist',
340
+ 'description': 'Get places to visit in a city',
341
+ 'parameters': {
342
+ 'type': 'object',
343
+ 'properties': {
344
+ 'city': {
345
+ 'type': 'string',
346
+ 'description': 'The name of the city',
347
+ },
348
+ },
349
+ 'required': ['city'],
350
+ },
351
+ },
352
+ },
353
+ ]
354
+
355
+ response = ollama.chat(
356
+ model='ajindal/llama3.1-storm:8b',
357
+ messages=[
358
+ {'role': 'system', 'content': 'Do not answer to nay vulgar questions.'},
359
+ {'role': 'user', 'content': 'What is the weather in Toronto and San Francisco?'}
360
+ ],
361
+ tools=tools
362
+ )
363
+
364
+ print(response['message']) # Expected Response: {'role': 'assistant', 'content': "<tool_call>{'tool_name': 'get_current_weather', 'tool_arguments': {'city': 'Toronto'}}</tool_call>"}
365
+ ```
366
+
367
+
368
+ ## Alignment Note
369
+ While **Llama-3.1-Storm-8B** did not undergo an explicit model alignment process, it may still retain some alignment properties inherited from the Meta-Llama-3.1-8B-Instruct model.
370
+
371
+ ## Cite Our Work
372
+ ```
373
+ @misc {ashvini_kumar_jindal_2024,
374
+ author = { {Ashvini Kumar Jindal, Pawan Kumar Rajpoot, Ankur Parikh, Akshita Sukhlecha} },
375
+ title = { Llama-3.1-Storm-8B },
376
+ year = 2024,
377
+ url = { https://huggingface.co/akjindal53244/Llama-3.1-Storm-8B },
378
+ doi = { 10.57967/hf/2902 },
379
+ publisher = { Hugging Face }
380
+ }
381
+ ```
382
+
383
+ ## Support Our Work
384
+ With 3 team-members spanned across 3 different time-zones, we have won [NeurIPS LLM Efficiency Challenge 2023](https://llm-efficiency-challenge.github.io/) and 4 other competitions in Finance and Arabic LLM space. We have also published [SOTA mathematical reasoning model](https://huggingface.co/akjindal53244/Arithmo-Mistral-7B).
385
+
386
+ **Llama-3.1-Storm-8B** is our most valuable contribution so far towards the open-source community. We are committed in developing efficient generalist LLMs. **We're seeking both computational resources and innovative collaborators to drive this initiative forward.**
387
+