@article{codegemma_2024,
title={CodeGemma: Open Code Models Based on Gemma},
url={https://goo.gle/codegemma},
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}
}
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2024-12-18 (世界標準時間)。"],[],[],null,["# CodeGemma model card\n\n**Model page:** [CodeGemma](https://ai.google.dev/gemma/docs/codegemma)\n\n**Resources and technical documentation:**\n\n- [Technical Report](https://goo.gle/codegemma)\n- [Responsible Generative AI Toolkit](https://ai.google.dev/responsible)\n- [CodeGemma on Kaggle](https://www.kaggle.com/models/google/codegemma)\n\n**Terms of Use:** [Terms](https://ai.google.dev/gemma/terms)\n\n**Authors:** Google\n\nModel information\n-----------------\n\n### Model summary\n\n#### Description\n\nCodeGemma is a family of lightweight open code models built on top of Gemma.\nCodeGemma models are text-to-text and text-to-code decoder-only models and are\navailable as a 7 billion pretrained variant that specializes in code completion\nand code generation tasks, a 7 billion parameter instruction-tuned variant for\ncode chat and instruction following and a 2 billion parameter pretrained variant\nfor fast code completion.\n\n#### Inputs and outputs\n\n- **Input:** For pretrained model variants: code prefix and optionally suffix\n for code completion and generation scenarios or natural language text/prompt.\n For instruction-tuned model variant: natural language text or prompt.\n\n- **Output:** For pretrained model variants: fill-in-the-middle code\n completion, code and natural language. For instruction-tuned model variant:\n code and natural language.\n\n#### Citation\n\n @article{codegemma_2024,\n title={CodeGemma: Open Code Models Based on Gemma},\n url={https://goo.gle/codegemma},\n author={ {CodeGemma Team} and Hartman, Ale Jakse and Hu, Andrea and Choquette-Choo, Christopher A. and Zhao, Heri and Fine, Jane and Hui,\n 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.},\n year={2024}\n }\n\n### Model data\n\n#### Training dataset\n\nUsing Gemma as the base model, CodeGemma 2B and 7B pretrained variants are\nfurther trained on an additional 500 to 1000 billion tokens of primarily English\nlanguage data from open source mathematics datasets and synthetically generated\ncode.\n\n#### Training data processing\n\nThe following data pre-processing techniques were applied to train CodeGemma:\n\n- 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.\n- 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.\n- 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.\n- 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).\n\nImplementation information\n--------------------------\n\n### Hardware and frameworks used during training\n\n[Like Gemma](https://ai.google.dev/gemma/docs/core/model_card#implementation_information),\nCodeGemma was trained on the latest generation of\n[Tensor Processing Unit (TPU)](https://cloud.google.com/tpu/docs/intro-to-tpu)\nhardware (TPUv5e),\nusing [JAX](https://github.com/jax-ml/jax) and [ML\nPathways](https://blog.google/technology/ai/introducing-pathways-next-generation-ai-architecture/).\n\nEvaluation information\n----------------------\n\n### Benchmark results\n\n#### Evaluation approach\n\n- Code completion benchmarks: [HumanEval (HE)](https://arxiv.org/abs/2204.05999) (Single Line and Multiple Line Infilling)\n- Code generation benchmarks: HumanEval, [MBPP](https://arxiv.org/abs/2108.07732), [BabelCode (BC)](https://arxiv.org/abs/2302.01973) \\[C++, C#, Go, Java, JavaScript, Kotlin, Python, Rust\\]\n- Q\\&A: [BoolQ](https://arxiv.org/abs/1905.10044), [PIQA](https://arxiv.org/abs/1911.11641), [TriviaQA](https://arxiv.org/abs/1705.03551)\n- Natural Language: [ARC-Challenge](https://arxiv.org/abs/1911.01547), [HellaSwag](https://arxiv.org/abs/1905.07830), [MMLU](https://arxiv.org/abs/2009.03300), [WinoGrande](https://arxiv.org/abs/1907.10641)\n- Math Reasoning: [GSM8K](https://arxiv.org/abs/2110.14168), [MATH](https://arxiv.org/abs/2103.03874)\n\n#### Coding benchmark results\n\n| Benchmark | 2B | 2B (1.1) | 7B | 7B-IT | 7B-IT (1.1) |\n|-----------------------|------|----------|------|-------|-------------|\n| HumanEval | 31.1 | 37.8 | 44.5 | 56.1 | 60.4 |\n| MBPP | 43.6 | 49.2 | 56.2 | 54.2 | 55.6 |\n| HumanEval Single Line | 78.4 | 79.3 | 76.1 | 68.3 | 77.4 |\n| HumanEval Multi Line | 51.4 | 51.0 | 58.4 | 20.1 | 23.7 |\n| BC HE C++ | 24.2 | 19.9 | 32.9 | 42.2 | 46.6 |\n| BC HE C# | 10.6 | 26.1 | 22.4 | 26.7 | 54.7 |\n| BC HE Go | 20.5 | 18.0 | 21.7 | 28.6 | 34.2 |\n| BC HE Java | 29.2 | 29.8 | 41.0 | 48.4 | 50.3 |\n| BC HE JavaScript | 21.7 | 28.0 | 39.8 | 46.0 | 48.4 |\n| BC HE Kotlin | 28.0 | 32.3 | 39.8 | 51.6 | 47.8 |\n| BC HE Python | 21.7 | 36.6 | 42.2 | 48.4 | 54.0 |\n| BC HE Rust | 26.7 | 24.2 | 34.1 | 36.0 | 37.3 |\n| BC MBPP C++ | 47.1 | 38.9 | 53.8 | 56.7 | 63.5 |\n| BC MBPP C# | 28.7 | 45.3 | 32.5 | 41.2 | 62.0 |\n| BC MBPP Go | 45.6 | 38.9 | 43.3 | 46.2 | 53.2 |\n| BC MBPP Java | 41.8 | 49.7 | 50.3 | 57.3 | 62.9 |\n| BC MBPP JavaScript | 45.3 | 45.0 | 58.2 | 61.4 | 61.4 |\n| BC MBPP Kotlin | 46.8 | 49.7 | 54.7 | 59.9 | 62.6 |\n| BC MBPP Python | 38.6 | 52.9 | 59.1 | 62.0 | 60.2 |\n| BC MBPP Rust | 45.3 | 47.4 | 52.9 | 53.5 | 52.3 |\n\n#### Natural language benchmarks (on 7B models)\n\nEthics and safety\n-----------------\n\n### Ethics and safety evaluations\n\n#### Evaluations approach\n\nOur evaluation methods include structured evaluations and internal red-teaming\ntesting of relevant content policies. Red-teaming was conducted by a number of\ndifferent teams, each with different goals and human evaluation metrics.\nThese models were evaluated against a number of different categories relevant to\nethics and safety, including:\n\n- Human evaluation on prompts covering content safety and representational\n harms. See the\n [Gemma model card](https://ai.google.dev/gemma/docs/core/model_card#evaluation_results)\n for more details on evaluation approach.\n\n- Specific testing of cyber-offence capabilities, focusing on testing autonomous\n hacking capabilities and ensuring potential harms are limited.\n\n#### Evaluation results\n\nThe results of ethics and safety evaluations are within acceptable thresholds\nfor meeting\n[internal policies](https://storage.googleapis.com/gweb-uniblog-publish-prod/documents/2023_Google_AI_Principles_Progress_Update.pdf#page=11)\nfor categories such as child safety, content safety, representational harms,\nmemorization, large-scale harms. See the\n[Gemma model card](https://ai.google.dev/gemma/docs/core/model_card#evaluation_results)\nfor more details.\n\nModel usage and limitations\n---------------------------\n\n### Known limitations\n\nLarge Language Models (LLMs) have limitations based on their training data and\nthe inherent limitations of the technology. See the\n[Gemma model card](https://ai.google.dev/gemma/docs/core/model_card#limitations)\nfor more details on the limitations of LLMs.\n\n### Ethical considerations and risks\n\nThe development of large language models (LLMs) raises several ethical concerns.\nWe have carefully considered multiple aspects in the development of these\nmodels.\n\nPlease refer to [the same discussion](https://ai.google.dev/gemma/docs/core/model_card#ethical_considerations_and_risks)\nin the Gemma model card for model details.\n\nIntended usage\n--------------\n\n### Application\n\nCode Gemma models have a wide range of applications, which vary between IT and\nPT models. The following list of potential uses is not comprehensive. The\npurpose of this list is to provide contextual information about the possible\nuse-cases that the model creators considered as part of model training and\ndevelopment.\n\n- Code Completion: PT models can be used to complete code with an IDE extension\n- Code Generation: IT model can be used to generate code with or without an IDE extension\n- Code Conversation: IT model can power conversation interfaces which discuss code\n- Code Education: IT model supports interactive code learning experiences, aids in syntax correction or provides coding practice\n\n### Benefits\n\nAt the time of release, this family of models provides high-performance open\ncode-focused large language model implementations designed from the ground up\nfor Responsible AI development compared to similarly sized models.\n\nUsing the coding benchmark evaluation metrics described in this document, these\nmodels have shown to provide superior performance to other, comparably-sized\nopen model alternatives."]]