/ Модель

Характеристики

Контекст
8 192 токена
Параметры
2,5 млрд
Размер весов
5 ГБ
Лицензия
Gemma
Архитектура
gemma · dense
Библиотека
transformers
Опубликована
4 авг 2024

codegemma-1.1-2b-fix

Генерация текстаТекст → текст3 профессии

Производная модели google/codegemma-1.1-2b. Компактная модель Google на 2 млрд параметров для автодополнения кода, в том числе заполнения пропусков между частями кода.

24скачиваний за 30 дней0лайковвеса обновлены4 авг 2024

Бенчмарки

Как модель справилась с задачами пользователей ailist и что о ней публикуют открытые лидерборды

Тесты пользователейпока нет

Никто ещё не опубликовал тест этой модели. Соберите бенчмарк из своих задач — результат появится здесь.

  1. Добавьте модель в бенчмарк

    Вместе с другими моделями категории «Текст» — сравнение идёт внутри одной категории.

  2. Опишите свои задачи

    Напишите запросы, при необходимости приложите файлы и эталонные ответы.

  3. Запустите и опубликуйте

    Модели ответят на каждую задачу, судья оценит ответы. Опубликованный результат появится на этой странице.

Публичные оценки

Из открытых лидербордов. Сравнивайте результаты одного теста при одинаковых условиях — отсутствие оценки не значит, что модель хуже.

В подключённых источниках результатов для этой модели пока нет.

Что умеет модель

Описание составлено по карточке модели и метаданным Hugging Face

Карточка модели sh2nd/codegemma-1.1-2b-fix на Hugging Face совпадает с карточкой google/codegemma-1.1-2b, поэтому описание составлено по ней.

CodeGemma 1.1 2B — компактная языковая модель для работы с кодом, разработанная Google на основе Gemma. Это предварительно обученная декодерная модель с 2 млрд параметров, предназначенная прежде всего для быстрого автодополнения кода. Она поддерживает заполнение пропусков между префиксом и суффиксом (fill-in-the-middle) в редакторе кода; на вход также можно подавать текстовые подсказки, а на выходе получать код или текст. Модель обучалась на дополнительных данных, преимущественно на английском языке: коде из открытых репозиториев, математических наборах данных и синтетически созданном коде.

Модель подходит для интеграции в IDE и помощи при написании кода. Карточка описывает CodeGemma 2B как вариант для автодополнения, а не для чата или генерации кода по естественно-языковому запросу; эти сценарии в таблице отнесены к другим вариантам семейства. Для скачивания доступны веса в формате Safetensors, библиотека — Transformers. Лицензия — Gemma, использование регулируется условиями Google для Gemma.

Как и другие большие языковые модели, CodeGemma может выдавать неверный или неподходящий код; результат следует проверять. В карточке также отмечено, что ограничения наследуются от семейства Gemma.

Сценарии применения

  • автодополнение кода в IDE
  • заполнение пропущенного фрагмента между префиксом и суффиксом кода
  • подсказки кода при редактировании программ

Ограничения

Модель может генерировать ошибочный или неподходящий код, поэтому результаты нужно проверять. Вариант 2B предназначен прежде всего для автодополнения; карточка не позиционирует его как чат-модель.

Для каких профессий подходит3

Разделы каталога профессий, в задачах которых используется эта модель

Все профессии

Карточка модели

README от автора на Hugging Face, как он его опубликовал

Открыть на Hugging Face

CodeGemma

Model Page : CodeGemma

Resources and Technical Documentation : Technical Report : Responsible Generative AI Toolkit

Terms of Use : Terms

Authors : Google

Model Information

Summary description and brief definition of inputs and outputs.

Description

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.

codegemma-2b codegemma-7bcodegemma-7b-it
Code Completion✅✅
Generation from natural language✅✅
Chat✅
Instruction Following✅

Sample Usage

For Code Completion

Code completion can be used for infilling inside code editors. CodeGemma was trained for this task using the fill-in-the-middle (FIM) objective, where you provide a prefix and a suffix as context for the completion. The following tokens are used to separate the different parts of the input:

  • <|fim_prefix|> precedes the context before the completion we want to run.
  • <|fim_suffix|> precedes the suffix. You must put this token exactly where the cursor would be positioned in an editor, as this is the location that will be completed by the model.
  • <|fim_middle|> is the prompt that invites the model to run the generation.

In addition to these, there's also <|file_separator|>, which is used to provide multi-file contexts.

Please, make sure to not provide any extra spaces or newlines around the tokens, other than those that would naturally occur in the code fragment you want to complete. Here's an example:

from transformers import GemmaTokenizer, AutoModelForCausalLM

model_id = "google/codegemma-1.1-2b"
tokenizer = GemmaTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id)

prompt = '''\
<|fim_prefix|>import datetime
def calculate_age(birth_year):
    """Calculates a person's age based on their birth year."""
    current_year = datetime.date.today().year
    <|fim_suffix|>
    return age<|fim_middle|>\
'''

inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
prompt_len = inputs["input_ids"].shape[-1]
outputs = model.generate(**inputs, max_new_tokens=100)
print(tokenizer.decode(outputs[0][prompt_len:]))

This may return something like the following:

age = current_year - birth_year<|file_separator|>test_calculate_age.py
<|fim_suffix|>
    assert calculate_age(1990) == 33
    assert calculate_age(1980) == 43
    assert calculate_age(1970) == 53
    assert calculate_age(1960) == 63
    assert calculate_age(1950) == 73

Note the extra content after the correct completion. The model returns the completion, followed by one of the FIM tokens or the EOS token. You should ignore everything that comes after any of these tokens. A good way to achieve this is by providing a list of terminators to the generate function, like this:

FIM_PREFIX = '<|fim_prefix|>'
FIM_SUFFIX = '<|fim_suffix|>'
FIM_MIDDLE = '<|fim_middle|>'
FIM_FILE_SEPARATOR = '<|file_separator|>'

terminators = tokenizer.convert_tokens_to_ids([FIM_PREFIX, FIM_MIDDLE, FIM_SUFFIX, FIM_FILE_SEPARATOR])
terminators += [tokenizer.eos_token_id]

outputs = model.generate(
  **inputs,
  max_new_tokens=100,
  eos_token_id=terminators,
)

In this case, generation stops as soon as the first delimiter is found in the response:

age = current_year - birth_year<|file_separator|>

For Code Generation

from transformers import GemmaTokenizer, AutoModelForCausalLM

tokenizer = GemmaTokenizer.from_pretrained("google/codegemma-1.1-2b")
model = AutoModelForCausalLM.from_pretrained("google/codegemma-1.1-2b")

input_text = "Write me a Python function to calculate the nth fibonacci number."
input_ids = tokenizer(input_text, return_tensors="pt")

outputs = model.generate(**input_ids)
print(tokenizer.decode(outputs[0]))

Inputs and Outputs

Inputs : For pretrained model variants: code prefix and/or suffix for code completion and generation scenarios, or natural language text or prompt : For instruction tuned model variant: natural language text or prompt

Outputs : For pretrained model variants: fill-in-the-middle code completion, code and natural language : For instruction tuned model variant: code and natural language

Model Data

Data used for model training and how the data was processed.

Training Dataset

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.

Training Data Processing

The following data pre-processing techniques were applied:

  • 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.
  • 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
  • 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.

Implementation Information

Information about the hardware and software used to train the models.

Hardware

CodeGemma was trained using the latest generation of Tensor Processing Unit (TPU) hardware (TPUv5e).

Software

Training was done using JAX and ML Pathways.

Evaluation Information

Model evaluation metrics and results.

Evaluation Approach

We evaluate CodeGemma on a variety of academic benchmarks across several domains:

  • Code completion benchmarks: HumanEval Single Line and Multiple Line Infilling
  • Code generation benchmarks: HumanEval, MBPP, BabelCode (C++, C#, Go, Java, JavaScript, Kotlin, Python, Rust)
  • Q&A: BoolQ, PIQA, TriviaQA
  • Natural Language: ARC-Challenge, HellaSwag, MMLU, WinoGrande
  • Math Reasoning: GSM8K, MATH

Evaluation Results

Coding Benchmarks

Benchmark2B2B (1.1)7B7B-IT7B-IT (1.1)
HumanEval31.137.844.556.160.4
MBPP43.649.256.254.255.6
HumanEval Single Line78.479.376.168.377.4
HumanEval Multi Line51.451.058.420.123.7
BC HE C++24.219.932.942.246.6
BC HE C#10.626.122.426.754.7
BC HE Go20.518.021.728.634.2
BC HE Java29.229.841.048.450.3
BC HE JavaScript21.728.039.846.048.4
BC HE Kotlin28.032.339.851.647.8
BC HE Python21.736.642.248.454.0
BC HE Rust26.724.234.136.037.3
BC MBPP C++47.138.953.856.763.5
BC MBPP C#28.745.332.541.262.0
BC MBPP Go45.638.943.346.253.2
BC MBPP Java41.849.750.357.362.9
BC MBPP JavaScript45.345.058.261.461.4
BC MBPP Kotlin46.849.754.759.962.6
BC MBPP Python38.652.959.162.060.2
BC MBPP Rust45.347.452.953.552.3

Natural Language Benchmarks

CodeGemma Natural Language Benchmarks

Ethics and Safety

Ethics and safety evaluation approach and results.

Evaluation 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 & Limitations

These models have certain limitations that users should be aware of.

Intended Usage

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.

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 & 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.

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.

Как запустить

На своей GPU в ailist. Цена — по текущим предложениям провайдеров

GPU в ailist

Универсальный рантайм · transformers

Можно запустить

Подбираем GPU…

Класс архитектуры
GemmaForCausalLM
Ревизия весов
7405b99

0 моделей