GGUF
GGUF
Inference Endpoints
andrijdavid commited on
Commit
d188c90
·
verified ·
1 Parent(s): 9ace571

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -33,3 +33,20 @@ 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
+ Q2_K/Q2_K-00001-of-00001.gguf filter=lfs diff=lfs merge=lfs -text
37
+ Q3_K/Q3_K-00001-of-00001.gguf filter=lfs diff=lfs merge=lfs -text
38
+ Q3_K_L/Q3_K_L-00001-of-00001.gguf filter=lfs diff=lfs merge=lfs -text
39
+ Q3_K_M/Q3_K_M-00001-of-00001.gguf filter=lfs diff=lfs merge=lfs -text
40
+ Q3_K_S/Q3_K_S-00001-of-00001.gguf filter=lfs diff=lfs merge=lfs -text
41
+ Q4_0/Q4_0-00001-of-00001.gguf filter=lfs diff=lfs merge=lfs -text
42
+ Q4_1/Q4_1-00001-of-00001.gguf filter=lfs diff=lfs merge=lfs -text
43
+ Q4_K/Q4_K-00001-of-00001.gguf filter=lfs diff=lfs merge=lfs -text
44
+ Q4_K_M/Q4_K_M-00001-of-00001.gguf filter=lfs diff=lfs merge=lfs -text
45
+ Q4_K_S/Q4_K_S-00001-of-00001.gguf filter=lfs diff=lfs merge=lfs -text
46
+ Q5_0/Q5_0-00001-of-00001.gguf filter=lfs diff=lfs merge=lfs -text
47
+ Q5_1/Q5_1-00001-of-00001.gguf filter=lfs diff=lfs merge=lfs -text
48
+ Q5_K/Q5_K-00001-of-00001.gguf filter=lfs diff=lfs merge=lfs -text
49
+ Q5_K_M/Q5_K_M-00001-of-00001.gguf filter=lfs diff=lfs merge=lfs -text
50
+ Q5_K_S/Q5_K_S-00001-of-00001.gguf filter=lfs diff=lfs merge=lfs -text
51
+ Q6_K/Q6_K-00001-of-00001.gguf filter=lfs diff=lfs merge=lfs -text
52
+ Q8_0/Q8_0-00001-of-00001.gguf filter=lfs diff=lfs merge=lfs -text
Q2_K/Q2_K-00001-of-00001.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3a3b43ddbc613a69859c8dd942ebbef353a3520dd5666177f3474555b1204df4
3
+ size 423612480
Q3_K/Q3_K-00001-of-00001.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3ebb83c87cd54cac4ed63f31d03df844e3d0cdefb6545d8a613d31862322d01b
3
+ size 555561024
Q3_K_L/Q3_K_L-00001-of-00001.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:783543583e4637872a5c8f74224a13b3cb93de7db202f1e1eb93405b8ec3e3fa
3
+ size 599404608
Q3_K_M/Q3_K_M-00001-of-00001.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3ebb83c87cd54cac4ed63f31d03df844e3d0cdefb6545d8a613d31862322d01b
3
+ size 555561024
Q3_K_S/Q3_K_S-00001-of-00001.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f06f25b3b563e9375830a18605e70d6fa5e7476c04c478b10021619ee93496ec
3
+ size 490784832
Q4_0/Q4_0-00001-of-00001.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:493d9646c3692ba46d31c9f9169ec06f4445f4053bb67e4d5da77b495c0cf311
3
+ size 625487936
Q4_1/Q4_1-00001-of-00001.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:51d3ee35f607fbac4d27b2115c8918f1e1f43c0b86b7632f2eade33bb9a2da38
3
+ size 688877632
Q4_K/Q4_K-00001-of-00001.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:42ac276b9ee3fae88a0de111b0e638afc51fc528b5db3bbcc28c20fcec1adf78
3
+ size 672919616
Q4_K_M/Q4_K_M-00001-of-00001.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:42ac276b9ee3fae88a0de111b0e638afc51fc528b5db3bbcc28c20fcec1adf78
3
+ size 672919616
Q4_K_S/Q4_K_S-00001-of-00001.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:90240429af4462ca2dcfa8d157e99f270cb97cd4e54bc4fd69579ebf1a666ebb
3
+ size 626995264
Q5_0/Q5_0-00001-of-00001.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:90ec801cf97cb93c3af9c5c2cc6fedcd82be1fccab3b391d21f74b4e75eab99a
3
+ size 752267328
Q5_1/Q5_1-00001-of-00001.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fcf9d682aaad99693a24ef7d934214fa0d384510043613a9b69447f613346ddc
3
+ size 815657024
Q5_K/Q5_K-00001-of-00001.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e62491eec739491e33cb3e4e1885dcf03b34146c4371a8483e20ef1b2b993efb
3
+ size 785795136
Q5_K_M/Q5_K_M-00001-of-00001.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e62491eec739491e33cb3e4e1885dcf03b34146c4371a8483e20ef1b2b993efb
3
+ size 785795136
Q5_K_S/Q5_K_S-00001-of-00001.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:784e59552a004eccb226d2bc160225778cee1e758fe5d17072459092dc54e6d3
3
+ size 752267328
Q6_K/Q6_K-00001-of-00001.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fb672f969ef6aa6b0c2605e5c22f509722aaa1e865562454b15d91d62080d669
3
+ size 886970432
Q8_0/Q8_0-00001-of-00001.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:13dc6676b2355d0356d7892d8b34d8518233d79a28f9ea1d14f94e81d7decad5
3
+ size 1148477504
README.md ADDED
@@ -0,0 +1,361 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ tags:
4
+ - GGUF
5
+ license_name: apple-sample-code-license
6
+ license_link: LICENSE
7
+ quantized_by: andrijdavid
8
+ ---
9
+ # OpenELM-1_1B-Instruct-GGUF
10
+ - Original model: [OpenELM-1_1B-Instruct](https://huggingface.co/apple/OpenELM-1_1B-Instruct)
11
+
12
+ <!-- description start -->
13
+ ## Description
14
+
15
+ This repo contains GGUF format model files for [OpenELM-1_1B-Instruct](https://huggingface.co/apple/OpenELM-1_1B-Instruct).
16
+
17
+ <!-- description end -->
18
+ <!-- README_GGUF.md-about-gguf start -->
19
+ ### About GGUF
20
+ GGUF is a new format introduced by the llama.cpp team on August 21st 2023. It is a replacement for GGML, which is no longer supported by llama.cpp.
21
+ Here is an incomplete list of clients and libraries that are known to support GGUF:
22
+ * [llama.cpp](https://github.com/ggerganov/llama.cpp). This is the source project for GGUF, providing both a Command Line Interface (CLI) and a server option.
23
+ * [text-generation-webui](https://github.com/oobabooga/text-generation-webui), Known as the most widely used web UI, this project boasts numerous features and powerful extensions, and supports GPU acceleration.
24
+ * [Ollama](https://github.com/jmorganca/ollama) Ollama is a lightweight and extensible framework designed for building and running language models locally. It features a simple API for creating, managing, and executing models, along with a library of pre-built models for use in various applications​
25
+ * [KoboldCpp](https://github.com/LostRuins/koboldcpp), A comprehensive web UI offering GPU acceleration across all platforms and architectures, particularly renowned for storytelling.
26
+ * [GPT4All](https://gpt4all.io), This is a free and open source GUI that runs locally, supporting Windows, Linux, and macOS with full GPU acceleration.
27
+ * [LM Studio](https://lmstudio.ai/) An intuitive and powerful local GUI for Windows and macOS (Silicon), featuring GPU acceleration.
28
+ * [LoLLMS Web UI](https://github.com/ParisNeo/lollms-webui). A notable web UI with a variety of unique features, including a comprehensive model library for easy model selection.
29
+ * [Faraday.dev](https://faraday.dev/), An attractive, user-friendly character-based chat GUI for Windows and macOS (both Silicon and Intel), also offering GPU acceleration.
30
+ * [llama-cpp-python](https://github.com/abetlen/llama-cpp-python), A Python library equipped with GPU acceleration, LangChain support, and an OpenAI-compatible API server.
31
+ * [candle](https://github.com/huggingface/candle), A Rust-based ML framework focusing on performance, including GPU support, and designed for ease of use.
32
+ * [ctransformers](https://github.com/marella/ctransformers), A Python library featuring GPU acceleration, LangChain support, and an OpenAI-compatible AI server.
33
+ * [localGPT](https://github.com/PromtEngineer/localGPT) An open-source initiative enabling private conversations with documents.
34
+ <!-- README_GGUF.md-about-gguf end -->
35
+
36
+ <!-- compatibility_gguf start -->
37
+ ## Explanation of quantisation methods
38
+ <details>
39
+ <summary>Click to see details</summary>
40
+ The new methods available are:
41
+
42
+ * GGML_TYPE_Q2_K - "type-1" 2-bit quantization in super-blocks containing 16 blocks, each block having 16 weight. Block scales and mins are quantized with 4 bits. This ends up effectively using 2.5625 bits per weight (bpw)
43
+ * GGML_TYPE_Q3_K - "type-0" 3-bit quantization in super-blocks containing 16 blocks, each block having 16 weights. Scales are quantized with 6 bits. This end up using 3.4375 bpw.
44
+ * GGML_TYPE_Q4_K - "type-1" 4-bit quantization in super-blocks containing 8 blocks, each block having 32 weights. Scales and mins are quantized with 6 bits. This ends up using 4.5 bpw.
45
+ * GGML_TYPE_Q5_K - "type-1" 5-bit quantization. Same super-block structure as GGML_TYPE_Q4_K resulting in 5.5 bpw
46
+ * GGML_TYPE_Q6_K - "type-0" 6-bit quantization. Super-blocks with 16 blocks, each block having 16 weights. Scales are quantized with 8 bits. This ends up using 6.5625 bpw.
47
+ </details>
48
+ <!-- compatibility_gguf end -->
49
+
50
+ <!-- README_GGUF.md-how-to-download start -->
51
+ ## How to download GGUF files
52
+
53
+ **Note for manual downloaders:** You almost never want to clone the entire repo! Multiple different quantisation formats are provided, and most users only want to pick and download a single folder.
54
+
55
+ The following clients/libraries will automatically download models for you, providing a list of available models to choose from:
56
+
57
+ * LM Studio
58
+ * LoLLMS Web UI
59
+ * Faraday.dev
60
+
61
+ ### In `text-generation-webui`
62
+
63
+ Under Download Model, you can enter the model repo: LiteLLMs/OpenELM-1_1B-Instruct-GGUF and below it, a specific filename to download, such as: Q4_0/Q4_0-00001-of-00001.gguf.
64
+
65
+ Then click Download.
66
+
67
+ ### On the command line, including multiple files at once
68
+
69
+ I recommend using the `huggingface-hub` Python library:
70
+
71
+ ```shell
72
+ pip3 install huggingface-hub
73
+ ```
74
+
75
+ Then you can download any individual model file to the current directory, at high speed, with a command like this:
76
+
77
+ ```shell
78
+ huggingface-cli download LiteLLMs/OpenELM-1_1B-Instruct-GGUF Q4_0/Q4_0-00001-of-00001.gguf --local-dir . --local-dir-use-symlinks False
79
+ ```
80
+
81
+ <details>
82
+ <summary>More advanced huggingface-cli download usage (click to read)</summary>
83
+
84
+ You can also download multiple files at once with a pattern:
85
+
86
+ ```shell
87
+ huggingface-cli download LiteLLMs/OpenELM-1_1B-Instruct-GGUF --local-dir . --local-dir-use-symlinks False --include='*Q4_K*gguf'
88
+ ```
89
+
90
+ For more documentation on downloading with `huggingface-cli`, please see: [HF -> Hub Python Library -> Download files -> Download from the CLI](https://huggingface.co/docs/huggingface_hub/guides/download#download-from-the-cli).
91
+
92
+ To accelerate downloads on fast connections (1Gbit/s or higher), install `hf_transfer`:
93
+
94
+ ```shell
95
+ pip3 install huggingface_hub[hf_transfer]
96
+ ```
97
+
98
+ And set environment variable `HF_HUB_ENABLE_HF_TRANSFER` to `1`:
99
+
100
+ ```shell
101
+ HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download LiteLLMs/OpenELM-1_1B-Instruct-GGUF Q4_0/Q4_0-00001-of-00001.gguf --local-dir . --local-dir-use-symlinks False
102
+ ```
103
+
104
+ Windows Command Line users: You can set the environment variable by running `set HF_HUB_ENABLE_HF_TRANSFER=1` before the download command.
105
+ </details>
106
+ <!-- README_GGUF.md-how-to-download end -->
107
+ <!-- README_GGUF.md-how-to-run start -->
108
+ ## Example `llama.cpp` command
109
+
110
+ Make sure you are using `llama.cpp` from commit [d0cee0d](https://github.com/ggerganov/llama.cpp/commit/d0cee0d36d5be95a0d9088b674dbb27354107221) or later.
111
+
112
+ ```shell
113
+ ./main -ngl 35 -m Q4_0/Q4_0-00001-of-00001.gguf --color -c 2048 --temp 0.7 --repeat_penalty 1.1 -n -1 -p "<PROMPT>"
114
+ ```
115
+
116
+ Change `-ngl 32` to the number of layers to offload to GPU. Remove it if you don't have GPU acceleration.
117
+
118
+ Change `-c 2048` to the desired sequence length. For extended sequence models - eg 8K, 16K, 32K - the necessary RoPE scaling parameters are read from the GGUF file and set by llama.cpp automatically. Note that longer sequence lengths require much more resources, so you may need to reduce this value.
119
+
120
+ If you want to have a chat-style conversation, replace the `-p <PROMPT>` argument with `-i -ins`
121
+
122
+ For other parameters and how to use them, please refer to [the llama.cpp documentation](https://github.com/ggerganov/llama.cpp/blob/master/examples/main/README.md)
123
+
124
+ ## How to run in `text-generation-webui`
125
+
126
+ Further instructions can be found in the text-generation-webui documentation, here: [text-generation-webui/docs/04 ‐ Model Tab.md](https://github.com/oobabooga/text-generation-webui/blob/main/docs/04%20%E2%80%90%20Model%20Tab.md#llamacpp).
127
+
128
+ ## How to run from Python code
129
+
130
+ You can use GGUF models from Python using the [llama-cpp-python](https://github.com/abetlen/llama-cpp-python) or [ctransformers](https://github.com/marella/ctransformers) libraries. Note that at the time of writing (Nov 27th 2023), ctransformers has not been updated for some time and is not compatible with some recent models. Therefore I recommend you use llama-cpp-python.
131
+
132
+ ### How to load this model in Python code, using llama-cpp-python
133
+
134
+ For full documentation, please see: [llama-cpp-python docs](https://abetlen.github.io/llama-cpp-python/).
135
+
136
+ #### First install the package
137
+
138
+ Run one of the following commands, according to your system:
139
+
140
+ ```shell
141
+ # Base ctransformers with no GPU acceleration
142
+ pip install llama-cpp-python
143
+ # With NVidia CUDA acceleration
144
+ CMAKE_ARGS="-DLLAMA_CUBLAS=on" pip install llama-cpp-python
145
+ # Or with OpenBLAS acceleration
146
+ CMAKE_ARGS="-DLLAMA_BLAS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS" pip install llama-cpp-python
147
+ # Or with CLBLast acceleration
148
+ CMAKE_ARGS="-DLLAMA_CLBLAST=on" pip install llama-cpp-python
149
+ # Or with AMD ROCm GPU acceleration (Linux only)
150
+ CMAKE_ARGS="-DLLAMA_HIPBLAS=on" pip install llama-cpp-python
151
+ # Or with Metal GPU acceleration for macOS systems only
152
+ CMAKE_ARGS="-DLLAMA_METAL=on" pip install llama-cpp-python
153
+ # In windows, to set the variables CMAKE_ARGS in PowerShell, follow this format; eg for NVidia CUDA:
154
+ $env:CMAKE_ARGS = "-DLLAMA_OPENBLAS=on"
155
+ pip install llama-cpp-python
156
+ ```
157
+
158
+ #### Simple llama-cpp-python example code
159
+
160
+ ```python
161
+ from llama_cpp import Llama
162
+ # Set gpu_layers to the number of layers to offload to GPU. Set to 0 if no GPU acceleration is available on your system.
163
+ llm = Llama(
164
+ model_path="./Q4_0/Q4_0-00001-of-00001.gguf", # Download the model file first
165
+ n_ctx=32768, # The max sequence length to use - note that longer sequence lengths require much more resources
166
+ n_threads=8, # The number of CPU threads to use, tailor to your system and the resulting performance
167
+ n_gpu_layers=35 # The number of layers to offload to GPU, if you have GPU acceleration available
168
+ )
169
+ # Simple inference example
170
+ output = llm(
171
+ "<PROMPT>", # Prompt
172
+ max_tokens=512, # Generate up to 512 tokens
173
+ stop=["</s>"], # Example stop token - not necessarily correct for this specific model! Please check before using.
174
+ echo=True # Whether to echo the prompt
175
+ )
176
+ # Chat Completion API
177
+ llm = Llama(model_path="./Q4_0/Q4_0-00001-of-00001.gguf", chat_format="llama-2") # Set chat_format according to the model you are using
178
+ llm.create_chat_completion(
179
+ messages = [
180
+ {"role": "system", "content": "You are a story writing assistant."},
181
+ {
182
+ "role": "user",
183
+ "content": "Write a story about llamas."
184
+ }
185
+ ]
186
+ )
187
+ ```
188
+
189
+ ## How to use with LangChain
190
+
191
+ Here are guides on using llama-cpp-python and ctransformers with LangChain:
192
+
193
+ * [LangChain + llama-cpp-python](https://python.langchain.com/docs/integrations/llms/llamacpp)
194
+ * [LangChain + ctransformers](https://python.langchain.com/docs/integrations/providers/ctransformers)
195
+
196
+ <!-- README_GGUF.md-how-to-run end -->
197
+
198
+ <!-- footer end -->
199
+
200
+ <!-- original-model-card start -->
201
+ # Original model card: OpenELM-1_1B-Instruct
202
+
203
+
204
+ # OpenELM
205
+
206
+ *Sachin Mehta, Mohammad Hossein Sekhavat, Qingqing Cao, Maxwell Horton, Yanzi Jin, Chenfan Sun, Iman Mirzadeh, Mahyar Najibi, Dmitry Belenko, Peter Zatloukal, Mohammad Rastegari*
207
+
208
+ We introduce **OpenELM**, a family of **Open** **E**fficient **L**anguage **M**odels. OpenELM uses a layer-wise scaling strategy to efficiently allocate parameters within each layer of the transformer model, leading to enhanced accuracy. We pretrained OpenELM models using the [CoreNet](https://github.com/apple/corenet) library. We release both pretrained and instruction tuned models with 270M, 450M, 1.1B and 3B parameters.
209
+
210
+ Our pre-training dataset contains RefinedWeb, deduplicated PILE, a subset of RedPajama, and a subset of Dolma v1.6, totaling approximately 1.8 trillion tokens. Please check license agreements and terms of these datasets before using them.
211
+
212
+
213
+
214
+ ## Usage
215
+
216
+ We have provided an example function to generate output from OpenELM models loaded via [HuggingFace Hub](https://huggingface.co/docs/hub/) in `generate_openelm.py`.
217
+
218
+ You can try the model by running the following command:
219
+ ```
220
+ python generate_openelm.py --model apple/OpenELM-1_1B-Instruct --hf_access_token [HF_ACCESS_TOKEN] --prompt 'Once upon a time there was' --generate_kwargs repetition_penalty=1.2
221
+ ```
222
+ Please refer to [this link](https://huggingface.co/docs/hub/security-tokens) to obtain your hugging face access token.
223
+
224
+ Additional arguments to the hugging face generate function can be passed via `generate_kwargs`. As an example, to speedup the inference, you can try [lookup token speculative generation](https://huggingface.co/docs/transformers/generation_strategies) by passing the `prompt_lookup_num_tokens` argument as follows:
225
+ ```
226
+ python generate_openelm.py --model apple/OpenELM-1_1B-Instruct --hf_access_token [HF_ACCESS_TOKEN] --prompt 'Once upon a time there was' --generate_kwargs repetition_penalty=1.2 prompt_lookup_num_tokens=10
227
+ ```
228
+ Alternatively, try model-wise speculative generation with an [assistive model](https://huggingface.co/blog/assisted-generation) by passing a smaller model through the `assistant_model` argument, for example:
229
+ ```
230
+ python generate_openelm.py --model apple/OpenELM-1_1B-Instruct --hf_access_token [HF_ACCESS_TOKEN] --prompt 'Once upon a time there was' --generate_kwargs repetition_penalty=1.2 --assistant_model [SMALLER_MODEL]
231
+ ```
232
+
233
+ ## Main Results
234
+
235
+ ### Zero-Shot
236
+
237
+ | **Model Size** | **ARC-c** | **ARC-e** | **BoolQ** | **HellaSwag** | **PIQA** | **SciQ** | **WinoGrande** | **Average** |
238
+ | | | - | | -- | | | -- | -- | | | - | | -- |
239
+ | [OpenELM-270M](https://huggingface.co/apple/OpenELM-270M) | 27.65 | **66.79** | 47.15 | 25.72 | 69.75 | 30.91 | **39.24** | **53.83** | 45.13 |
240
+ | [OpenELM-270M-Instruct](https://huggingface.co/apple/OpenELM-270M-Instruct) | **32.51** | 66.01 | **51.58** | **26.70** | **70.78** | 33.78 | 38.72 | 53.20 | **46.66** |
241
+ | [OpenELM-450M](https://huggingface.co/apple/OpenELM-450M) | 30.20 | **68.63** | 53.86 | **26.01** | 72.31 | 33.11 | 40.18 | 57.22 | 47.69 |
242
+ | [OpenELM-450M-Instruct](https://huggingface.co/apple/OpenELM-450M-Instruct) | **33.53** | 67.44 | **59.31** | 25.41 | **72.63** | **36.84** | **40.48** | **58.33** | **49.25** |
243
+ | [OpenELM-1_1B](https://huggingface.co/apple/OpenELM-1_1B) | 36.69 | **71.74** | 65.71 | **27.05** | **75.57** | 36.46 | 36.98 | 63.22 | 51.68 |
244
+ | [OpenELM-1_1B-Instruct](https://huggingface.co/apple/OpenELM-1_1B-Instruct) | **41.55** | 71.02 | **71.83** | 25.65 | 75.03 | **39.43** | **45.95** | **64.72** | **54.40** |
245
+ | [OpenELM-3B](https://huggingface.co/apple/OpenELM-3B) | 42.24 | **73.29** | 73.28 | **26.76** | 78.24 | **38.76** | 34.98 | 67.25 | 54.35 |
246
+ | [OpenELM-3B-Instruct](https://huggingface.co/apple/OpenELM-3B-Instruct) | **47.70** | 72.33 | **76.87** | 24.80 | **79.00** | 38.47 | **38.76** | **67.96** | **55.73** |
247
+
248
+ See the technical report for more results and comparison.
249
+
250
+ ## Evaluation
251
+
252
+ ### Setup
253
+
254
+ Install the following dependencies:
255
+
256
+ ```bash
257
+
258
+ # install public lm-eval-harness
259
+
260
+ harness_repo="public-lm-eval-harness"
261
+ git clone https://github.com/EleutherAI/lm-evaluation-harness ${harness_repo}
262
+ cd ${harness_repo}
263
+ # use main branch on 03-15-2024, SHA is dc90fec
264
+ git checkout dc90fec
265
+ pip install -e .
266
+ cd ..
267
+
268
+ # 66d6242 is the main branch on 2024-04-01
269
+ pip install datasets@git+https://github.com/huggingface/datasets.git@66d6242
270
+ pip install tokenizers>=0.15.2 transformers>=4.38.2 sentencepiece>=0.2.0
271
+
272
+ ```
273
+
274
+ ### Evaluate OpenELM
275
+
276
+ ```bash
277
+
278
+ # OpenELM-1_1B-Instruct
279
+ hf_model=apple/OpenELM-1_1B-Instruct
280
+
281
+ # this flag is needed because lm-eval-harness set add_bos_token to False by default, but OpenELM uses LLaMA tokenizer which requires add_bos_token to be True
282
+ tokenizer=meta-llama/Llama-2-7b-hf
283
+ add_bos_token=True
284
+ batch_size=1
285
+
286
+ mkdir lm_eval_output
287
+
288
+ shot=0
289
+ task=arc_challenge,arc_easy,boolq,hellaswag,piqa,race,winogrande,sciq,truthfulqa_mc2
290
+ lm_eval --model hf \
291
+ --model_args pretrained=${hf_model},trust_remote_code=True,add_bos_token=${add_bos_token},tokenizer=${tokenizer} \
292
+ --tasks ${task} \
293
+ --device cuda:0 \
294
+ --num_fewshot ${shot} \
295
+ --output_path ./lm_eval_output/${hf_model//\//_}_${task//,/_}-${shot}shot \
296
+ --batch_size ${batch_size} 2>&1 | tee ./lm_eval_output/eval-${hf_model//\//_}_${task//,/_}-${shot}shot.log
297
+
298
+ shot=5
299
+ task=mmlu,winogrande
300
+ lm_eval --model hf \
301
+ --model_args pretrained=${hf_model},trust_remote_code=True,add_bos_token=${add_bos_token},tokenizer=${tokenizer} \
302
+ --tasks ${task} \
303
+ --device cuda:0 \
304
+ --num_fewshot ${shot} \
305
+ --output_path ./lm_eval_output/${hf_model//\//_}_${task//,/_}-${shot}shot \
306
+ --batch_size ${batch_size} 2>&1 | tee ./lm_eval_output/eval-${hf_model//\//_}_${task//,/_}-${shot}shot.log
307
+
308
+ shot=25
309
+ task=arc_challenge,crows_pairs_english
310
+ lm_eval --model hf \
311
+ --model_args pretrained=${hf_model},trust_remote_code=True,add_bos_token=${add_bos_token},tokenizer=${tokenizer} \
312
+ --tasks ${task} \
313
+ --device cuda:0 \
314
+ --num_fewshot ${shot} \
315
+ --output_path ./lm_eval_output/${hf_model//\//_}_${task//,/_}-${shot}shot \
316
+ --batch_size ${batch_size} 2>&1 | tee ./lm_eval_output/eval-${hf_model//\//_}_${task//,/_}-${shot}shot.log
317
+
318
+ shot=10
319
+ task=hellaswag
320
+ lm_eval --model hf \
321
+ --model_args pretrained=${hf_model},trust_remote_code=True,add_bos_token=${add_bos_token},tokenizer=${tokenizer} \
322
+ --tasks ${task} \
323
+ --device cuda:0 \
324
+ --num_fewshot ${shot} \
325
+ --output_path ./lm_eval_output/${hf_model//\//_}_${task//,/_}-${shot}shot \
326
+ --batch_size ${batch_size} 2>&1 | tee ./lm_eval_output/eval-${hf_model//\//_}_${task//,/_}-${shot}shot.log
327
+
328
+ ```
329
+
330
+
331
+ ## Bias, Risks, and Limitations
332
+
333
+ The release of OpenELM models aims to empower and enrich the open research community by providing access to state-of-the-art language models. Trained on publicly available datasets, these models are made available without any safety guarantees. Consequently, there exists the possibility of these models producing outputs that are inaccurate, harmful, biased, or objectionable in response to user prompts. Thus, it is imperative for users and developers to undertake thorough safety testing and implement appropriate filtering mechanisms tailored to their specific requirements.
334
+
335
+ ## Citation
336
+
337
+ If you find our work useful, please cite:
338
+
339
+ ```BibTex
340
+ @article{mehtaOpenELMEfficientLanguage2024,
341
+ title = {{OpenELM}: {An} {Efficient} {Language} {Model} {Family} with {Open} {Training} and {Inference} {Framework}},
342
+ shorttitle = {{OpenELM}},
343
+ url = {https://arxiv.org/abs/2404.14619v1},
344
+ language = {en},
345
+ urldate = {2024-04-24},
346
+ journal = {arXiv.org},
347
+ author = {Mehta, Sachin and Sekhavat, Mohammad Hossein and Cao, Qingqing and Horton, Maxwell and Jin, Yanzi and Sun, Chenfan and Mirzadeh, Iman and Najibi, Mahyar and Belenko, Dmitry and Zatloukal, Peter and Rastegari, Mohammad},
348
+ month = apr,
349
+ year = {2024},
350
+ }
351
+
352
+ @inproceedings{mehta2022cvnets,
353
+ author = {Mehta, Sachin and Abdolhosseini, Farzad and Rastegari, Mohammad},
354
+ title = {CVNets: High Performance Library for Computer Vision},
355
+ year = {2022},
356
+ booktitle = {Proceedings of the 30th ACM International Conference on Multimedia},
357
+ series = {MM '22}
358
+ }
359
+ ```
360
+
361
+ <!-- original-model-card end -->