MBilal-72 commited on
Commit
6bfdcf1
·
verified ·
1 Parent(s): 676f438

Upload 6 files

Browse files

upload model layer2_tinyllama_qlora

README.md CHANGED
@@ -1,3 +1,59 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: TinyLlama/TinyLlama-1.1B-Chat-v1.0
3
+ library_name: peft
4
+ pipeline_tag: text-generation
5
+ tags:
6
+ - lora
7
+ - sft
8
+ - transformers
9
+ - trl
10
+ - security
11
+ - adversarial-defense
12
+ ---
13
+
14
+ # Model Card for Protecher - Layer 2 Aligned Generator
15
+
16
+ ## Model Details
17
+
18
+ ### Model Description
19
+ This model is a QLoRA fine-tuned adapter for `TinyLlama-1.1B-Chat-v1.0`. It serves as "Layer 2" in a 3-Layer Defense-in-Depth architecture designed to protect Large Language Models against adversarial prompt injections and jailbreak attacks. It has been specifically aligned to refuse malicious instructions, illegal requests, and harmful generation while maintaining conversational utility.
20
+
21
+ - **Developed by:** Bilal
22
+ - **Model type:** Causal Language Model (with PEFT/LoRA adapter)
23
+ - **Language(s) (NLP):** English
24
+ - **Finetuned from model:** TinyLlama/TinyLlama-1.1B-Chat-v1.0
25
+
26
+ ## Uses
27
+
28
+ ### Direct Use
29
+ This adapter should be loaded on top of the base TinyLlama 1.1B Chat model. It is designed to act as the core generative brain of a secure chat application. It is strictly trained to identify disguised malicious intents that bypass standard keyword filters.
30
+
31
+ ### Out-of-Scope Use
32
+ This model is highly constrained for security. It is not intended for generating unrestricted creative content, code generation without guardrails, or autonomous agent loops.
33
+
34
+ ## Training Details
35
+
36
+ ### Training Data
37
+ The model was fine-tuned using a custom Hybrid Dataset containing both explicit malicious prompts (jailbreaks, prompt injections) and benign conversational prompts (small talk, greetings, safe queries).
38
+
39
+ ### Training Procedure
40
+ The model was trained using Parameter-Efficient Fine-Tuning (PEFT) specifically utilizing the QLoRA method. The base model was loaded in 4-bit quantization (nf4) to reduce memory overhead, allowing it to be trained efficiently on consumer-grade hardware (NVIDIA T4).
41
+
42
+ #### Training Hyperparameters
43
+ - **Training regime:** QLoRA (r=16, lora_alpha=16)
44
+ - **Precision:** 4-bit mixed precision (fp16 compute dtype)
45
+ - **Epochs:** 3
46
+ - **Optimizer:** AdamW
47
+
48
+ ## Evaluation
49
+
50
+ ### Results
51
+ When deployed as Layer 2 alongside a DistilBERT Pre-Filter (Layer 1) and a Zero-Shot MNLI Output Validator (Layer 3), the end-to-end architecture achieved:
52
+ - **71.43% Drop** in successful Adversarial Attacks.
53
+ - **Overall System Safety Rate:** 84.00%
54
+ - **Latency Efficiency:** 3.6x faster than baseline due to early-stage attack short-circuiting.
55
+
56
+ ### Framework versions
57
+ - PEFT 0.18.1
58
+ - Transformers 4.38.0
59
+ - TRL 0.7.11
adapter_config.json ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alora_invocation_tokens": null,
3
+ "alpha_pattern": {},
4
+ "arrow_config": null,
5
+ "auto_mapping": null,
6
+ "base_model_name_or_path": "TinyLlama/TinyLlama-1.1B-Chat-v1.0",
7
+ "bias": "none",
8
+ "corda_config": null,
9
+ "ensure_weight_tying": false,
10
+ "eva_config": null,
11
+ "exclude_modules": null,
12
+ "fan_in_fan_out": false,
13
+ "inference_mode": true,
14
+ "init_lora_weights": true,
15
+ "layer_replication": null,
16
+ "layers_pattern": null,
17
+ "layers_to_transform": null,
18
+ "loftq_config": {},
19
+ "lora_alpha": 32,
20
+ "lora_bias": false,
21
+ "lora_dropout": 0.05,
22
+ "megatron_config": null,
23
+ "megatron_core": "megatron.core",
24
+ "modules_to_save": null,
25
+ "peft_type": "LORA",
26
+ "peft_version": "0.18.1",
27
+ "qalora_group_size": 16,
28
+ "r": 16,
29
+ "rank_pattern": {},
30
+ "revision": null,
31
+ "target_modules": [
32
+ "q_proj",
33
+ "v_proj"
34
+ ],
35
+ "target_parameters": null,
36
+ "task_type": "CAUSAL_LM",
37
+ "trainable_token_indices": null,
38
+ "use_dora": false,
39
+ "use_qalora": false,
40
+ "use_rslora": false
41
+ }
adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8d184c89980c3957ff6e3c27f7ee262fda991e24558a2c5f361b7e0a823fc65a
3
+ size 9022864
chat_template.jinja ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% for message in messages %}
2
+ {% if message['role'] == 'user' %}
3
+ {{ '<|user|>
4
+ ' + message['content'] + eos_token }}
5
+ {% elif message['role'] == 'system' %}
6
+ {{ '<|system|>
7
+ ' + message['content'] + eos_token }}
8
+ {% elif message['role'] == 'assistant' %}
9
+ {{ '<|assistant|>
10
+ ' + message['content'] + eos_token }}
11
+ {% endif %}
12
+ {% if loop.last and add_generation_prompt %}
13
+ {{ '<|assistant|>' }}
14
+ {% endif %}
15
+ {% endfor %}
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "backend": "tokenizers",
3
+ "bos_token": "<s>",
4
+ "clean_up_tokenization_spaces": false,
5
+ "eos_token": "</s>",
6
+ "is_local": true,
7
+ "legacy": false,
8
+ "model_max_length": 2048,
9
+ "pad_token": "</s>",
10
+ "padding_side": "right",
11
+ "sp_model_kwargs": {},
12
+ "tokenizer_class": "TokenizersBackend",
13
+ "unk_token": "<unk>",
14
+ "use_default_system_prompt": false
15
+ }