--- license: gemma language: - it - en base_model: - google/gemma-2-2b-it pipeline_tag: text-generation library_name: transformers datasets: - efederici/capybara-claude-15k-ita - anakin87/fine-instructions-ita-70k - mii-llm/argilla-math-preferences-it - ruggsea/wsdm2024-cot-dataset - anakin87/evol-dpo-ita-reranked - anakin87/gemma-vs-gemma-preferences - mlabonne/orpo-dpo-mix-40k ---

Gemma 2 2B Neogenesis ITA

Fine-tuned version of [google/gemma-2-2b-it](https://huggingface.co/google/gemma-2-2b-it) optimized for better performance in Italian. - Small yet powerful model with 2.6 billion parameters - Supports 8k context length GGUF quants: [static](https://huggingface.co/mradermacher/gemma-2-2b-neogenesis-ita-GGUF) - [weighted/imatrix](https://huggingface.co/mradermacher/gemma-2-2b-neogenesis-ita-i1-GGUF) *Need a stronger model?* Try [gemma-2-9b-neogenesis-ita](https://huggingface.co/anakin87/gemma-2-9b-neogenesis-ita). # ๐ŸŽฎ Usage [๐Ÿ’ฌ๐Ÿ‡ฎ๐Ÿ‡น Try the model on Hugging Face Spaces](https://huggingface.co/spaces/anakin87/gemma-2-2b-neogenesis-ita) **Text generation with Transformers** ```python import torch from transformers import pipeline model_id="anakin87/gemma-2-2b-neogenesis-ita" pipe = pipeline( "text-generation", model=model_id, model_kwargs={"torch_dtype": torch.bfloat16}, device="cuda", ) messages = [{"role": "user", "content": "Cos'รจ l'interesse composto? Spiega in maniera semplice e chiara."}] outputs = pipe(messages, max_new_tokens=500) print(outputs[0]["generated_text"][1]["content"]) >>> Immagina di avere 100 euro e di depositarli in un conto che ti dร  un interesse del 5% all'anno.... ``` For more usage examples and applications, refer to the [๐Ÿ““ Kaggle notebook](https://www.kaggle.com/code/anakin87/post-training-gemma-for-italian-and-beyond). # ๐Ÿ† Evaluation Results The model was submitted and evaluated in the [Open Ita LLM Leaderboard](https://huggingface.co/spaces/mii-llm/open_ita_llm_leaderboard), the most popular leaderboard for Italian Language Models. | Model | MMLU_IT | ARC_IT | HELLASWAG_IT | Average | |-----------------------|---------|--------|--------------|---------| | google/gemma-2-2b-it | 47.65 | 40.03 |54.69 | 47.46 | | [anakin87/gemma-2-2b-ita-sft](https://huggingface.co/anakin87/gemma-2-2b-ita-sft) (SFT checkpoint) | 47.77 | **41.15** |55.66 | 48.19 | | **anakin87/gemma-2-2b-neogenesis-ita (DPO)** | **48.03** | 40.46 |**56.97** | **48.49** | Qualitative evaluation across various domains is available [here](https://html-preview.github.io/?url=https://github.com/anakin87/gemma-neogenesis/blob/main/qualitative_evaluation/qualitative_evaluation.html). # ๐Ÿ”ง Training details The model was fine-tuned using [Hugging Face TRL](https://huggingface.co/docs/trl/index). The training involved Instruction Fine Tuning and Direct Preference Optimization. I adopted a relatively new technique for parameter-efficient learning: [Spectrum](https://arxiv.org/abs/2406.06623). The idea is to train only the layers of the model with high Signal-to-Noise Ratio (SNR) and โ„๏ธ freeze the rest. Specifically, training focused on the top 25% most informative layers. Batch size: 16; learning rate: 5e-6; epochs: 1 for SFT and 1 for DPO. Training required about 15 hours on a single NVIDIA A6000 GPU (48GB VRAM). For comprehensive training code and details, check out the [๐Ÿ““ Kaggle notebook](https://www.kaggle.com/code/anakin87/post-training-gemma-for-italian-and-beyond). # ๐Ÿ—ƒ๏ธ Training data The model was trained primarily on Italian data, with a small portion of English data included. For Instruction Fine Tuning: - Italian data - [efederici/capybara-claude-15k-ita](https://huggingface.co/datasets/efederici/capybara-claude-15k-ita) - [anakin87/fine-instructions-ita-70k](https://huggingface.co/datasets/anakin87/fine-instructions-ita-70k) For Direct Preference Optimization - Italian data - [mii-llm/argilla-math-preferences-it](https://huggingface.co/datasets/mii-llm/argilla-math-preferences-it) - [ruggsea/wsdm2024-cot-dataset](https://huggingface.co/datasets/ruggsea/wsdm2024-cot-dataset) - [anakin87/evol-dpo-ita-reranked](https://huggingface.co/datasets/anakin87/evol-dpo-ita-reranked) - [anakin87/gemma-vs-gemma-preferences](https://huggingface.co/datasets/anakin87/gemma-vs-gemma-preferences) - English data - [mlabonne/orpo-dpo-mix-40k](https://huggingface.co/datasets/mlabonne/orpo-dpo-mix-40k) ๐Ÿ™ Thanks to the authors for providing these datasets. # Usage limitations Although the model demonstrates solid Italian fluency and good reasoning capabilities for its small size, it is expected to have limited world knowledge due to its restricted number of parameters. This limitation can be mitigated by pairing it with techniques like Retrieval-Augmented Generation. Check out the [๐Ÿ““ Kaggle notebook](https://www.kaggle.com/code/anakin87/post-training-gemma-for-italian-and-beyond) for an example. # ๐Ÿ›ก๏ธ Safety While this model was not specifically fine-tuned for safety, its selective training with the Spectrum technique helps preserve certain safety features from the original model, as emerged in the [qualitative evaluation](https://html-preview.github.io/?url=https://github.com/anakin87/gemma-neogenesis/blob/main/qualitative_evaluation/qualitative_evaluation.html).