Gemma-2-2b LoRA Adapter

This repository contains a LoRA adapter for the Gemma-2-2b model. The adapter was fine-tuned to make the base model consistently generate text summaries that extract key points from the given input. By using LoRA, only a small fraction of the model parameters is updated (approximately 0.4864%), keeping the base model intact while achieving the desired behavior.

Overview

  • Base Model: google/gemma-2-2b
  • Adapter: LoRA adapter fine-tuned to produce summaries.
  • Purpose: The adapter adjusts the model to focus on summarizing texts based on key parameters while drastically reducing the number of trainable parameters.
  • Usage: Load the base model and attach this adapter using the PEFT library.

How to Use the Adapter

  1. Installation:

Make sure you have the necessary libraries installed. For example:

pip install transformers peft bitsandbytes
  1. Loading the Base Model and Attaching the Adapter:

Use the following example code to load the base model and attach the adapter:

from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel

base_model = AutoModelForCausalLM.from_pretrained(
"google/gemma-2-2b",
torch_dtype=torch.float16,
device_map="auto",
attn_implementation="eager"
) # use quant if you need it

model = PeftModel.from_pretrained(base_model, "itqop/gemma-2-2b-summarize-adapter")

tokenizer = AutoTokenizer.from_pretrained("itqop/gemma-2-2b-summarize-adapter")
if tokenizer.pad_token is None:
tokenizer.pad_token = tokenizer.eos_token
  1. Inference Example:

Below is an example of how to send a request to the model. In this example, the input text is not translated (it remains in Russian):

Example Request:

<start_sum>text Каждую ночь я вижу его во сне. Он стоит у края леса, в тёмной одежде, лицо скрыто капюшоном. Его глаза горят ярким светом, который пробивает тьму. Я всегда пытаюсь к нему подойти, но он исчезает, как мираж, когда я почти дохожу. Это повторяется каждую ночь, и страх все больше меня охватывает. Что это значит? Кто этот человек? Почему он преследует меня во сне? Может быть, это просто плохой сон, но ощущение его присутствия слишком реальное, чтобы быть игнорируемым.<end_sum>
<start_sum>sum
Ключевые моменты этого сообщения:
1. **Сновидения:** Главный герой видит повторяющиеся сны о загадочном существе в лесу.
2. **Загадочность существа:** Существо скрывает лицо и имеет горящие глаза, что создает атмосферу таинственности и страха.
3. **Попытка приблизиться:** Герой пытается к этому существности подходить во снах, однако его прерывает исчезновение во время прикосновения.
4. **Страх и беспокойство:** Сны вызывают у героя страх и тревогу, он не может понять их смысла и природу преследователя.
<end_sum>

You can pass this prompt to the model, and it will generate the summary based on the key points provided.

License

This adapter is released under the CC BY-NC-ND 4.0 license, which prohibits commercial use and modifications. See the LICENSE file for details.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model is not currently available via any of the supported Inference Providers.
The model cannot be deployed to the HF Inference API: The model has no library tag.

Model tree for itqop/gemma-2-2b-summarize-adapter

Base model

google/gemma-2-2b
Finetuned
(507)
this model