File size: 3,828 Bytes
fedfd47 435665c fedfd47 4639d41 435665c fedfd47 435665c fedfd47 435665c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
---
library_name: peft
license: apache-2.0
datasets:
- knkarthick/dialogsum
pipeline_tag: summarization
---
## About the Model
LLama-2 7B is finetuned using SFT to generate summaries from conversations.
## Useage with Transformers
```python
from transformers import AutoTokenizer, AutoModelForCausalLM
import transformers
from peft import PeftModel
# Quantization config
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype="float16",
)
model_name = "TinyPixel/Llama-2-7B-bf16-sharded"
# loading the model with quantization config
model = AutoModelForCausalLM.from_pretrained(
model_name,
quantization_config=bnb_config,
trust_remote_code=True,
device_map='auto'
)
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True , return_token_type_ids=False)
tokenizer.pad_token = tokenizer.eos_token
model = PeftModel.from_pretrained(model,"shenoy/DialogSumLlama2_qlora", device_map="auto")
text = """### Instruction:
Write a concise summary of the below input text.Return your response in bullet points which covers the key points of the text.
### Input:
#Person1#: Ms. Dawson, I need you to take a dictation for me.
#Person2#: Yes, sir...
#Person1#: This should go out as an intra-office memorandum to all employees by this afternoon. Are you ready?
#Person2#: Yes, sir. Go ahead.
#Person1#: Attention all staff... Effective immediately, all office communications are restricted to email correspondence and official memos. The use of Instant Message programs by employees during working hours is strictly prohibited.
#Person2#: Sir, does this apply to intra-office communications only? Or will it also restrict external communications?
#Person1#: It should apply to all communications, not only in this office between employees, but also any outside communications.
#Person2#: But sir, many employees use Instant Messaging to communicate with their clients.
#Person1#: They will just have to change their communication methods. I don't want any - one using Instant Messaging in this office. It wastes too much time! Now, please continue with the memo. Where were we?
#Person2#: This applies to internal and external communications.
#Person1#: Yes. Any employee who persists in using Instant Messaging will first receive a warning and be placed on probation. At second offense, the employee will face termination. Any questions regarding this new policy may be directed to department heads.
#Person2#: Is that all?
#Person1#: Yes. Please get this memo typed up and distributed to all employees before 4 pm.
### Response :"""
inputs = tokenizer(text, return_tensors="pt")
outputs = model.generate(input_ids=inputs['input_ids'], attention_mask=inputs['attention_mask'], max_new_tokens=100 ,repetition_penalty=1.2)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
```
---
## Training procedure
Training Configuration:
- `per_device_train_batch_size`: 4
- `gradient_accumulation_steps`: 4
- `optim`: "paged_adamw_8bit"
- `learning_rate`: 2e-4
- `lr_scheduler_type`: "linear"
- `save_strategy`: "epoch"
- `logging_steps`: 10
- `num_train_epochs`: 2
- `max_steps`: 50
- `fp16`: True
LORA Configuration:
- `lora_alpha`: 16
- `lora_dropout`: 0.05
- `target_modules`: ["q_proj", "v_proj"]
- `r`: 8
- `bias`: "none"
- `task_type`: "CAUSAL_LM"
The following `bitsandbytes` quantization config was used during training:
- load_in_8bit: False
- load_in_4bit: True
- llm_int8_threshold: 6.0
- llm_int8_skip_modules: None
- llm_int8_enable_fp32_cpu_offload: False
- llm_int8_has_fp16_weight: False
- bnb_4bit_quant_type: nf4
- bnb_4bit_use_double_quant: False
- bnb_4bit_compute_dtype: float16
### Framework versions
- `accelerate` 0.21.0
- `peft` 0.4.0
- `bitsandbytes` 0.40.2
- `transformers` 4.30.2
- `trl` 0.4.7 |