andrijdavid commited on
Commit
456e3b4
1 Parent(s): 908d893

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:166878392686dd0c7835adc5852405fae1b3a15106d10e7b6066826691faa5ca
3
+ size 3481447040
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:cfad5aaed620510b2faa705966fb7e49b70dc7d8ad27d2e0b4a41d37c0fc8261
3
+ size 4369328768
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:b96d07b20691db3c2dfb7cbc7b3bccb81e29051c5adc4a3eef9e051c74d4b5a6
3
+ size 4709067392
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:cfad5aaed620510b2faa705966fb7e49b70dc7d8ad27d2e0b4a41d37c0fc8261
3
+ size 4369328768
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:650d69b1560654d83073281ce14c4f61f9cabbe700afa2a903c0f5b95e809b54
3
+ size 3982404224
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:55d215595733a2a7d59c0592695f8bd017accd6b14dfe2f13aa9d18b135766da
3
+ size 5011843712
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:f360c29575580c3efc3f5c7c659c8eb8c04328fd8edc4371625710ed1c5bbba2
3
+ size 5496285824
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:e6dfd0ff3e9ddd6e070d077848abed7b282de4708b27e5c9e43d564132cbf9e1
3
+ size 5329758848
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:e6dfd0ff3e9ddd6e070d077848abed7b282de4708b27e5c9e43d564132cbf9e1
3
+ size 5329758848
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:d18fd4e4bb9a5622d5a803d999de8deccddea4a1d2a032cd3e56bb8a9c4939b1
3
+ size 5046446720
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:a882fff2508b43651ff671f74398e08ab93bbca23340b5cb5f74a16cf2d1d29d
3
+ size 5980727936
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:48410b6598d129604721b1fcae8de9c86215f1337093fcc488f9c99861d8c5e0
3
+ size 6465170048
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:451a38e2f5cdaa0f24709ee4884317d62cb05c2dcc20d0fa84ba309258bf1948
3
+ size 6144502400
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:451a38e2f5cdaa0f24709ee4884317d62cb05c2dcc20d0fa84ba309258bf1948
3
+ size 6144502400
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:783ee4ebd3a3a000b06d567ec77adef46c6f2fa65cfaa979eb8e0b48cfc738cb
3
+ size 5980727936
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:5b565c349c9a38868314fff847541d3d520454f2d04cfb2ecf0ff44b90fc1dbb
3
+ size 7010167424
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:ccca539825b80557ba5e7fdd49ba284a47f5678f1d00d8f31bafe6a8514d7126
3
+ size 9077844608
README.md ADDED
@@ -0,0 +1,451 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ license: gemma
4
+ license_link: https://ai.google.dev/gemma/terms
5
+ pipeline_tag: text-generation
6
+ tags:
7
+ - GGUF
8
+ extra_gated_heading: Access CodeGemma on Hugging Face
9
+ extra_gated_prompt: To access CodeGemma on Hugging Face, you’re required to review
10
+ and agree to Google’s usage license. To do this, please ensure you’re logged-in
11
+ to Hugging Face and click below. Requests are processed immediately.
12
+ extra_gated_button_content: Acknowledge license
13
+ widget:
14
+ - text: '<start_of_turn>user Write a Python function to calculate the nth fibonacci
15
+ number.<end_of_turn> <start_of_turn>model
16
+
17
+ '
18
+ inference:
19
+ parameters:
20
+ max_new_tokens: 200
21
+ quantized_by: andrijdavid
22
+ ---
23
+ # codegemma-1.1-7b-it-GGUF
24
+ - Original model: [codegemma-1.1-7b-it](https://huggingface.co/google/codegemma-1.1-7b-it)
25
+
26
+ <!-- description start -->
27
+ ## Description
28
+
29
+ This repo contains GGUF format model files for [codegemma-1.1-7b-it](https://huggingface.co/google/codegemma-1.1-7b-it).
30
+
31
+ <!-- description end -->
32
+ <!-- README_GGUF.md-about-gguf start -->
33
+ ### About GGUF
34
+ 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.
35
+ Here is an incomplete list of clients and libraries that are known to support GGUF:
36
+ * [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.
37
+ * [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.
38
+ * [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​
39
+ * [KoboldCpp](https://github.com/LostRuins/koboldcpp), A comprehensive web UI offering GPU acceleration across all platforms and architectures, particularly renowned for storytelling.
40
+ * [GPT4All](https://gpt4all.io), This is a free and open source GUI that runs locally, supporting Windows, Linux, and macOS with full GPU acceleration.
41
+ * [LM Studio](https://lmstudio.ai/) An intuitive and powerful local GUI for Windows and macOS (Silicon), featuring GPU acceleration.
42
+ * [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.
43
+ * [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.
44
+ * [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.
45
+ * [candle](https://github.com/huggingface/candle), A Rust-based ML framework focusing on performance, including GPU support, and designed for ease of use.
46
+ * [ctransformers](https://github.com/marella/ctransformers), A Python library featuring GPU acceleration, LangChain support, and an OpenAI-compatible AI server.
47
+ * [localGPT](https://github.com/PromtEngineer/localGPT) An open-source initiative enabling private conversations with documents.
48
+ <!-- README_GGUF.md-about-gguf end -->
49
+
50
+ <!-- compatibility_gguf start -->
51
+ ## Explanation of quantisation methods
52
+ <details>
53
+ <summary>Click to see details</summary>
54
+ The new methods available are:
55
+
56
+ * 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)
57
+ * 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.
58
+ * 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.
59
+ * GGML_TYPE_Q5_K - "type-1" 5-bit quantization. Same super-block structure as GGML_TYPE_Q4_K resulting in 5.5 bpw
60
+ * 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.
61
+ </details>
62
+ <!-- compatibility_gguf end -->
63
+
64
+ <!-- README_GGUF.md-how-to-download start -->
65
+ ## How to download GGUF files
66
+
67
+ **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.
68
+
69
+ The following clients/libraries will automatically download models for you, providing a list of available models to choose from:
70
+
71
+ * LM Studio
72
+ * LoLLMS Web UI
73
+ * Faraday.dev
74
+
75
+ ### In `text-generation-webui`
76
+
77
+ Under Download Model, you can enter the model repo: LiteLLMs/codegemma-1.1-7b-it-GGUF and below it, a specific filename to download, such as: Q4_0/Q4_0-00001-of-00001.gguf.
78
+
79
+ Then click Download.
80
+
81
+ ### On the command line, including multiple files at once
82
+
83
+ I recommend using the `huggingface-hub` Python library:
84
+
85
+ ```shell
86
+ pip3 install huggingface-hub
87
+ ```
88
+
89
+ Then you can download any individual model file to the current directory, at high speed, with a command like this:
90
+
91
+ ```shell
92
+ huggingface-cli download LiteLLMs/codegemma-1.1-7b-it-GGUF Q4_0/Q4_0-00001-of-00001.gguf --local-dir . --local-dir-use-symlinks False
93
+ ```
94
+
95
+ <details>
96
+ <summary>More advanced huggingface-cli download usage (click to read)</summary>
97
+
98
+ You can also download multiple files at once with a pattern:
99
+
100
+ ```shell
101
+ huggingface-cli download LiteLLMs/codegemma-1.1-7b-it-GGUF --local-dir . --local-dir-use-symlinks False --include='*Q4_K*gguf'
102
+ ```
103
+
104
+ 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).
105
+
106
+ To accelerate downloads on fast connections (1Gbit/s or higher), install `hf_transfer`:
107
+
108
+ ```shell
109
+ pip3 install huggingface_hub[hf_transfer]
110
+ ```
111
+
112
+ And set environment variable `HF_HUB_ENABLE_HF_TRANSFER` to `1`:
113
+
114
+ ```shell
115
+ HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download LiteLLMs/codegemma-1.1-7b-it-GGUF Q4_0/Q4_0-00001-of-00001.gguf --local-dir . --local-dir-use-symlinks False
116
+ ```
117
+
118
+ Windows Command Line users: You can set the environment variable by running `set HF_HUB_ENABLE_HF_TRANSFER=1` before the download command.
119
+ </details>
120
+ <!-- README_GGUF.md-how-to-download end -->
121
+ <!-- README_GGUF.md-how-to-run start -->
122
+ ## Example `llama.cpp` command
123
+
124
+ Make sure you are using `llama.cpp` from commit [d0cee0d](https://github.com/ggerganov/llama.cpp/commit/d0cee0d36d5be95a0d9088b674dbb27354107221) or later.
125
+
126
+ ```shell
127
+ ./main -ngl 35 -m Q4_0/Q4_0-00001-of-00001.gguf --color -c --temp 0.7 --repeat_penalty 1.1 -n -1 -p "<PROMPT>"
128
+ ```
129
+
130
+ Change `-ngl 32` to the number of layers to offload to GPU. Remove it if you don't have GPU acceleration.
131
+
132
+ Change `-c ` 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.
133
+
134
+ If you want to have a chat-style conversation, replace the `-p <PROMPT>` argument with `-i -ins`
135
+
136
+ 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)
137
+
138
+ ## How to run in `text-generation-webui`
139
+
140
+ 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).
141
+
142
+ ## How to run from Python code
143
+
144
+ 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.
145
+
146
+ ### How to load this model in Python code, using llama-cpp-python
147
+
148
+ For full documentation, please see: [llama-cpp-python docs](https://abetlen.github.io/llama-cpp-python/).
149
+
150
+ #### First install the package
151
+
152
+ Run one of the following commands, according to your system:
153
+
154
+ ```shell
155
+ # Base ctransformers with no GPU acceleration
156
+ pip install llama-cpp-python
157
+ # With NVidia CUDA acceleration
158
+ CMAKE_ARGS="-DLLAMA_CUBLAS=on" pip install llama-cpp-python
159
+ # Or with OpenBLAS acceleration
160
+ CMAKE_ARGS="-DLLAMA_BLAS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS" pip install llama-cpp-python
161
+ # Or with CLBLast acceleration
162
+ CMAKE_ARGS="-DLLAMA_CLBLAST=on" pip install llama-cpp-python
163
+ # Or with AMD ROCm GPU acceleration (Linux only)
164
+ CMAKE_ARGS="-DLLAMA_HIPBLAS=on" pip install llama-cpp-python
165
+ # Or with Metal GPU acceleration for macOS systems only
166
+ CMAKE_ARGS="-DLLAMA_METAL=on" pip install llama-cpp-python
167
+ # In windows, to set the variables CMAKE_ARGS in PowerShell, follow this format; eg for NVidia CUDA:
168
+ $env:CMAKE_ARGS = "-DLLAMA_OPENBLAS=on"
169
+ pip install llama-cpp-python
170
+ ```
171
+
172
+ #### Simple llama-cpp-python example code
173
+
174
+ ```python
175
+ from llama_cpp import Llama
176
+ # Set gpu_layers to the number of layers to offload to GPU. Set to 0 if no GPU acceleration is available on your system.
177
+ llm = Llama(
178
+ model_path="./Q4_0/Q4_0-00001-of-00001.gguf", # Download the model file first
179
+ n_ctx=32768, # The max sequence length to use - note that longer sequence lengths require much more resources
180
+ n_threads=8, # The number of CPU threads to use, tailor to your system and the resulting performance
181
+ n_gpu_layers=35 # The number of layers to offload to GPU, if you have GPU acceleration available
182
+ )
183
+ # Simple inference example
184
+ output = llm(
185
+ "<PROMPT>", # Prompt
186
+ max_tokens=512, # Generate up to 512 tokens
187
+ stop=["</s>"], # Example stop token - not necessarily correct for this specific model! Please check before using.
188
+ echo=True # Whether to echo the prompt
189
+ )
190
+ # Chat Completion API
191
+ 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
192
+ llm.create_chat_completion(
193
+ messages = [
194
+ {"role": "system", "content": "You are a story writing assistant."},
195
+ {
196
+ "role": "user",
197
+ "content": "Write a story about llamas."
198
+ }
199
+ ]
200
+ )
201
+ ```
202
+
203
+ ## How to use with LangChain
204
+
205
+ Here are guides on using llama-cpp-python and ctransformers with LangChain:
206
+
207
+ * [LangChain + llama-cpp-python](https://python.langchain.com/docs/integrations/llms/llamacpp)
208
+ * [LangChain + ctransformers](https://python.langchain.com/docs/integrations/providers/ctransformers)
209
+
210
+ <!-- README_GGUF.md-how-to-run end -->
211
+
212
+ <!-- footer end -->
213
+
214
+ <!-- original-model-card start -->
215
+ # Original model card: codegemma-1.1-7b-it
216
+
217
+
218
+ # CodeGemma
219
+
220
+ Model Page
221
+ : [CodeGemma](https://ai.google.dev/gemma/docs/codegemma)
222
+
223
+ Resources and Technical Documentation
224
+ : [Technical Report](https://goo.gle/codegemma)
225
+ : [Responsible Generative AI Toolkit](https://ai.google.dev/responsible)
226
+
227
+ Terms of Use
228
+ : [Terms](https://www.kaggle.com/models/google/codegemma/license/consent/verify/huggingface?returnModelRepoId=google/codegemma-1.1-7b-it)
229
+
230
+ Authors
231
+ : Google
232
+
233
+ ## Model Information
234
+
235
+ Summary description and brief definition of inputs and outputs.
236
+
237
+ ### Description
238
+
239
+ CodeGemma is a collection of lightweight open code models built on top of Gemma. CodeGemma models are text-to-text and text-to-code decoder-only models and are available as a 7 billion pretrained variant that specializes in code completion and code generation tasks, a 7 billion parameter instruction-tuned variant for code chat and instruction following and a 2 billion parameter pretrained variant for fast code completion.
240
+
241
+ | | [ **codegemma-2b** ](https://huggingface.co/google/codegemma-1.1-2b) | [codegemma-7b](https://huggingface.co/google/codegemma-7b) | [codegemma-7b-it](https://huggingface.co/google/codegemma-1.1-7b-it) |
242
+ | -- | :: | :--: | :: |
243
+ | Code Completion | ✅ | ✅ | |
244
+ | Generation from natural language | | ✅ | ✅ |
245
+ | Chat | | | ✅ |
246
+ | Instruction Following | | | ✅ |
247
+
248
+ ### Sample Usage
249
+
250
+ This model is intended to answer questions about code fragments, to generate code from natural language, or to engage in a conversation with the user about programming or technical problems. If you need to use code completion (for example, integrated in an IDE), we recommend you use one of the pre-trained models instead: [CodeGemma 7B](https://huggingface.co/google/codegemma-7b), or [CodeGemma 2B](https://huggingface.co/google/codegemma-2b).
251
+
252
+ #### For Code Generation
253
+
254
+ ```python
255
+ from transformers import GemmaTokenizer, AutoModelForCausalLM
256
+
257
+ tokenizer = GemmaTokenizer.from_pretrained("google/codegemma-1.1-7b-it")
258
+ model = AutoModelForCausalLM.from_pretrained("google/codegemma-1.1-7b-it")
259
+
260
+ input_text = "Write me a Python function to calculate the nth fibonacci number."
261
+ input_ids = tokenizer(input_text, return_tensors="pt")
262
+
263
+ outputs = model.generate(**input_ids)
264
+ print(tokenizer.decode(outputs[0]))
265
+ ```
266
+
267
+ #### Chat Template
268
+
269
+ The instruction-tuned models use a chat template that must be adhered to for conversational use.
270
+ The easiest way to apply it is using the tokenizer's built-in chat template, as shown in the following snippet.
271
+
272
+ Let's load the model and apply the chat template to a conversation. In this example, we'll start with a single user interaction:
273
+
274
+ ```py
275
+ from transformers import AutoTokenizer, AutoModelForCausalLM
276
+ import transformers
277
+ import torch
278
+
279
+ model_id = "google/codegemma-1.1-7b-it"
280
+ dtype = torch.bfloat16
281
+
282
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
283
+ model = AutoModelForCausalLM.from_pretrained(
284
+ model_id,
285
+ device_map="cuda",
286
+ torch_dtype=dtype,
287
+ )
288
+
289
+ chat = [
290
+ { "role": "user", "content": "Write a hello world program" },
291
+ ]
292
+
293
+ prompt = tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
294
+ ```
295
+
296
+ At this point, the prompt contains the following text:
297
+
298
+ ```
299
+ <bos><start_of_turn>user
300
+ Write a hello world program<end_of_turn>
301
+ <start_of_turn>model
302
+ ```
303
+
304
+ As you can see, each turn is preceded by a `<start_of_turn>` delimiter and then the role of the entity
305
+ (either `user`, for content supplied by the user, or `model` for LLM responses). Turns finish with
306
+ the `<end_of_turn>` token.
307
+
308
+ You can follow this format to build the prompt manually, if you need to do it without the tokenizer's
309
+ chat template.
310
+
311
+ After the prompt is ready, generation can be performed like this:
312
+
313
+ ```py
314
+ inputs = tokenizer.encode(prompt, add_special_tokens=False, return_tensors="pt")
315
+ outputs = model.generate(input_ids=inputs.to(model.device), max_new_tokens=150)
316
+ ```
317
+
318
+ ### Inputs and Outputs
319
+
320
+ Inputs
321
+ : For pretrained model variants: code prefix and/or suffix for code completion and generation scenarios, or natural language text or prompt
322
+ : For instruction tuned model variant: natural language text or prompt
323
+
324
+ Outputs
325
+ : For pretrained model variants: fill-in-the-middle code completion, code and natural language
326
+ : For instruction tuned model variant: code and natural language
327
+
328
+ ## Model Data
329
+
330
+ Data used for model training and how the data was processed.
331
+
332
+ ### Training Dataset
333
+
334
+ Using Gemma as the base model, CodeGemma 2B and 7B pretrained variants are further trained on an additional 500 to 1000 billion tokens of primarily English language data from publicly available code repositories, open source mathematics datasets and synthetically generated code.
335
+
336
+ ### Training Data Processing
337
+
338
+ The following data pre-processing techniques were applied:
339
+
340
+ * FIM Pretrained CodeGemma models focus on fill-in-the-middle (FIM) tasks. The models are trained to work with both PSM and SPM modes. Our FIM settings are 80% to 90% FIM rate with 50-50 PSM/SPM.
341
+ * Dependency Graph-based Packing and Unit Test-based Lexical Packing techniques: To improve model alignment with real-world applications, we structured training examples at the project/repository level to co-locate the most relevant source files within each repository. Specifically, we employed two heuristic techniques: dependency graph-based packing and unit test-based lexical packing
342
+ * We developed a novel technique for splitting the documents into prefix, middle, and suffix to make the suffix start in a more syntactically natural point rather than purely random distribution.
343
+ * Safety: Similarly to Gemma, we deployed rigorous safety filtering including filtering personal data, CSAM filtering and other filtering based on content quality and safety in line with [our policies](https://storage.googleapis.com/gweb-uniblog-publish-prod/documents/2023_Google_AI_Principles_Progress_Update.pdf#page=11).
344
+
345
+ ## Implementation Information
346
+
347
+ Information about the hardware and software used to train the models.
348
+
349
+ ### Hardware
350
+
351
+ CodeGemma was trained using the latest generation of [Tensor Processing Unit (TPU)](https://cloud.google.com/tpu/docs/intro-to-tpu) hardware (TPUv5e).
352
+
353
+ ### Software
354
+
355
+ Training was done using [JAX](https://github.com/google/jax) and [ML Pathways](https://blog.google/technology/ai/introducing-pathways-next-generation-ai-architecture/).
356
+
357
+ ## Evaluation Information
358
+
359
+ Model evaluation metrics and results.
360
+
361
+ ### Evaluation Approach
362
+
363
+ We evaluate CodeGemma on a variety of academic benchmarks across several domains:
364
+
365
+ * Code completion benchmarks: HumanEval Single Line and Multiple Line Infilling
366
+ * Code generation benchmarks: HumanEval, MBPP, BabelCode (C++, C#, Go, Java, JavaScript, Kotlin, Python, Rust)
367
+ * Q&A: BoolQ, PIQA, TriviaQA
368
+ * Natural Language: ARC-Challenge, HellaSwag, MMLU, WinoGrande
369
+ * Math Reasoning: GSM8K, MATH
370
+
371
+ ### Evaluation Results
372
+
373
+ #### Coding Benchmarks
374
+
375
+ | Benchmark | [2B](https://huggingface.co/google/codegemma-2b) | [2B (1.1)](https://huggingface.co/google/codegemma-1.1-2b) | [7B](https://huggingface.co/google/codegemma-7b) | [7B-IT](https://huggingface.co/google/codegemma-7b-it) | [7B-IT (1.1)](https://huggingface.co/google/codegemma-1.1-7b-it) |
376
+ | - | | | ---- |
377
+ | HumanEval | 31.1 | 37.8 | 44.5 | 56.1 | 60.4 |
378
+ | MBPP | 43.6 | 49.2 | 56.2 | 54.2 | 55.6 |
379
+ | HumanEval Single Line | 78.4 | 79.3 | 76.1 | 68.3 | 77.4 |
380
+ | HumanEval Multi Line | 51.4 | 51.0 | 58.4 | 20.1 | 23.7 |
381
+ | BC HE C++ | 24.2 | 19.9 | 32.9 | 42.2 | 46.6 |
382
+ | BC HE C# | 10.6 | 26.1 | 22.4 | 26.7 | 54.7 |
383
+ | BC HE Go | 20.5 | 18.0 | 21.7 | 28.6 | 34.2 |
384
+ | BC HE Java | 29.2 | 29.8 | 41.0 | 48.4 | 50.3 |
385
+ | BC HE JavaScript | 21.7 | 28.0 | 39.8 | 46.0 | 48.4 |
386
+ | BC HE Kotlin | 28.0 | 32.3 | 39.8 | 51.6 | 47.8 |
387
+ | BC HE Python | 21.7 | 36.6 | 42.2 | 48.4 | 54.0 |
388
+ | BC HE Rust | 26.7 | 24.2 | 34.1 | 36.0 | 37.3 |
389
+ | BC MBPP C++ | 47.1 | 38.9 | 53.8 | 56.7 | 63.5 |
390
+ | BC MBPP C# | 28.7 | 45.3 | 32.5 | 41.2 | 62.0 |
391
+ | BC MBPP Go | 45.6 | 38.9 | 43.3 | 46.2 | 53.2 |
392
+ | BC MBPP Java | 41.8 | 49.7 | 50.3 | 57.3 | 62.9 |
393
+ | BC MBPP JavaScript | 45.3 | 45.0 | 58.2 | 61.4 | 61.4 |
394
+ | BC MBPP Kotlin | 46.8 | 49.7 | 54.7 | 59.9 | 62.6 |
395
+ | BC MBPP Python | 38.6 | 52.9 | 59.1 | 62.0 | 60.2 |
396
+ | BC MBPP Rust | 45.3 | 47.4 | 52.9 | 53.5 | 52.3 |
397
+
398
+ #### Natural Language Benchmarks
399
+
400
+ ![CodeGemma Natural Language Benchmarks](./codegemma_nl_benchmarks.png)
401
+
402
+ ## Ethics and Safety
403
+
404
+ Ethics and safety evaluation approach and results.
405
+
406
+ ### Evaluation Approach
407
+
408
+ Our evaluation methods include structured evaluations and internal red-teaming testing of relevant content policies. Red-teaming was conducted by a number of different teams, each with different goals and human evaluation metrics. These models were evaluated against a number of different categories relevant to ethics and safety, including:
409
+
410
+ * Human evaluation on prompts covering content safety and representational harms. See the [Gemma model card](https://ai.google.dev/gemma/docs/model_card#evaluation_approach) for more details on evaluation approach.
411
+ * Specific testing of cyber-offence capabilities, focusing on testing autonomous hacking capabilities and ensuring potential harms are limited.
412
+
413
+ ### Evaluation Results
414
+
415
+ The results of ethics and safety evaluations are within acceptable thresholds for meeting [internal policies](https://storage.googleapis.com/gweb-uniblog-publish-prod/documents/2023_Google_AI_Principles_Progress_Update.pdf#page=11) for categories such as child safety, content safety, representational harms, memorization, large-scale harms. See the [Gemma model card](https://ai.google.dev/gemma/docs/model_card#evaluation_results) for more details.
416
+
417
+ ## Model Usage & Limitations
418
+
419
+ These models have certain limitations that users should be aware of.
420
+
421
+ ### Intended Usage
422
+
423
+ Code Gemma models have a wide range of applications, which vary between IT and PT models. The following list of potential uses is not comprehensive. The purpose of this list is to provide contextual information about the possible use-cases that the model creators considered as part of model training and development.
424
+
425
+ Code Completion
426
+ : PT models can be used to complete code with an IDE extension
427
+
428
+ Code Generation
429
+ : IT model can be used to generate code with or without an IDE extension
430
+
431
+ Code Conversation
432
+ : IT model can power conversation interfaces which discuss code.
433
+
434
+ Code Education
435
+ : IT model supports interactive code learning experiences, aids in syntax correction or provides coding practice.
436
+
437
+ ### Known Limitations
438
+
439
+ Large Language Models (LLMs) have limitations based on their training data and the inherent limitations of the technology. See the [Gemma model card](https://ai.google.dev/gemma/docs/model_card#evaluation_results) for more details on the limitations of LLMs.
440
+
441
+ ### Ethical Considerations & Risks
442
+
443
+ The development of large language models (LLMs) raises several ethical concerns. We have carefully considered multiple aspects in the development of these models. Please refer to [the same discussion](https://ai.google.dev/gemma/docs/model_card#ethical_considerations_and_risks) in the Gemma model card for model details.
444
+
445
+ ### Benefits
446
+
447
+ At the time of release, this family of models provides high-performance open code-focused large language model implementations designed from the ground up for Responsible AI development compared to similarly sized models.
448
+
449
+ Using the coding benchmark evaluation metrics described in this document, these models have shown to provide superior performance to other, comparably-sized open model alternatives.
450
+
451
+ <!-- original-model-card end -->