itqop commited on
Commit
33276a2
·
verified ·
1 Parent(s): 0357784

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +66 -1
README.md CHANGED
@@ -5,4 +5,69 @@ language:
5
  base_model:
6
  - google/gemma-2-2b
7
  pipeline_tag: summarization
8
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  base_model:
6
  - google/gemma-2-2b
7
  pipeline_tag: summarization
8
+ ---
9
+ # Gemma-2-2b LoRA Adapter
10
+
11
+ 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.12%), keeping the base model intact while achieving the desired behavior.
12
+
13
+ ## Overview
14
+
15
+ - **Base Model:** [google/gemma-2-2b](https://huggingface.co/google/gemma-2-2b)
16
+ - **Adapter:** LoRA adapter fine-tuned to produce summaries.
17
+ - **Purpose:** The adapter adjusts the model to focus on summarizing texts based on key parameters while drastically reducing the number of trainable parameters.
18
+ - **Usage:** Load the base model and attach this adapter using the PEFT library.
19
+
20
+ ## How to Use the Adapter
21
+
22
+ 1. **Installation:**
23
+
24
+ Make sure you have the necessary libraries installed. For example:
25
+
26
+ ```bash
27
+ pip install transformers peft bitsandbytes
28
+ ```
29
+
30
+ 2. **Loading the Base Model and Attaching the Adapter:**
31
+
32
+ Use the following example code to load the base model and attach the adapter:
33
+
34
+ ```python
35
+ from transformers import AutoModelForCausalLM, AutoTokenizer
36
+ from peft import PeftModel
37
+
38
+ base_model = AutoModelForCausalLM.from_pretrained(
39
+ "google/gemma-2-2b",
40
+ torch_dtype=torch.float16,
41
+ device_map="auto",
42
+ attn_implementation="eager"
43
+ ) # use quant if you need it
44
+
45
+ model = PeftModel.from_pretrained(base_model, "itqop/gemma-2-2b-summarize-adapter")
46
+
47
+ tokenizer = AutoTokenizer.from_pretrained("itqop/gemma-2-2b-summarize-adapter")
48
+ if tokenizer.pad_token is None:
49
+ tokenizer.pad_token = tokenizer.eos_token
50
+
51
+ ```
52
+
53
+ 3. **Inference Example:**
54
+
55
+ 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):
56
+
57
+ **Example Request:**
58
+
59
+ ```
60
+ Запрос: Каждую ночь я вижу его во сне. Он стоит у края леса, в тёмной одежде, лицо скрыто капюшоном. Его глаза горят ярким светом, который пробивает тьму. Я всегда пытаюсь к нему подойти, но он исчезает, как мираж, когда я почти дохожу. Это повторяется каждую ночь, и страх все больше меня охватывает. Что это значит? Кто этот человек? Почему он преследует меня во сне? Может быть, это просто плохой сон, но ощущение его присутствия слишком реальное, чтобы быть игнорируемым.
61
+ Ожидаемый ответ:
62
+ Ключевые моменты этого сообщения:
63
+ 1. **Сновидения:** Главный герой видит повторяющиеся сны о загадочном существе в лесу.
64
+ 2. **Загадочность существа:** Существо скрывает лицо и имеет горящие глаза, что создает атмосферу таинственности и страха.
65
+ 3. **Попытка приблизиться:** Герой пытается к этому существности подходить во снах, однако его прерывает исчезновение во время прикосновения.
66
+ 4. **Страх и беспокойство:** Сны вызывают у героя страх и тревогу, он не может понять их смысла и природу преследователя.
67
+ ```
68
+
69
+ You can pass this prompt to the model, and it will generate the summary based on the key points provided.
70
+
71
+ ## License
72
+
73
+ This adapter is released under the **CC BY-NC-ND 4.0** license, which prohibits commercial use and modifications. See the [LICENSE](./LICENSE) file for details.