HoneyBadger2989 commited on
Commit
e07bb44
1 Parent(s): 41e9ea5

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ llama-3.1-storm-8b.Q2_K.gguf filter=lfs diff=lfs merge=lfs -text
37
+ llama-3.1-storm-8b.bf16.gguf filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,364 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ - de
5
+ - fr
6
+ - it
7
+ - pt
8
+ - hi
9
+ - es
10
+ - th
11
+ library_name: transformers
12
+ license: llama3.1
13
+ pipeline_tag: text-generation
14
+ tags:
15
+ - llama-3.1
16
+ - conversational
17
+ - instruction following
18
+ - reasoning
19
+ - function calling
20
+ - mergekit
21
+ - finetuning
22
+ - axolotl
23
+ - autoquant
24
+ - gguf
25
+ ---
26
+
27
+ ![image/jpeg](https://cdn-uploads.huggingface.co/production/uploads/64c75c1237333ccfef30a602/tmOlbERGKP7JSODa6T06J.jpeg)
28
+
29
+ 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/)
30
+
31
+ **🤗 Hugging Face Announcement Blog**: https://huggingface.co/blog/akjindal53244/llama31-storm8b
32
+
33
+ **🚀Ollama:** `ollama run ajindal/llama3.1-storm:8b`
34
+
35
+
36
+ ## TL;DR
37
+
38
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/64c75c1237333ccfef30a602/mDtDeiHwnBupw1k_n99Lf.png)
39
+
40
+ 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:
41
+ 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).**
42
+ 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.
43
+ 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.
44
+
45
+ ## 🏆 Introducing Llama-3.1-Storm-8B
46
+ [**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.
47
+
48
+ 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.
49
+
50
+ 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.
51
+
52
+
53
+ ## Llama-3.1-Storm-8B Model Strengths
54
+ 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.
55
+
56
+ <table>
57
+ <tr>
58
+ <td><strong>Model Strength</strong>
59
+ </td>
60
+ <td><strong>Relevant Benchmarks</strong>
61
+ </td>
62
+ <tr>
63
+ <tr>
64
+ <td>🎯 Improved Instruction Following
65
+ </td>
66
+ <td>IFEval Strict (+3.93%)
67
+ </td>
68
+ <tr>
69
+ <tr>
70
+ <td>🌐 Enhanced Knowledge Driven Question Answering
71
+ </td>
72
+ <td>GPQA (+7.21%), MMLU-Pro (+0.55%), AGIEval (+3.77%)
73
+ </td>
74
+ <tr>
75
+ <tr>
76
+ <td>🧠 Better Reasoning
77
+ </td>
78
+ <td>ARC-C (+3.92%), MuSR (+2.77%), BBH (+1.67%), AGIEval (+3.77%)
79
+ </td>
80
+ <tr>
81
+ <tr>
82
+ <td>🤖 Superior Agentic Capabilities
83
+ </td>
84
+ <td>BFCL: Overall Acc (+7.92%), BFCL: AST Summary (+12.32%)
85
+ </td>
86
+ <tr>
87
+ <tr>
88
+ <td>🚫 Reduced Hallucinations
89
+ </td>
90
+ <td>TruthfulQA (+9%)
91
+ </td>
92
+ <tr>
93
+ </table>
94
+
95
+ **Note**: All improvements are absolute gains over Meta-Llama-3.1-8B-Instruct.
96
+
97
+
98
+ ## Llama-3.1-Storm-8B Models
99
+ 1. `BF16`: [Llama-3.1-Storm-8B](https://huggingface.co/akjindal53244/Llama-3.1-Storm-8B)
100
+ 2. ⚡ `FP8`: [Llama-3.1-Storm-8B-FP8-Dynamic](https://huggingface.co/akjindal53244/Llama-3.1-Storm-8B-FP8-Dynamic)
101
+ 3. ⚡ `GGUF`: [Llama-3.1-Storm-8B-GGUF](https://huggingface.co/akjindal53244/Llama-3.1-Storm-8B-GGUF)
102
+ 4. 🚀 Ollama: `ollama run ajindal/llama3.1-storm:8b`
103
+
104
+
105
+ ## 💻 How to Use the Model
106
+ 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.
107
+
108
+ ### Installation
109
+ ```bash
110
+ pip install --upgrade "transformers>=4.43.2" torch==2.3.1 accelerate vllm==0.5.3.post1
111
+ ```
112
+
113
+ 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:
114
+
115
+ ### Conversational Use-case
116
+ #### Use with [🤗 Transformers](https://github.com/huggingface/transformers)
117
+ ##### Using `transformers.pipeline()` API
118
+ ```python
119
+ import transformers
120
+ import torch
121
+
122
+ model_id = "akjindal53244/Llama-3.1-Storm-8B"
123
+ pipeline = transformers.pipeline(
124
+ "text-generation",
125
+ model=model_id,
126
+ model_kwargs={"torch_dtype": torch.bfloat16},
127
+ device_map="auto",
128
+ )
129
+
130
+ messages = [
131
+ {"role": "system", "content": "You are a helpful assistant."},
132
+ {"role": "user", "content": "What is 2+2?"}
133
+ ]
134
+
135
+ outputs = pipeline(messages, max_new_tokens=128, do_sample=True, temperature=0.01, top_k=100, top_p=0.95)
136
+ print(outputs[0]["generated_text"][-1]) # Expected Output: {'role': 'assistant', 'content': '2 + 2 = 4'}
137
+ ```
138
+
139
+ ##### Using `model.generate()` API
140
+ ```bash
141
+ pip install flash_attn==2.6.3
142
+ ```
143
+
144
+ ```python
145
+ import torch
146
+ from transformers import AutoTokenizer, LlamaForCausalLM
147
+
148
+ # Apply Llama3.1 chat-template
149
+ def format_prompt(user_query):
150
+ 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"""
151
+ return template.format(user_query)
152
+
153
+
154
+ model_id = 'akjindal53244/Llama-3.1-Storm-8B'
155
+ tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
156
+ model = LlamaForCausalLM.from_pretrained(
157
+ model_id,
158
+ torch_dtype=torch.bfloat16,
159
+ device_map="auto",
160
+ load_in_8bit=False,
161
+ load_in_4bit=False,
162
+ use_flash_attention_2=True
163
+ )
164
+
165
+ # Build final input prompt after applying chat-template
166
+ prompt = format_prompt("What is 2+2?")
167
+
168
+ input_ids = tokenizer(prompt, return_tensors="pt").input_ids.to("cuda")
169
+ generated_ids = model.generate(input_ids, max_new_tokens=128, temperature=0.01, do_sample=True, eos_token_id=tokenizer.eos_token_id)
170
+ response = tokenizer.decode(generated_ids[0][input_ids.shape[-1]:], skip_special_tokens=True)
171
+ print(response) # Expected Output: '2 + 2 = 4'
172
+ ```
173
+
174
+ #### Use with [vLLM](https://github.com/vllm-project/vllm)
175
+ ```python
176
+ from vllm import LLM, SamplingParams
177
+ from transformers import AutoTokenizer
178
+
179
+ model_id = "akjindal53244/Llama-3.1-Storm-8B" # FP8 model: "akjindal53244/Llama-3.1-Storm-8B-FP8-Dynamic"
180
+ num_gpus = 1
181
+
182
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
183
+ llm = LLM(model=model_id, tensor_parallel_size=num_gpus)
184
+ sampling_params = SamplingParams(max_tokens=128, temperature=0.01, top_k=100, top_p=0.95)
185
+
186
+ messages = [
187
+ {"role": "system", "content": "You are a helpful assistant."},
188
+ {"role": "user", "content": "What is 2+2?"}
189
+ ]
190
+ prompt = tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize = False)
191
+ print(llm.generate([prompt], sampling_params)[0].outputs[0].text.strip()) # Expected Output: 2 + 2 = 4
192
+ ```
193
+
194
+ #### Use with [LitGPT](https://github.com/Lightning-AI/litgpt)
195
+ ```bash
196
+ pip install 'litgpt[all]'
197
+ litgpt download akjindal53244/Llama-3.1-Storm-8B --model_name meta-llama/Meta-Llama-3.1-8B
198
+ ```
199
+
200
+ ```python
201
+ from litgpt import LLM
202
+
203
+ llm = LLM.load(model="akjindal53244/Llama-3.1-Storm-8B")
204
+ llm.generate("What do Llamas eat?")
205
+ ```
206
+
207
+ ### Function Calling Use-case
208
+
209
+ [**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.
210
+
211
+ #### Prompt Format for Function Calling
212
+ Llama-3.1-Storm-8B is trained with specific system prompt for Function Calling:
213
+ ```
214
+ 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.
215
+
216
+ Here are the available functions:
217
+ <tools>LIST_OF_TOOLS</tools>
218
+
219
+ For each function call return a json object with function name and arguments within <tool_call></tool_call> XML tags in the format:
220
+ <tool_call>{"tool_name": <function-name>, "tool_arguments": <args-dict>}</tool_call>
221
+ ```
222
+ Above system prompt should be used with passing `LIST_OF_TOOLS` as input.
223
+
224
+
225
+ #### Use with [vLLM](https://github.com/vllm-project/vllm)
226
+ ```python
227
+ import json
228
+ from vllm import LLM, SamplingParams
229
+ from transformers import AutoTokenizer
230
+
231
+ model_id = "akjindal53244/Llama-3.1-Storm-8B" # FP8 model: "akjindal53244/Llama-3.1-Storm-8B-FP8-Dynamic"
232
+ num_gpus = 1
233
+
234
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
235
+ llm = LLM(model=model_id, tensor_parallel_size=num_gpus)
236
+ sampling_params = SamplingParams(max_tokens=128, temperature=0.01, top_k=100, top_p=0.95)
237
+
238
+
239
+ def create_system_prompt(tools_list):
240
+ 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.
241
+
242
+ Here are the available functions:
243
+ <tools>{}</tools>
244
+
245
+ For each function call return a json object with function name and arguments within <tool_call></tool_call> XML tags in the format:
246
+ <tool_call>{"tool_name": <function-name>, "tool_arguments": <args-dict>}</tool_call>"""
247
+
248
+ # Convert the tools list to a string representation
249
+ tools_str = json.dumps(tools_list, ensure_ascii=False)
250
+ # Format the system prompt with the tools list
251
+ system_prompt = system_prompt_format.format(tools_str)
252
+ return system_prompt
253
+
254
+
255
+ # Example tools list
256
+ tools_list = [
257
+ {
258
+ "name": "peers",
259
+ "description": "Retrieves a list of company peers given a stock symbol.",
260
+ "parameters": {
261
+ "symbol": {
262
+ "description": "The stock symbol for the company.",
263
+ "type": "str",
264
+ "default": ""
265
+ }
266
+ }
267
+ },
268
+ {
269
+ "name": "web_chain_details",
270
+ "description": "python",
271
+ "parameters": {
272
+ "chain_slug": {
273
+ "description": "The slug identifier for the blockchain (e.g., 'ethereum' for Ethereum mainnet).",
274
+ "type": "str",
275
+ "default": "ethereum"
276
+ }
277
+ }
278
+ }
279
+ ]
280
+
281
+ # Create the system prompt with the tools list
282
+ system_prompt = create_system_prompt(tools_list)
283
+
284
+ messages = [
285
+ {"role": "system", "content": system_prompt},
286
+ {"role": "user", "content": "I need to understand the details of the Ethereum blockchain for my cryptocurrency project. Can you fetch the details for 'ethereum'?"}
287
+ ]
288
+
289
+ prompt = tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize = False)
290
+ 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>
291
+ ```
292
+
293
+ #### Use with [Ollama](https://ollama.com/)
294
+ ```
295
+ import ollama
296
+
297
+ tools = [{
298
+ 'type': 'function',
299
+ 'function': {
300
+ 'name': 'get_current_weather',
301
+ 'description': 'Get the current weather for a city',
302
+ 'parameters': {
303
+ 'type': 'object',
304
+ 'properties': {
305
+ 'city': {
306
+ 'type': 'string',
307
+ 'description': 'The name of the city',
308
+ },
309
+ },
310
+ 'required': ['city'],
311
+ },
312
+ },
313
+ },
314
+ {
315
+ 'type': 'function',
316
+ 'function': {
317
+ 'name': 'get_places_to_vist',
318
+ 'description': 'Get places to visit in a city',
319
+ 'parameters': {
320
+ 'type': 'object',
321
+ 'properties': {
322
+ 'city': {
323
+ 'type': 'string',
324
+ 'description': 'The name of the city',
325
+ },
326
+ },
327
+ 'required': ['city'],
328
+ },
329
+ },
330
+ },
331
+ ]
332
+
333
+ response = ollama.chat(
334
+ model='ajindal/llama3.1-storm:8b',
335
+ messages=[
336
+ {'role': 'system', 'content': 'Do not answer to nay vulgar questions.'},
337
+ {'role': 'user', 'content': 'What is the weather in Toronto and San Francisco?'}
338
+ ],
339
+ tools=tools
340
+ )
341
+
342
+ print(response['message']) # Expected Response: {'role': 'assistant', 'content': "<tool_call>{'tool_name': 'get_current_weather', 'tool_arguments': {'city': 'Toronto'}}</tool_call>"}
343
+ ```
344
+
345
+
346
+ ## Alignment Note
347
+ 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.
348
+
349
+ ## Cite Our Work
350
+ ```
351
+ @misc {ashvini_kumar_jindal_2024,
352
+ author = { {Ashvini Kumar Jindal, Pawan Kumar Rajpoot, Ankur Parikh, Akshita Sukhlecha} },
353
+ title = { Llama-3.1-Storm-8B },
354
+ year = 2024,
355
+ url = { https://huggingface.co/akjindal53244/Llama-3.1-Storm-8B },
356
+ doi = { 10.57967/hf/2902 },
357
+ publisher = { Hugging Face }
358
+ }
359
+ ```
360
+
361
+ ## Support Our Work
362
+ 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).
363
+
364
+ **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.**
llama-3.1-storm-8b.Q2_K.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:647103d3ee021ed423106b647c0132e10190d00fec48b602caa428e72ca265d8
3
+ size 3179132128
llama-3.1-storm-8b.bf16.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d3fbbde17fb44ac4db4cde36051974ed355ce1944198ff0ba24e5e9a489f9830
3
+ size 16068891872