Downloads · 30 days
227
7% of all-time downloads
LiteLLMs/codegemma-1.1-2b-GGUF
codegemma-1.1-2b-GGUF is a machine learning model from LiteLLMs. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for transformers. The card lists the license as gemma.
Downloads · 30 days
227
7% of all-time downloads
All-time downloads
3.2K
Public
Repo size
23.8 GB
Likes
0
Public
Click a slice to open those files.
.gguf28.7 GB · 100%
From the Hugging Face model README
This repo contains GGUF format model files for codegemma-1.1-2b.
<!-- description end --> <!-- README_GGUF.md-about-gguf start -->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. Here is an incomplete list of clients and libraries that are known to support GGUF:
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.
The following clients/libraries will automatically download models for you, providing a list of available models to choose from:
text-generation-webuiUnder Download Model, you can enter the model repo: LiteLLMs/codegemma-1.1-2b-GGUF and below it, a specific filename to download, such as: Q4_0/Q4_0-00001-of-00001.gguf.
Then click Download.
I recommend using the huggingface-hub Python library:
pip3 install huggingface-hub
Then you can download any individual model file to the current directory, at high speed, with a command like this:
huggingface-cli download LiteLLMs/codegemma-1.1-2b-GGUF Q4_0/Q4_0-00001-of-00001.gguf --local-dir . --local-dir-use-symlinks False
<details>
<summary>More advanced huggingface-cli download usage (click to read)</summary>
You can also download multiple files at once with a pattern:
huggingface-cli download LiteLLMs/codegemma-1.1-2b-GGUF --local-dir . --local-dir-use-symlinks False --include='*Q4_K*gguf'
For more documentation on downloading with huggingface-cli, please see: HF -> Hub Python Library -> Download files -> Download from the CLI.
To accelerate downloads on fast connections (1Gbit/s or higher), install hf_transfer:
pip3 install huggingface_hub[hf_transfer]
And set environment variable HF_HUB_ENABLE_HF_TRANSFER to 1:
HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download LiteLLMs/codegemma-1.1-2b-GGUF Q4_0/Q4_0-00001-of-00001.gguf --local-dir . --local-dir-use-symlinks False
Windows Command Line users: You can set the environment variable by running set HF_HUB_ENABLE_HF_TRANSFER=1 before the download command.
Make sure you are using llama.cpp from commit d0cee0d or later.
./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>"
Change -ngl 32 to the number of layers to offload to GPU. Remove it if you don't have GPU acceleration.
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.
If you want to have a chat-style conversation, replace the -p <PROMPT> argument with -i -ins
For other parameters and how to use them, please refer to the llama.cpp documentation
text-generation-webuiFurther instructions can be found in the text-generation-webui documentation, here: text-generation-webui/docs/04 ‐ Model Tab.md.
You can use GGUF models from Python using the llama-cpp-python or 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.
For full documentation, please see: llama-cpp-python docs.
Run one of the following commands, according to your system:
# Base ctransformers with no GPU acceleration
pip install llama-cpp-python
# With NVidia CUDA acceleration
CMAKE_ARGS="-DLLAMA_CUBLAS=on" pip install llama-cpp-python
# Or with OpenBLAS acceleration
CMAKE_ARGS="-DLLAMA_BLAS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS" pip install llama-cpp-python
# Or with CLBLast acceleration
CMAKE_ARGS="-DLLAMA_CLBLAST=on" pip install llama-cpp-python
# Or with AMD ROCm GPU acceleration (Linux only)
CMAKE_ARGS="-DLLAMA_HIPBLAS=on" pip install llama-cpp-python
# Or with Metal GPU acceleration for macOS systems only
CMAKE_ARGS="-DLLAMA_METAL=on" pip install llama-cpp-python
# In windows, to set the variables CMAKE_ARGS in PowerShell, follow this format; eg for NVidia CUDA:
$env:CMAKE_ARGS = "-DLLAMA_OPENBLAS=on"
pip install llama-cpp-python
from llama_cpp import Llama
# Set gpu_layers to the number of layers to offload to GPU. Set to 0 if no GPU acceleration is available on your system.
llm = Llama(
model_path="./Q4_0/Q4_0-00001-of-00001.gguf", # Download the model file first
n_ctx=32768, # The max sequence length to use - note that longer sequence lengths require much more resources
n_threads=8, # The number of CPU threads to use, tailor to your system and the resulting performance
n_gpu_layers=35 # The number of layers to offload to GPU, if you have GPU acceleration available
)
# Simple inference example
output = llm(
"<PROMPT>", # Prompt
max_tokens=512, # Generate up to 512 tokens
stop=["</s>"], # Example stop token - not necessarily correct for this specific model! Please check before using.
echo=True # Whether to echo the prompt
)
# Chat Completion API
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
llm.create_chat_completion(
messages = [
{"role": "system", "content": "You are a story writing assistant."},
{
"role": "user",
"content": "Write a story about llamas."
}
]
)
Here are guides on using llama-cpp-python and ctransformers with LangChain:
<!-- README_GGUF.md-how-to-run end --> <!-- footer end --> <!-- original-model-card start -->Model Page : CodeGemma
Resources and Technical Documentation : Technical Report : Responsible Generative AI Toolkit
Terms of Use : Terms
Authors : Google
Summary description and brief definition of inputs and outputs.
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-7b | codegemma-7b-it | | -- | :: | :--: | :: | | Code Completion | ✅ | ✅ | | | Generation from natural language | | ✅ | ✅ | | Chat | | | ✅ | | Instruction Following | | | ✅ |
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|>
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 : 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
Data used for model training and how the data was processed.
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.
The following data pre-processing techniques were applied:
Information about the hardware and software used to train the models.
CodeGemma was trained using the latest generation of Tensor Processing Unit (TPU) hardware (TPUv5e).
Training was done using JAX and ML Pathways.
Model evaluation metrics and results.
We evaluate CodeGemma on a variety of academic benchmarks across several domains:
| Benchmark | 2B | 2B (1.1) | 7B | 7B-IT | 7B-IT (1.1) | | - | | | ---- | | HumanEval | 31.1 | 37.8 | 44.5 | 56.1 | 60.4 | | MBPP | 43.6 | 49.2 | 56.2 | 54.2 | 55.6 | | HumanEval Single Line | 78.4 | 79.3 | 76.1 | 68.3 | 77.4 | | HumanEval Multi Line | 51.4 | 51.0 | 58.4 | 20.1 | 23.7 | | BC HE C++ | 24.2 | 19.9 | 32.9 | 42.2 | 46.6 | | BC HE C# | 10.6 | 26.1 | 22.4 | 26.7 | 54.7 | | BC HE Go | 20.5 | 18.0 | 21.7 | 28.6 | 34.2 | | BC HE Java | 29.2 | 29.8 | 41.0 | 48.4 | 50.3 | | BC HE JavaScript | 21.7 | 28.0 | 39.8 | 46.0 | 48.4 | | BC HE Kotlin | 28.0 | 32.3 | 39.8 | 51.6 | 47.8 | | BC HE Python | 21.7 | 36.6 | 42.2 | 48.4 | 54.0 | | BC HE Rust | 26.7 | 24.2 | 34.1 | 36.0 | 37.3 | | BC MBPP C++ | 47.1 | 38.9 | 53.8 | 56.7 | 63.5 | | BC MBPP C# | 28.7 | 45.3 | 32.5 | 41.2 | 62.0 | | BC MBPP Go | 45.6 | 38.9 | 43.3 | 46.2 | 53.2 | | BC MBPP Java | 41.8 | 49.7 | 50.3 | 57.3 | 62.9 | | BC MBPP JavaScript | 45.3 | 45.0 | 58.2 | 61.4 | 61.4 | | BC MBPP Kotlin | 46.8 | 49.7 | 54.7 | 59.9 | 62.6 | | BC MBPP Python | 38.6 | 52.9 | 59.1 | 62.0 | 60.2 | | BC MBPP Rust | 45.3 | 47.4 | 52.9 | 53.5 | 52.3 |

Ethics and safety evaluation approach and results.
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:
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.
These models have certain limitations that users should be aware of.
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.
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.
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.
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.
<!-- original-model-card end -->