Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,141 @@
|
|
1 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
license: apache-2.0
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
tags:
|
3 |
+
- generated_from_trainer
|
4 |
+
model-index:
|
5 |
+
- name: Qra-7b-dolly-instruction-0.1
|
6 |
+
results: []
|
7 |
+
datasets:
|
8 |
+
- s3nh/alpaca-dolly-instruction-only-polish
|
9 |
+
language:
|
10 |
+
- pl
|
11 |
+
inference: true
|
12 |
license: apache-2.0
|
13 |
+
pipeline_tag: text-generation
|
14 |
---
|
15 |
+
|
16 |
+
# Qra-7b-dolly-instruction-0.1
|
17 |
+
|
18 |
+
This model if a fine-tuned version of [OPI-PG/Qra-7b](https://huggingface.co/OPI-PG/Qra-7b) on the [s3nh/alpaca-dolly-instruction-only-polish](https://huggingface.co/datasets/s3nh/alpaca-dolly-instruction-only-polish) dataset.
|
19 |
+
|
20 |
+
## Model Description
|
21 |
+
|
22 |
+
Trained from [OPI-PG/Qra-7b](https://huggingface.co/OPI-PG/Qra-7b)
|
23 |
+
|
24 |
+
## Intended uses & limitations
|
25 |
+
|
26 |
+
This model has been fine-tuned for question-answering task. It is possible to use it as a chat, but it doesn't work well because the dataset did not contain conversations.
|
27 |
+
|
28 |
+
```py
|
29 |
+
import torch
|
30 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
|
31 |
+
|
32 |
+
model_id = "nie3e/Qra-7b-dolly-instruction-0.1"
|
33 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
34 |
+
|
35 |
+
model = AutoModelForCausalLM.from_pretrained(
|
36 |
+
model_id,
|
37 |
+
torch_dtype=torch.bfloat16,
|
38 |
+
)
|
39 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
40 |
+
pipe = pipeline(
|
41 |
+
"text-generation", model=model, tokenizer=tokenizer, device=device
|
42 |
+
)
|
43 |
+
|
44 |
+
def get_answer(system_prompt: str, user_prompt: str) -> str:
|
45 |
+
input_msg = [
|
46 |
+
{"role": "system", "content": system_prompt},
|
47 |
+
{"role": "user", "content": user_prompt}
|
48 |
+
]
|
49 |
+
prompt = pipe.tokenizer.apply_chat_template(
|
50 |
+
input_msg, tokenize=False,
|
51 |
+
add_generation_prompt=True
|
52 |
+
)
|
53 |
+
outputs = pipe(
|
54 |
+
prompt, max_new_tokens=512, do_sample=False, temperature=0.1, top_k=50,
|
55 |
+
top_p=0.1, eos_token_id=pipe.tokenizer.eos_token_id,
|
56 |
+
pad_token_id=pipe.tokenizer.pad_token_id
|
57 |
+
)
|
58 |
+
return outputs[0]['generated_text'][len(prompt):].strip()
|
59 |
+
|
60 |
+
print(
|
61 |
+
get_answer(
|
62 |
+
system_prompt="Jesteś przyjaznym chatbotem",
|
63 |
+
user_prompt="Napisz czym jest dokument architectural decision record."
|
64 |
+
)
|
65 |
+
)
|
66 |
+
```
|
67 |
+
|
68 |
+
## Training and evaluation data
|
69 |
+
|
70 |
+
Dataset: [s3nh/alpaca-dolly-instruction-only-polish](https://huggingface.co/datasets/s3nh/alpaca-dolly-instruction-only-polish)
|
71 |
+
|
72 |
+
Each row has been converted into conversation using this function:
|
73 |
+
```py
|
74 |
+
system_message = """Jesteś przyjaznym chatbotem"""
|
75 |
+
|
76 |
+
def create_conversation(sample) -> dict:
|
77 |
+
strip_characters = "\"'"
|
78 |
+
return {
|
79 |
+
"messages": [
|
80 |
+
{"role": "system", "content": system_message},
|
81 |
+
{"role": "user",
|
82 |
+
"content": f"{sample['instruction'].strip(strip_characters)} "
|
83 |
+
f"{sample['input'].strip(strip_characters)}"},
|
84 |
+
{"role": "assistant",
|
85 |
+
"content": f"{sample['output'].strip(strip_characters)}"}
|
86 |
+
]
|
87 |
+
}
|
88 |
+
```
|
89 |
+
|
90 |
+
Train/test split: 90%/10%
|
91 |
+
|
92 |
+
## Training procedure
|
93 |
+
|
94 |
+
GPU: 2x RTX 4060Ti 16GB
|
95 |
+
Training time: ~13 hours
|
96 |
+
|
97 |
+
Using `device_map="auto"`
|
98 |
+
|
99 |
+
### Training hyperparameters
|
100 |
+
|
101 |
+
Lora config:
|
102 |
+
```py
|
103 |
+
peft_config = LoraConfig(
|
104 |
+
lora_alpha=128,
|
105 |
+
lora_dropout=0.05,
|
106 |
+
r=256,
|
107 |
+
bias="none",
|
108 |
+
target_modules="all-linear",
|
109 |
+
task_type="CAUSAL_LM"
|
110 |
+
)
|
111 |
+
```
|
112 |
+
|
113 |
+
Training arguments:
|
114 |
+
```py
|
115 |
+
args = TrainingArguments(
|
116 |
+
output_dir="Qra-7b-dolly-instruction-0.1",
|
117 |
+
num_train_epochs=3,
|
118 |
+
per_device_train_batch_size=1,
|
119 |
+
gradient_accumulation_steps=6,
|
120 |
+
gradient_checkpointing=True,
|
121 |
+
optim="adamw_torch_fused",
|
122 |
+
logging_steps=10,
|
123 |
+
save_strategy="epoch",
|
124 |
+
learning_rate=2e-4,
|
125 |
+
bf16=True,
|
126 |
+
tf32=True,
|
127 |
+
max_grad_norm=0.3,
|
128 |
+
warmup_ratio=0.03,
|
129 |
+
lr_scheduler_type="constant",
|
130 |
+
push_to_hub=False,
|
131 |
+
report_to=["tensorboard"],
|
132 |
+
)
|
133 |
+
```
|
134 |
+
|
135 |
+
|
136 |
+
### Framework versions
|
137 |
+
|
138 |
+
- Transformers 4.39.2
|
139 |
+
- Pytorch 2.2.2+cu121
|
140 |
+
- Datasets 2.18.0
|
141 |
+
- Tokenizers 0.15.2
|