RichardErkhov commited on
Commit
9f5eaff
·
verified ·
1 Parent(s): 0e175a8

uploaded readme

Browse files
Files changed (1) hide show
  1. README.md +317 -0
README.md ADDED
@@ -0,0 +1,317 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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-FP8-Dynamic - bnb 8bits
11
+ - Model creator: https://huggingface.co/akjindal53244/
12
+ - Original model: https://huggingface.co/akjindal53244/Llama-3.1-Storm-8B-FP8-Dynamic/
13
+
14
+
15
+
16
+
17
+ Original model description:
18
+ ---
19
+ language:
20
+ - en
21
+ - de
22
+ - fr
23
+ - it
24
+ - pt
25
+ - hi
26
+ - es
27
+ - th
28
+ pipeline_tag: text-generation
29
+ tags:
30
+ - llama-3.1
31
+ - fp8
32
+ - conversational
33
+ - instruction following
34
+ - reasoning
35
+ - function calling
36
+ license: llama3.1
37
+ ---
38
+
39
+ ![image/jpeg](https://cdn-uploads.huggingface.co/production/uploads/64c75c1237333ccfef30a602/tmOlbERGKP7JSODa6T06J.jpeg)
40
+
41
+ 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/)
42
+
43
+ **🤗 Hugging Face Announcement Blog**: https://huggingface.co/blog/akjindal53244/llama31-storm8b
44
+
45
+ **🚀Ollama:** `ollama run ajindal/llama3.1-storm:8b`
46
+
47
+ <br>
48
+
49
+ # Llama-3.1-Storm-8B-FP8-Dynamic
50
+ ## Model Optimizations
51
+ This model was obtained by quantizing the weights and activations of [Llama-3.1-Storm-8B](https://huggingface.co/akjindal53244/Llama-3.1-Storm-8B) to FP8 data type using [this script](https://github.com/vllm-project/llm-compressor/tree/main/examples/quantization_w8a8_fp8), ready for inference with vLLM. This optimization reduces the number of bits per parameter from 16 to 8, reducing the disk size and GPU memory requirements by approximately 50%.
52
+
53
+ Only the weights and activations of the linear operators within transformers blocks are quantized. Symmetric per-tensor quantization is applied, in which a single linear scaling maps the FP8 representations of the quantized weights and activations. LLM Compressor is used for quantization with 512 sequences of UltraChat.
54
+
55
+ ## TL;DR
56
+
57
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/64c75c1237333ccfef30a602/mDtDeiHwnBupw1k_n99Lf.png)
58
+
59
+ 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:
60
+ 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).**
61
+ 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.
62
+ 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.
63
+
64
+ ## 🏆 Introducing Llama-3.1-Storm-8B
65
+ [**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.
66
+
67
+ 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.
68
+
69
+ 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.
70
+
71
+
72
+ ## Llama-3.1-Storm-8B Model Strengths
73
+ 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.
74
+
75
+ <table>
76
+ <tr>
77
+ <td><strong>Model Strength</strong>
78
+ </td>
79
+ <td><strong>Relevant Benchmarks</strong>
80
+ </td>
81
+ <tr>
82
+ <tr>
83
+ <td>🎯 Improved Instruction Following
84
+ </td>
85
+ <td>IFEval Strict (+3.93%)
86
+ </td>
87
+ <tr>
88
+ <tr>
89
+ <td>🌐 Enhanced Knowledge Driven Question Answering
90
+ </td>
91
+ <td>GPQA (+7.21%), MMLU-Pro (+0.55%), AGIEval (+3.77%)
92
+ </td>
93
+ <tr>
94
+ <tr>
95
+ <td>🧠 Better Reasoning
96
+ </td>
97
+ <td>ARC-C (+3.92%), MuSR (+2.77%), BBH (+1.67%), AGIEval (+3.77%)
98
+ </td>
99
+ <tr>
100
+ <tr>
101
+ <td>🤖 Superior Agentic Capabilities
102
+ </td>
103
+ <td>BFCL: Overall Acc (+7.92%), BFCL: AST Summary (+12.32%)
104
+ </td>
105
+ <tr>
106
+ <tr>
107
+ <td>🚫 Reduced Hallucinations
108
+ </td>
109
+ <td>TruthfulQA (+9%)
110
+ </td>
111
+ <tr>
112
+ </table>
113
+
114
+ **Note**: All improvements are absolute gains over Meta-Llama-3.1-8B-Instruct.
115
+
116
+
117
+ ## Llama-3.1-Storm-8B Models
118
+ 1. `BF16`: [Llama-3.1-Storm-8B](https://huggingface.co/akjindal53244/Llama-3.1-Storm-8B)
119
+ 2. ⚡ `FP8`: [Llama-3.1-Storm-8B-FP8-Dynamic](https://huggingface.co/akjindal53244/Llama-3.1-Storm-8B-FP8-Dynamic)
120
+ 3. ⚡ `GGUF`: [Llama-3.1-Storm-8B-GGUF](https://huggingface.co/akjindal53244/Llama-3.1-Storm-8B-GGUF)
121
+ 4. 🚀 Ollama: `ollama run ajindal/llama3.1-storm:8b`
122
+
123
+
124
+
125
+ ## 💻 How to Use the FP8 Model
126
+ ### Installation
127
+ ```bash
128
+ pip install --upgrade "transformers>=4.43.2" torch==2.3.1 accelerate vllm==0.5.3.post1
129
+ ```
130
+
131
+ 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:
132
+
133
+ ### Conversational Use-case
134
+ #### Use with [vLLM](https://github.com/vllm-project/vllm)
135
+ ```python
136
+ from vllm import LLM, SamplingParams
137
+ from transformers import AutoTokenizer
138
+
139
+ model_id = "akjindal53244/Llama-3.1-Storm-8B" # FP8 model: "akjindal53244/Llama-3.1-Storm-8B-FP8-Dynamic"
140
+ num_gpus = 1
141
+
142
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
143
+ llm = LLM(model=model_id, tensor_parallel_size=num_gpus)
144
+ sampling_params = SamplingParams(max_tokens=128, temperature=0.01, top_k=100, top_p=0.95)
145
+
146
+ messages = [
147
+ {"role": "system", "content": "You are a helpful assistant."},
148
+ {"role": "user", "content": "What is 2+2?"}
149
+ ]
150
+ prompt = tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize = False)
151
+ print(llm.generate([prompt], sampling_params)[0].outputs[0].text.strip()) # Expected Output: 2 + 2 = 4
152
+ ```
153
+
154
+ ### Function Calling Use-case
155
+
156
+ [**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.
157
+
158
+ #### Prompt Format for Function Calling
159
+ Llama-3.1-Storm-8B is trained with specific system prompt for Function Calling:
160
+ ```
161
+ 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.
162
+
163
+ Here are the available functions:
164
+ <tools>LIST_OF_TOOLS</tools>
165
+
166
+ For each function call return a json object with function name and arguments within <tool_call></tool_call> XML tags in the format:
167
+ <tool_call>{"tool_name": <function-name>, "tool_arguments": <args-dict>}</tool_call>
168
+ ```
169
+ Above system prompt should be used with passing `LIST_OF_TOOLS` as input.
170
+
171
+
172
+ #### Use with [vLLM](https://github.com/vllm-project/vllm)
173
+ ```python
174
+ import json
175
+ from vllm import LLM, SamplingParams
176
+ from transformers import AutoTokenizer
177
+
178
+ model_id = "akjindal53244/Llama-3.1-Storm-8B-FP8-Dynamic"
179
+ num_gpus = 1
180
+
181
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
182
+ llm = LLM(model=model_id, tensor_parallel_size=num_gpus)
183
+ sampling_params = SamplingParams(max_tokens=128, temperature=0.01, top_k=100, top_p=0.95)
184
+
185
+
186
+ def create_system_prompt(tools_list):
187
+ 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.
188
+
189
+ Here are the available functions:
190
+ <tools>{}</tools>
191
+
192
+ For each function call return a json object with function name and arguments within <tool_call></tool_call> XML tags in the format:
193
+ <tool_call>{"tool_name": <function-name>, "tool_arguments": <args-dict>}</tool_call>"""
194
+
195
+ # Convert the tools list to a string representation
196
+ tools_str = json.dumps(tools_list, ensure_ascii=False)
197
+ # Format the system prompt with the tools list
198
+ system_prompt = system_prompt_format.format(tools_str)
199
+ return system_prompt
200
+
201
+
202
+ # Example tools list
203
+ tools_list = [
204
+ {
205
+ "name": "peers",
206
+ "description": "Retrieves a list of company peers given a stock symbol.",
207
+ "parameters": {
208
+ "symbol": {
209
+ "description": "The stock symbol for the company.",
210
+ "type": "str",
211
+ "default": ""
212
+ }
213
+ }
214
+ },
215
+ {
216
+ "name": "web_chain_details",
217
+ "description": "python",
218
+ "parameters": {
219
+ "chain_slug": {
220
+ "description": "The slug identifier for the blockchain (e.g., 'ethereum' for Ethereum mainnet).",
221
+ "type": "str",
222
+ "default": "ethereum"
223
+ }
224
+ }
225
+ }
226
+ ]
227
+
228
+ # Create the system prompt with the tools list
229
+ system_prompt = create_system_prompt(tools_list)
230
+
231
+ messages = [
232
+ {"role": "system", "content": system_prompt},
233
+ {"role": "user", "content": "I need to understand the details of the Ethereum blockchain for my cryptocurrency project. Can you fetch the details for 'ethereum'?"}
234
+ ]
235
+
236
+ prompt = tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize = False)
237
+ 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>
238
+ ```
239
+
240
+ #### Use with [Ollama](https://ollama.com/)
241
+ ```
242
+ import ollama
243
+
244
+ tools = [{
245
+ 'type': 'function',
246
+ 'function': {
247
+ 'name': 'get_current_weather',
248
+ 'description': 'Get the current weather for a city',
249
+ 'parameters': {
250
+ 'type': 'object',
251
+ 'properties': {
252
+ 'city': {
253
+ 'type': 'string',
254
+ 'description': 'The name of the city',
255
+ },
256
+ },
257
+ 'required': ['city'],
258
+ },
259
+ },
260
+ },
261
+ {
262
+ 'type': 'function',
263
+ 'function': {
264
+ 'name': 'get_places_to_vist',
265
+ 'description': 'Get places to visit in a city',
266
+ 'parameters': {
267
+ 'type': 'object',
268
+ 'properties': {
269
+ 'city': {
270
+ 'type': 'string',
271
+ 'description': 'The name of the city',
272
+ },
273
+ },
274
+ 'required': ['city'],
275
+ },
276
+ },
277
+ },
278
+ ]
279
+
280
+ response = ollama.chat(
281
+ model='ajindal/llama3.1-storm:8b',
282
+ messages=[
283
+ {'role': 'system', 'content': 'Do not answer to nay vulgar questions.'},
284
+ {'role': 'user', 'content': 'What is the weather in Toronto and San Francisco?'}
285
+ ],
286
+ tools=tools
287
+ )
288
+
289
+ print(response['message']) # Expected Response: {'role': 'assistant', 'content': "<tool_call>{'tool_name': 'get_current_weather', 'tool_arguments': {'city': 'Toronto'}}</tool_call>"}
290
+ ```
291
+
292
+
293
+ ## Alignment Note
294
+ 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.
295
+
296
+
297
+ ## Acknowledgement
298
+ We thank [Robert Shaw](https://www.linkedin.com/in/robert-shaw-1a01399a/) from [Neural Magic](https://neuralmagic.com/) for providing guidance during FP8 model conversion.
299
+
300
+
301
+ ## Cite Our Work
302
+ ```
303
+ @misc {ashvini_kumar_jindal_2024,
304
+ author = { {Ashvini Kumar Jindal, Pawan Kumar Rajpoot, Ankur Parikh, Akshita Sukhlecha} },
305
+ title = { Llama-3.1-Storm-8B },
306
+ year = 2024,
307
+ url = { https://huggingface.co/akjindal53244/Llama-3.1-Storm-8B },
308
+ doi = { 10.57967/hf/2902 },
309
+ publisher = { Hugging Face }
310
+ }
311
+ ```
312
+
313
+ ## Support Our Work
314
+ 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).
315
+
316
+ **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.**
317
+