palomapiot commited on
Commit
f64ea0e
1 Parent(s): fb159bd

commit files to HF hub

Browse files
README.md CHANGED
@@ -1,3 +1,122 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: peft
3
+ base_model: meta-llama/Llama-2-13b-chat-hf
4
+ license: mit
5
+ datasets:
6
+ - irlab-udc/metahate
7
+ language:
8
+ - en
9
+ pipeline_tag: text-generation
10
+ tags:
11
+ - hate speech
12
+ ---
13
+
14
+ # LLaMA2 Fine-Tuned on not Engaging with Hate Speech
15
+
16
+ ## Model Description
17
+ This model is a fine-tuned version of `meta-llama/Llama-2-13b-chat-hf` on a hate speech dataset using the PEFT approach, to prevent the model from exacerbating hate discourse.
18
+
19
+ ## Intended Uses & Limitations
20
+ This model is intended for research purposes in conversational applications to stop hate speech generation.
21
+
22
+ ## Bias, Risks, and Limitations
23
+
24
+ - **Biases**: The model may carry biases present in the training data.
25
+ - **False Positives/Negatives**: It's not perfect and may continue some hate speech conversations.
26
+ - **Domain Specificity**: Performance may vary across different domains.
27
+
28
+ ## How to Get Started with the Model
29
+
30
+ Use the code below to get started with the model.
31
+
32
+ ```python
33
+ from peft import PeftModel, PeftConfig
34
+ from transformers import AutoModelForCausalLM, AutoTokenizer, Conversation, pipeline
35
+
36
+ # Load the model
37
+ config = PeftConfig.from_pretrained("irlab-udc/LLaMA2-13b-Stop-Hate")
38
+ base_model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-2-13b-chat-hf")
39
+ model = PeftModel.from_pretrained(base_model, "irlab-udc/LLaMA2-13b-Stop-Hate")
40
+ tokenizer = AutoTokenizer.from_pretrained("irlab-udc/LLaMA2-13b-Stop-Hate")
41
+
42
+ # Test the model
43
+ chatbot = pipeline(task="conversational", model=model, tokenizer=tokenizer)
44
+ conversation = Conversation("Your input text here")
45
+ conversation = chatbot(conversation)
46
+ result = conversation.messages[-1]["content"]
47
+ ```
48
+
49
+
50
+ ## Training Details
51
+ - **Base Model:** meta-llama/Llama-2-13b-chat-hf
52
+ - **Fine-Tuning:** Using PEFT approach
53
+ - **Hardware:** NVIDIA RTX A6000
54
+
55
+ #### Configurations and Hyperparameters
56
+
57
+ The following LoraConfig config was used during training:
58
+
59
+ - r: 32
60
+ - lora_alpha: 64
61
+ - target_modules: ["q_proj", "k_proj", "v_proj", "o_proj", "gate_proj", "up_proj", "down_proj", "lm_head"]
62
+ - lora_dropout: 0.05
63
+ - bias: "lora_only"
64
+ - task_type: "CAUSAL_LM"
65
+
66
+ The following TrainingArguments config was used during training:
67
+
68
+ - per_device_train_batch_size: 16
69
+ - gradient_accumulation_steps: 1
70
+ - warmup_steps: 5
71
+ - max_steps: 1000
72
+ - learning_rate: 2.5e-5
73
+ - fp16=True
74
+ - optim= paged_adamw_8bit
75
+
76
+ The following `bitsandbytes` quantization config was used during training:
77
+
78
+ - quant_method: bitsandbytes
79
+ - _load_in_8bit: False
80
+ - _load_in_4bit: True
81
+ - llm_int8_threshold: 6.0
82
+ - llm_int8_skip_modules: None
83
+ - llm_int8_enable_fp32_cpu_offload: False
84
+ - llm_int8_has_fp16_weight: False
85
+ - bnb_4bit_quant_type: nf4
86
+ - bnb_4bit_use_double_quant: True
87
+ - bnb_4bit_compute_dtype: bfloat16
88
+ - bnb_4bit_quant_storage: uint8
89
+ - load_in_4bit: True
90
+ - load_in_8bit: False
91
+
92
+ ### Framework versions
93
+
94
+ - PEFT 0.6.2
95
+ - PyTorch 2.1.0
96
+ - 🤗 Transformers 4.35.0
97
+ - 🤗 Datasets 2.14.6
98
+
99
+
100
+ ## Environmental Impact
101
+
102
+ Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
103
+
104
+ - **Hardware Type:** NVIDIA RTX A6000
105
+ - **Hours used:** 9
106
+ - **Cloud Provider:** Private Infrastructure
107
+ - **Carbon Efficiency (kg/kWh):** 0,432
108
+ - **Carbon Emitted (kg eq. CO2):** 1,17
109
+
110
+
111
+ ## Citation
112
+
113
+ If you use this model, please cite the following reference:
114
+
115
+ ```bibtex
116
+ @article{
117
+ SOON!
118
+ }
119
+ ```
120
+
121
+ ## Acknowledgements
122
+ The authors thank the funding from the Horizon Europe research and innovation programme under the Marie Skłodowska-Curie Grant Agreement No. 101073351. The authors also thank the financial support supplied by the Consellería de Cultura, Educación, Formación Profesional e Universidades (accreditation 2019-2022 ED431G/01, ED431B 2022/33) and the European Regional Development Fund, which acknowledges the CITIC Research Center in ICT of the University of A Coruña as a Research Center of the Galician University System and the project PID2022-137061OB-C21 (Ministerio de Ciencia e Innovación, Agencia Estatal de Investigación, Proyectos de Generación de Conocimiento; supported by the European Regional Development Fund). The authors also thank the funding of project PLEC2021-007662 (MCIN/AEI/10.13039/501100011033, Ministerio de Ciencia e Innovación, Agencia Estatal de Investigación, Plan de Recuperación, Transformación y Resiliencia, Unión Europea-Next Generation EU).
adapter_config.json ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alpha_pattern": {},
3
+ "auto_mapping": null,
4
+ "base_model_name_or_path": "meta-llama/Llama-2-13b-chat-hf",
5
+ "bias": "lora_only",
6
+ "fan_in_fan_out": false,
7
+ "inference_mode": true,
8
+ "init_lora_weights": true,
9
+ "layers_pattern": null,
10
+ "layers_to_transform": null,
11
+ "lora_alpha": 64,
12
+ "lora_dropout": 0.05,
13
+ "modules_to_save": null,
14
+ "peft_type": "LORA",
15
+ "r": 32,
16
+ "rank_pattern": {},
17
+ "revision": null,
18
+ "target_modules": [
19
+ "q_proj",
20
+ "down_proj",
21
+ "v_proj",
22
+ "gate_proj",
23
+ "up_proj",
24
+ "k_proj",
25
+ "o_proj",
26
+ "lm_head"
27
+ ],
28
+ "task_type": "CAUSAL_LM"
29
+ }
adapter_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6a169f22c60115153293d1d0b3a9dbce6fc895043be641f1c6e5834ca0351e41
3
+ size 505649618
special_tokens_map.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<s>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "</s>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": "</s>",
17
+ "unk_token": {
18
+ "content": "<unk>",
19
+ "lstrip": false,
20
+ "normalized": false,
21
+ "rstrip": false,
22
+ "single_word": false
23
+ }
24
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9e556afd44213b6bd1be2b850ebbbd98f5481437a8021afaf58ee7fb1818d347
3
+ size 499723
tokenizer_config.json ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": true,
3
+ "add_eos_token": true,
4
+ "added_tokens_decoder": {
5
+ "0": {
6
+ "content": "<unk>",
7
+ "lstrip": false,
8
+ "normalized": false,
9
+ "rstrip": false,
10
+ "single_word": false,
11
+ "special": true
12
+ },
13
+ "1": {
14
+ "content": "<s>",
15
+ "lstrip": false,
16
+ "normalized": false,
17
+ "rstrip": false,
18
+ "single_word": false,
19
+ "special": true
20
+ },
21
+ "2": {
22
+ "content": "</s>",
23
+ "lstrip": false,
24
+ "normalized": false,
25
+ "rstrip": false,
26
+ "single_word": false,
27
+ "special": true
28
+ }
29
+ },
30
+ "bos_token": "<s>",
31
+ "chat_template": "{% if messages[0]['role'] == 'system' %}{% set loop_messages = messages[1:] %}{% set system_message = messages[0]['content'] %}{% else %}{% set loop_messages = messages %}{% set system_message = false %}{% endif %}{% for message in loop_messages %}{% if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}{{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}{% endif %}{% if loop.index0 == 0 and system_message != false %}{% set content = '<<SYS>>\\n' + system_message + '\\n<</SYS>>\\n\\n' + message['content'] %}{% else %}{% set content = message['content'] %}{% endif %}{% if message['role'] == 'user' %}{{ bos_token + '[INST] ' + content.strip() + ' [/INST]' }}{% elif message['role'] == 'assistant' %}{{ ' ' + content.strip() + ' ' + eos_token }}{% endif %}{% endfor %}",
32
+ "clean_up_tokenization_spaces": false,
33
+ "eos_token": "</s>",
34
+ "legacy": false,
35
+ "model_max_length": 512,
36
+ "pad_token": "</s>",
37
+ "padding_side": "left",
38
+ "sp_model_kwargs": {},
39
+ "tokenizer_class": "LlamaTokenizer",
40
+ "unk_token": "<unk>",
41
+ "use_default_system_prompt": false
42
+ }