Update README.md
Browse files
README.md
CHANGED
@@ -4,21 +4,105 @@ language:
|
|
4 |
- ja
|
5 |
pipeline_tag: text-generation
|
6 |
---
|
7 |
-
## Training procedure
|
8 |
|
|
|
9 |
|
10 |
-
|
11 |
-
- quant_method: bitsandbytes
|
12 |
-
- load_in_8bit: False
|
13 |
-
- load_in_4bit: True
|
14 |
-
- llm_int8_threshold: 6.0
|
15 |
-
- llm_int8_skip_modules: None
|
16 |
-
- llm_int8_enable_fp32_cpu_offload: False
|
17 |
-
- llm_int8_has_fp16_weight: False
|
18 |
-
- bnb_4bit_quant_type: nf4
|
19 |
-
- bnb_4bit_use_double_quant: True
|
20 |
-
- bnb_4bit_compute_dtype: float16
|
21 |
-
### Framework versions
|
22 |
|
|
|
23 |
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
- ja
|
5 |
pipeline_tag: text-generation
|
6 |
---
|
|
|
7 |
|
8 |
+
# Fine-tuned OpenCALM-7B Adapters for Meeting Summarization
|
9 |
|
10 |
+
## Description
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
+
These are weights for LoRA adapters fine-tuned on the OpenCALM-7B ([Andonian et al., 2021](https://huggingface.co/cyberagent/open-calm-7b)) model for Japanese meeting summarization.
|
13 |
|
14 |
+
## Usage
|
15 |
+
|
16 |
+
### Load model and tokenizer
|
17 |
+
|
18 |
+
Loading the model in the 4-bit quantized format is recommended to get reliable results since these LoRA adapters were trained by using QLoRA ([Dettmers et al., 2023](https://arxiv.org/abs/2305.14314)).
|
19 |
+
|
20 |
+
|
21 |
+
```python
|
22 |
+
import torch
|
23 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
|
24 |
+
from peft import PeftModel
|
25 |
+
|
26 |
+
bnb_config = BitsAndBytesConfig(
|
27 |
+
load_in_4bit=True,
|
28 |
+
bnb_4bit_use_double_quant=True,
|
29 |
+
bnb_4bit_quant_type="nf4",
|
30 |
+
bnb_4bit_compute_dtype=torch.float16
|
31 |
+
)
|
32 |
+
|
33 |
+
tokenizer = AutoTokenizer.from_pretrained("cyberagent/open-calm-7b")
|
34 |
+
model = AutoModelForCausalLM.from_pretrained(
|
35 |
+
"cyberagent/open-calm-7b",
|
36 |
+
quantization_config=bnb_config,
|
37 |
+
device_map="auto"
|
38 |
+
)
|
39 |
+
|
40 |
+
model = PeftModel.from_pretrained(model, "haih2/open-calm-7b-summarizer-lora")
|
41 |
+
```
|
42 |
+
|
43 |
+
### Generate summary
|
44 |
+
|
45 |
+
In the prompt provided to the model:
|
46 |
+
* The first part is the length of the summary to be generated,
|
47 |
+
* and The second part is the source meeting to be summarized.
|
48 |
+
|
49 |
+
```python
|
50 |
+
prompt = "この段落の要約50字以内生成:次に、私立高校の生徒に対する留学支援についてでございますが、都内の私立高校は、それぞれの学校における教育方針に基づきまして、生徒の留学先として海外の学校と提携するなど、既にさまざまな独自の取り組みを進めております。\\nこうした状況等を踏まえ、私立高校を対象とした留学支援のあり方について、今後検討してまいります。\\n\n"
|
51 |
+
|
52 |
+
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
53 |
+
with torch.no_grad():
|
54 |
+
tokens = model.generate(
|
55 |
+
**inputs,
|
56 |
+
max_new_tokens=256,
|
57 |
+
do_sample=True,
|
58 |
+
temperature=0.7,
|
59 |
+
top_k=32,
|
60 |
+
top_p=0.9,
|
61 |
+
repetition_penalty=1.0,
|
62 |
+
no_repeat_ngram_size=0,
|
63 |
+
pad_token_id=tokenizer.pad_token_id,
|
64 |
+
)
|
65 |
+
|
66 |
+
output = tokenizer.decode(tokens[0], skip_special_tokens=True)
|
67 |
+
print(output)
|
68 |
+
```
|
69 |
+
|
70 |
+
## Prompt Format
|
71 |
+
|
72 |
+
Any prompt is fine, but it is suggested to have `length` and `source` parts as follows:
|
73 |
+
|
74 |
+
```
|
75 |
+
"この段落を{length}に要約しなさい:{source}\n要約:"
|
76 |
+
```
|
77 |
+
|
78 |
+
or
|
79 |
+
|
80 |
+
```
|
81 |
+
"この段落の要約{length}生成:{source}\n"
|
82 |
+
```
|
83 |
+
|
84 |
+
## Fine-tuning Details
|
85 |
+
|
86 |
+
### Dataset
|
87 |
+
|
88 |
+
* [Congressional meeting's minutes](https://github.com/kmr-y/NTCIR14-QALab-PoliInfo-FormalRunDataset/tree/master) provided by QA Lab PoliInfo.
|
89 |
+
|
90 |
+
### Fine-tuning procedure
|
91 |
+
|
92 |
+
The OpenCALM-7B model was fine-tuned on the above dataset using the QLoRA method with prompt `この段落の要約{length}生成:{source}\n`.
|
93 |
+
|
94 |
+
## Evaluation
|
95 |
+
|
96 |
+
### Testing data & Metric
|
97 |
+
|
98 |
+
We evaluated the model on two sets: one for *multi-topic* summarization and the other for *single-topic* summarization. ROUGE-L (F1-score-based) with the [Japanese Mecab tokenizer](https://pypi.org/project/mecab-python3/) was used as the evaluation metric.
|
99 |
+
|
100 |
+
### Results
|
101 |
+
|
102 |
+
|Solution/Model|ROUGE-L <br> (multi-topic)|ROUGE-L <br> (single-topic)|
|
103 |
+
|:------------:|:------------------------:|:-------------------------:|
|
104 |
+
|1st place solution* |34.12 |**34.44**|
|
105 |
+
|2nd place solution* |32.79 |33.65 |
|
106 |
+
|*OpenCALM-7B (QLoRA)*|***36.75***|*33.31* |
|
107 |
+
|
108 |
+
*\* These scores are extracted from this [leaderboard](https://github.com/PoliInfo/PoliInfo.github.io/blob/master/FormalRunResult.md) for the summarization task.*
|