TechxGenus commited on
Commit
9dae4a2
1 Parent(s): 1628990

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +257 -0
README.md ADDED
@@ -0,0 +1,257 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ extra_gated_heading: Access CodeGemma on Hugging Face
4
+ extra_gated_prompt: >-
5
+ To access CodeGemma on Hugging Face, you’re required to review and agree to
6
+ Google’s usage license. To do this, please ensure you’re logged-in to Hugging
7
+ Face and click below. Requests are processed immediately.
8
+ extra_gated_button_content: Acknowledge license
9
+ pipeline_tag: text-generation
10
+ widget:
11
+ - text: >
12
+ <start_of_turn>user
13
+ Write a Python function to calculate the nth fibonacci number.<end_of_turn>
14
+ <start_of_turn>model
15
+ inference:
16
+ parameters:
17
+ max_new_tokens: 200
18
+ license: gemma
19
+ license_link: https://ai.google.dev/gemma/terms
20
+ ---
21
+
22
+ GPTQ quantized version of codegemma-1.1-7b-it model.
23
+
24
+ ---
25
+
26
+ # CodeGemma
27
+
28
+ Model Page
29
+ : [CodeGemma](https://ai.google.dev/gemma/docs/codegemma)
30
+
31
+ Resources and Technical Documentation
32
+ : [Technical Report](https://goo.gle/codegemma)
33
+ : [Responsible Generative AI Toolkit](https://ai.google.dev/responsible)
34
+
35
+ Terms of Use
36
+ : [Terms](https://ai.google.dev/gemma/terms)
37
+
38
+ Authors
39
+ : Google
40
+
41
+ ## Model Information
42
+
43
+ Summary description and brief definition of inputs and outputs.
44
+
45
+ ### Description
46
+
47
+ 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.
48
+
49
+ | | [ **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) |
50
+ |----------------------------------|:----------------------------------------------------------------:|:----------------------------------------------------------:|:----------------------------------------------------------------:|
51
+ | Code Completion | ✅ | ✅ | |
52
+ | Generation from natural language | | ✅ | ✅ |
53
+ | Chat | | | ✅ |
54
+ | Instruction Following | | | ✅ |
55
+
56
+ ### Sample Usage
57
+
58
+ 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).
59
+
60
+ #### For Code Generation
61
+
62
+ ```python
63
+ from transformers import GemmaTokenizer, AutoModelForCausalLM
64
+
65
+ tokenizer = GemmaTokenizer.from_pretrained("google/codegemma-1.1-7b-it")
66
+ model = AutoModelForCausalLM.from_pretrained("google/codegemma-1.1-7b-it")
67
+
68
+ input_text = "Write me a Python function to calculate the nth fibonacci number."
69
+ input_ids = tokenizer(input_text, return_tensors="pt")
70
+
71
+ outputs = model.generate(**input_ids)
72
+ print(tokenizer.decode(outputs[0]))
73
+ ```
74
+
75
+ #### Chat Template
76
+
77
+ The instruction-tuned models use a chat template that must be adhered to for conversational use.
78
+ The easiest way to apply it is using the tokenizer's built-in chat template, as shown in the following snippet.
79
+
80
+ Let's load the model and apply the chat template to a conversation. In this example, we'll start with a single user interaction:
81
+
82
+ ```py
83
+ from transformers import AutoTokenizer, AutoModelForCausalLM
84
+ import transformers
85
+ import torch
86
+
87
+ model_id = "google/codegemma-1.1-7b-it"
88
+ dtype = torch.bfloat16
89
+
90
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
91
+ model = AutoModelForCausalLM.from_pretrained(
92
+ model_id,
93
+ device_map="cuda",
94
+ torch_dtype=dtype,
95
+ )
96
+
97
+ chat = [
98
+ { "role": "user", "content": "Write a hello world program" },
99
+ ]
100
+
101
+ prompt = tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
102
+ ```
103
+
104
+ At this point, the prompt contains the following text:
105
+
106
+ ```
107
+ <bos><start_of_turn>user
108
+ Write a hello world program<end_of_turn>
109
+ <start_of_turn>model
110
+ ```
111
+
112
+ As you can see, each turn is preceded by a `<start_of_turn>` delimiter and then the role of the entity
113
+ (either `user`, for content supplied by the user, or `model` for LLM responses). Turns finish with
114
+ the `<end_of_turn>` token.
115
+
116
+ You can follow this format to build the prompt manually, if you need to do it without the tokenizer's
117
+ chat template.
118
+
119
+ After the prompt is ready, generation can be performed like this:
120
+
121
+ ```py
122
+ inputs = tokenizer.encode(prompt, add_special_tokens=False, return_tensors="pt")
123
+ outputs = model.generate(input_ids=inputs.to(model.device), max_new_tokens=150)
124
+ ```
125
+
126
+ ### Inputs and Outputs
127
+
128
+ Inputs
129
+ : For pretrained model variants: code prefix and/or suffix for code completion and generation scenarios, or natural language text or prompt
130
+ : For instruction tuned model variant: natural language text or prompt
131
+
132
+ Outputs
133
+ : For pretrained model variants: fill-in-the-middle code completion, code and natural language
134
+ : For instruction tuned model variant: code and natural language
135
+
136
+ ## Model Data
137
+
138
+ Data used for model training and how the data was processed.
139
+
140
+ ### Training Dataset
141
+
142
+ 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.
143
+
144
+ ### Training Data Processing
145
+
146
+ The following data pre-processing techniques were applied:
147
+
148
+ * 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.
149
+ * 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
150
+ * 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.
151
+ * 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).
152
+
153
+ ## Implementation Information
154
+
155
+ Information about the hardware and software used to train the models.
156
+
157
+ ### Hardware
158
+
159
+ CodeGemma was trained using the latest generation of [Tensor Processing Unit (TPU)](https://cloud.google.com/tpu/docs/intro-to-tpu) hardware (TPUv5e).
160
+
161
+ ### Software
162
+
163
+ Training was done using [JAX](https://github.com/google/jax) and [ML Pathways](https://blog.google/technology/ai/introducing-pathways-next-generation-ai-architecture/).
164
+
165
+ ## Evaluation Information
166
+
167
+ Model evaluation metrics and results.
168
+
169
+ ### Evaluation Approach
170
+
171
+ We evaluate CodeGemma on a variety of academic benchmarks across several domains:
172
+
173
+ * Code completion benchmarks: HumanEval Single Line and Multiple Line Infilling
174
+ * Code generation benchmarks: HumanEval, MBPP, BabelCode (C++, C#, Go, Java, JavaScript, Kotlin, Python, Rust)
175
+ * Q&A: BoolQ, PIQA, TriviaQA
176
+ * Natural Language: ARC-Challenge, HellaSwag, MMLU, WinoGrande
177
+ * Math Reasoning: GSM8K, MATH
178
+
179
+ ### Evaluation Results
180
+
181
+ #### Coding Benchmarks
182
+
183
+ 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)
184
+ ----------------------|------|----------|------|-------|------------
185
+ HumanEval | 31.1 | 37.8 | 44.5 | 56.1 | 60.4
186
+ MBPP | 43.6 | 49.2 | 56.2 | 54.2 | 55.6
187
+ HumanEval Single Line | 78.4 | 79.3 | 76.1 | 68.3 | 77.4
188
+ HumanEval Multi Line | 51.4 | 51.0 | 58.4 | 20.1 | 23.7
189
+ BC HE C++ | 24.2 | 19.9 | 32.9 | 42.2 | 46.6
190
+ BC HE C# | 10.6 | 26.1 | 22.4 | 26.7 | 54.7
191
+ BC HE Go | 20.5 | 18.0 | 21.7 | 28.6 | 34.2
192
+ BC HE Java | 29.2 | 29.8 | 41.0 | 48.4 | 50.3
193
+ BC HE JavaScript | 21.7 | 28.0 | 39.8 | 46.0 | 48.4
194
+ BC HE Kotlin | 28.0 | 32.3 | 39.8 | 51.6 | 47.8
195
+ BC HE Python | 21.7 | 36.6 | 42.2 | 48.4 | 54.0
196
+ BC HE Rust | 26.7 | 24.2 | 34.1 | 36.0 | 37.3
197
+ BC MBPP C++ | 47.1 | 38.9 | 53.8 | 56.7 | 63.5
198
+ BC MBPP C# | 28.7 | 45.3 | 32.5 | 41.2 | 62.0
199
+ BC MBPP Go | 45.6 | 38.9 | 43.3 | 46.2 | 53.2
200
+ BC MBPP Java | 41.8 | 49.7 | 50.3 | 57.3 | 62.9
201
+ BC MBPP JavaScript | 45.3 | 45.0 | 58.2 | 61.4 | 61.4
202
+ BC MBPP Kotlin | 46.8 | 49.7 | 54.7 | 59.9 | 62.6
203
+ BC MBPP Python | 38.6 | 52.9 | 59.1 | 62.0 | 60.2
204
+ BC MBPP Rust | 45.3 | 47.4 | 52.9 | 53.5 | 52.3
205
+
206
+ #### Natural Language Benchmarks
207
+
208
+ ![CodeGemma Natural Language Benchmarks](./codegemma_nl_benchmarks.png)
209
+
210
+ ## Ethics and Safety
211
+
212
+ Ethics and safety evaluation approach and results.
213
+
214
+ ### Evaluation Approach
215
+
216
+ 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:
217
+
218
+ * 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.
219
+ * Specific testing of cyber-offence capabilities, focusing on testing autonomous hacking capabilities and ensuring potential harms are limited.
220
+
221
+ ### Evaluation Results
222
+
223
+ 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.
224
+
225
+ ## Model Usage & Limitations
226
+
227
+ These models have certain limitations that users should be aware of.
228
+
229
+ ### Intended Usage
230
+
231
+ 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.
232
+
233
+ Code Completion
234
+ : PT models can be used to complete code with an IDE extension
235
+
236
+ Code Generation
237
+ : IT model can be used to generate code with or without an IDE extension
238
+
239
+ Code Conversation
240
+ : IT model can power conversation interfaces which discuss code.
241
+
242
+ Code Education
243
+ : IT model supports interactive code learning experiences, aids in syntax correction or provides coding practice.
244
+
245
+ ### Known Limitations
246
+
247
+ 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.
248
+
249
+ ### Ethical Considerations & Risks
250
+
251
+ 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.
252
+
253
+ ### Benefits
254
+
255
+ 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.
256
+
257
+ 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.