Team Ai
Modelpublic

Praneeth/code-gemma-2b-it

sourceHugging Faceotherupdated 3y agoView on Hugging Face
6likes150downloads
README.md58 linesDownload Raw Back to root
1---2language:3- en4license: other5library_name: transformers6tags:7- peft8- unsloth9- lora10- trl11- sft12datasets:13- HuggingFaceH4/CodeAlpaca_20K14license_name: gemma-terms-of-use15license_link: https://ai.google.dev/gemma/terms16 17inference: false18---19 20# Code-Gemma-2B21 22### Description23Code-Gemma was finetuned (1k steps) on the CodeAlpaca-20k dataset using the unsloth library to enhance the Gemma-2B-it model.24 25### Usage26 27Below we share some code snippets on how to get quickly started with running the model.28 29```python30!pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"31if major_version >= 8:32    # Use this for new GPUs like Ampere, Hopper GPUs (RTX 30xx, RTX 40xx, A100, H100, L40)33    !pip install --no-deps packaging ninja einops flash-attn xformers trl peft accelerate bitsandbytes34else:35    # Use this for older GPUs (V100, Tesla T4, RTX 20xx)36    !pip install --no-deps xformers trl peft accelerate bitsandbytes37pass38```39 40#### Running the model on a GPU using different precisions41 42* _Using `torch.float16`_43 44```python45 46from transformers import AutoTokenizer, AutoModelForCausalLM47 48tokenizer = AutoTokenizer.from_pretrained("Praneeth/code-gemma-2b-it")49model = AutoModelForCausalLM.from_pretrained("Praneeth/code-gemma-2b-it", device_map="auto", torch_dtype=torch.float16)50 51input_text = "Write me a poem about Machine Learning."52input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")53 54outputs = model.generate(**input_ids, max_new_tokens=256,)55print(tokenizer.decode(outputs[0]))56```57 58