NGC Catalog
CLASSIC
Welcome Guest
Models
CodeGemma 2B Base

CodeGemma 2B Base

For downloads and more information, please view on a desktop device.
Logo for CodeGemma 2B Base
Description
CodeGemma is a collection of lightweight open code models built on top of Gemma. This is a 2 billion parameter pre-trained variant for fast code completion.
Publisher
Google
Latest Version
1.0
Modified
April 12, 2024
Size
3.72 GB

CodeGemma 2B Base

CodeGemma Terms of Use

By accessing this model, you are agreeing to the Gemma Terms of Use.

Model page: CodeGemma

Resources and technical documentation:

  • Responsible Generative AI Toolkit
  • CodeGemma on Kaggle
  • Technical Report

Authors: Google

Model information

Model summary

Description

CodeGemma is a family 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 pre-trained 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 pre-trained variant for fast code completion.

CodeGemma models are optimized with NeMo Framework.
NVIDIA releases CodeGemma checkpoints converted to the *.nemo format to allow users to quickly customize them using techniques offered by NeMo Framework. Code Gemma customization examples are available at GenerativeAIExamples.

Inputs and outputs
  • Input: For pre-trained model variants: code prefix and optionally suffix for code completion and generation scenarios or natural language text/prompt. For instruction tuned model variant: natural language text or prompt.

  • Output: For pre-trained model variants: fill-in-the-middle code completion, code and natural language. For instruction tuned model variant: code and natural language.

Citation
@article{codegemma_2024,
    title={CodeGemma: Open Code Models Based on Gemma},
    url={https://www.kaggle.com/m/3301},
    author={CodeGemma Team and Hartman, Ale Jakse and Hu, Andrea and Choquette-Choo, Christopher A. and Zhao, Heri and Fine, Jane and Hui,
    Jeffrey and Shen, Jingyue and Kelley, Joe and Howland, Joshua and Bansal, Kshitij and Vilnis, Luke and Wirth, Mateo and Nguyen, Nam, and Michel, Paul and Choy, Peter and Joshi, Pratik and Kumar, Ravin and Hashmi, Sarmad and Agrawal, Shubham and Zuo, Siqi and Warkentin, Tris and Gong, Zhitao et al.},
    year={2024}
}

Model data

Training dataset

Using Gemma as the base model, CodeGemma 2B and 7B pre-trained variants are further trained on an additional 500 billion tokens of primarily English language data from open source mathematics datasets and synthetically generated code.

Training data processing

The following data pre-processing techniques were applied to train CodeGemma:

  • FIM - pre-trained 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% FIM rate with 50-50 PSM/SPM.
  • 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 colocate the most relevant source files within each repository. Specifically, we employed two heuristic techniques: dependency graph-based packing and unit test-based lexical packing.
  • 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.
  • 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.

Evaluation information

Benchmark results

Evaluation approach
  • Code completion benchmarks: HumanEval (HE) Single Line and Multiple Line Infilling
  • Code generation benchmarks: HumanEval, MBPP, BabelCode (BC) (C++, C#, Go, Java, JavaScript, Kotlin, Python, Rust)
  • Q&A: BoolQ, PIQA, TriviaQA
  • Natural Language: ARC-Challenge, HellaSwag, MMLU, WinoGrande
  • Math Reasoning: GSM8K, MATH
Coding benchmark results
Benchmark 2B 7B 7B-IT
HumanEval 31.1 44.5 56.1
MBPP 43.6 56.2 54.2
HumanEval Single Line 78.41 76.09 68.25
HumanEval Multi Line 51.44 58.44 20.05
BC HE C++ 24.2 32.9 42.2
BC HE C# 10.6 22.4 26.7
BC HE Go 20.5 21.7 28.6
BC HE Java 29.2 41.0 48.4
BC HE JavaScript 21.7 39.8 46.0
BC HE Kotlin 28.0 39.8 51.6
BC HE Python 21.7 42.2 48.4
BC HE Rust 26.7 34.1 36.0
BC MBPP C++ 47.1 53.8 56.7
BC MBPP C# 28.7 32.5 41.2
BC MBPP Go 45.6 43.3 46.2
BC MBPP Java 41.8 50.3 57.3
BC MBPP JavaScript 45.3 58.2 61.4
BC MBPP Kotlin 46.8 54.7 59.9
BC MBPP Python 38.6 59.1 62.0
BC MBPP Rust 45.3 52.9 53.5

Ethics and safety

Ethics and safety evaluations

Evaluations approach

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:

  • Human evaluation on prompts covering content safety and representational harms. See the Gemma model card for more details on evaluation approach.

  • Specific testing of cyber-offence capabilities, focusing on testing autonomous hacking capabilities and ensuring potential harms are limited.

Evaluation results

The results of ethics and safety evaluations are within acceptable thresholds for meeting internal policies for categories such as child safety, content safety, representational harms, memorization, large-scale harms. See the Gemma model card for more details.

Model usage and limitations

Known limitations

Large Language Models (LLMs) have limitations based on their training data and the inherent limitations of the technology. See the Gemma model card for more details on the limitations of LLMs.

Ethical considerations and risks

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 in the Gemma model card for model details.

Intended usage

Application

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.

  • Code Completion: PT models can be used to complete code with an IDE extension
  • Code Generation: IT model can be used to generate code with or without an IDE extension
  • Code Conversation: IT model can power conversation interfaces which discuss code
  • Code Education: IT model supports interactive code learning experiences, aids in syntax correction or provides coding practice

Benefits

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.

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.

CodeGemma Terms of Use

By using, reproducing, modifying, distributing, performing or displaying any portion or element of Gemma, Model Derivatives including via any Hosted Service, (each as defined below) (collectively, the “Gemma Services”) or otherwise accepting the terms of this Agreement, you agree to be bound by this Agreement.

Section 1

DEFINITIONS

1.1 Definitions

  • (a) “Agreement” or “Gemma Terms of Use” means these terms and conditions that govern the use, reproduction, Distribution or modification of the Gemma Services and any terms and conditions incorporated by reference.
  • (b) “Distribution” or “Distribute” means any transmission, publication, or other sharing of Gemma or Model Derivatives to a third party, including by providing or making Gemma or its functionality available as a hosted service via API, web access, or any other electronic or remote means (“Hosted Service”).
  • (c) “Gemma” means the set of machine learning language models, trained model weights and parameters identified at ai.google.dev/gemma, regardless of the source that you obtained it from.
  • (d) “Google” means Google LLC.
  • (e) “Model Derivatives” means all (i) modifications to Gemma, (ii) works based on Gemma, or (iii) any other machine learning model which is created by transfer of patterns of the weights, parameters, operations, or Output of Gemma, to that model in order to cause that model to perform similarly to Gemma, including distillation methods that use intermediate data representations or methods based on the generation of synthetic data Outputs by Gemma for training that model. For clarity, Outputs are not deemed Model Derivatives.
  • (f) “Output” means the information content output of Gemma or a Model Derivative that results from operating or otherwise using Gemma or the Model Derivative, including via a Hosted Service.

1.2 As used in this Agreement, “including” means “including without limitation”.

Section 2

ELIGIBILITY AND USAGE

2.1 Eligibility. You represent and warrant that you have the legal capacity to enter into this Agreement (including being of sufficient age of consent). If you are accessing or using any of the Gemma Services for or on behalf of a legal entity, (a) you are entering into this Agreement on behalf of yourself and that legal entity, (b) you represent and warrant that you have the authority to act on behalf of and bind that entity to this Agreement and (c) references to “you” or “your” in the remainder of this Agreement refers to both you (as an individual) and that entity.

2.2 Use. You may use, reproduce, modify, Distribute, perform or display any of the Gemma Services only in accordance with the terms of this Agreement, and must not violate (or encourage or permit anyone else to violate) any term of this Agreement.

Section 3

DISTRIBUTION AND RESTRICTIONS

3.1 Distribution and Redistribution. You may reproduce or Distribute copies of Gemma or Model Derivatives if you meet all of the following conditions:

  • a. You must include the use restrictions referenced in Section 3.2 as an enforceable provision in any agreement (e.g., license agreement, terms of use, etc.) governing the use and/or distribution of Gemma or Model Derivatives and you must provide notice to subsequent users you Distribute to that Gemma or Model Derivatives are subject to the use restrictions in Section 3.2.
  • b. You must provide all third-party recipients of Gemma or Model Derivatives a copy of this Agreement.
  • c. You must cause any modified files to carry prominent notices stating that you modified the files.
  • d. All Distributions (other than through a Hosted Service) must be accompanied by a “Notice” text file that contains the following notice: “Gemma is provided under and subject to the Gemma Terms of Use found at ai.google.dev/gemma/terms”.

You may add your own intellectual property statement to your modifications and, except as set forth in this Section, may provide additional or different terms and conditions for use, reproduction, or Distribution of your modifications, or for any such Model Derivatives as a whole, provided your use, reproduction, modification, Distribution, performance, and display of Gemma otherwise complies with the terms and conditions of this Agreement. Any additional or different terms and conditions you impose must not conflict with the terms of this Agreement.

3.2 Use Restrictions. You must not use any of the Gemma Services:

  • a. for the restricted uses set forth in the Gemma Prohibited Use Policy at ai.google.dev/gemma/prohibited_use_policy (“Prohibited Use Policy”), which is hereby incorporated by reference into this Agreement; or
  • b. in violation of applicable laws and regulations.

To the maximum extent permitted by law, Google reserves the right to restrict (remotely or otherwise) usage of any of the Gemma Services that Google reasonably believes are in violation of this Agreement.

3.3 Generated Output. Google claims no rights in Outputs you generate using Gemma. You and your users are solely responsible for Outputs and their subsequent uses.

Section 4

ADDITIONAL PROVISIONS

4.1 Updates. Google may update Gemma from time to time, and you must make reasonable efforts to use the latest version of Gemma.

4.2 Trademarks. Nothing in this Agreement grants you any rights to use Google’s trademarks, trade names, logos or to otherwise suggest endorsement or misrepresent the relationship between you and Google. Google reserves any rights not expressly granted herein.

4.3 DISCLAIMER OF WARRANTY. UNLESS REQUIRED BY APPLICABLE LAW, THE GEMMA SERVICES, AND OUTPUTS, ARE PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. YOU ARE SOLELY RESPONSIBLE FOR DETERMINING THE APPROPRIATENESS OF USING, REPRODUCING, MODIFYING, PERFORMING, DISPLAYING OR OR DISTRIBUTING ANY OF THE GEMMA SERVICES OR OUTPUTS AND ASSUME ANY AND ALL RISKS ASSOCIATED WITH YOUR USE OR DISTRIBUTION OF ANY OF THE GEMMA SERVICES OR OUTPUTS AND YOUR EXERCISE OF RIGHTS AND PERMISSIONS UNDER THIS AGREEMENT.

4.4 LIMITATION OF LIABILITY. TO THE FULLEST EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT AND UNDER NO LEGAL THEORY, WHETHER IN TORT (INCLUDING NEGLIGENCE), PRODUCT LIABILITY, CONTRACT, OR OTHERWISE, UNLESS REQUIRED BY APPLICABLE LAW, SHALL GOOGLE OR ITS AFFILIATES BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL, EXEMPLARY, CONSEQUENTIAL, OR PUNITIVE DAMAGES, OR LOST PROFITS OF ANY KIND ARISING FROM THIS AGREEMENT OR RELATED TO, ANY OF THE GEMMA SERVICES OR OUTPUTS EVEN IF GOOGLE OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

4.5 Term, Termination, and Survival. The term of this Agreement will commence upon your acceptance of this Agreement (including acceptance by your use, modification, or Distribution, reproduction, performance or display of any portion or element of the Gemma Services) and will continue in full force and effect until terminated in accordance with the terms of this Agreement. Google may terminate this Agreement if you are in breach of any term of this Agreement. Upon termination of this Agreement, you must delete and cease use and Distribution of all copies of Gemma and Model Derivatives in your possession or control. Sections 1, 2.1, 3.3, 4.2 to 4.9 shall survive the termination of this Agreement.

4.6 Governing Law and Jurisdiction. This Agreement will be governed by the laws of the State of California without regard to choice of law principles. The UN Convention on Contracts for the International Sale of Goods does not apply to this Agreement. The state and federal courts of Santa Clara County, California shall have exclusive jurisdiction of any dispute arising out of this Agreement.

4.7 Severability. If any provision of this Agreement is held to be invalid, illegal or unenforceable, the remaining provisions shall be unaffected thereby and remain valid as if such provision had not been set forth herein.

4.8 Entire Agreement. This Agreement states all the terms agreed between the parties and supersedes all other agreements between the parties as of the date of acceptance relating to its subject matter.

4.9 No Waiver. Google will not be treated as having waived any rights by not exercising (or delaying the exercise of) any rights under this Agreement.