OneZero-Y commited on
Commit
92e6e7d
·
verified ·
1 Parent(s): a189300

Upload lora_pii_detector_roberta-base_model LoRA model

Browse files
README.md ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model: roberta-base
4
+ tags:
5
+ - lora
6
+ - semantic-router
7
+ - pii-classification
8
+ - text-classification
9
+ - candle
10
+ - rust
11
+ language:
12
+ - en
13
+ pipeline_tag: text-classification
14
+ library_name: candle
15
+ ---
16
+
17
+ # lora_pii_detector_roberta-base_model
18
+
19
+ ## Model Description
20
+
21
+ This is a LoRA (Low-Rank Adaptation) fine-tuned model based on **roberta-base** for PII Detection - Detects personally identifiable information in text using token classification.
22
+
23
+ This model is part of the [semantic-router](https://github.com/vllm-project/semantic-router) project and is optimized for use with the Candle framework in Rust.
24
+
25
+ ## Model Details
26
+
27
+ - **Base Model**: roberta-base
28
+ - **Task**: Pii Classification
29
+ - **Framework**: Candle (Rust)
30
+ - **Model Size**: ~473MB
31
+ - **LoRA Rank**: 16
32
+ - **LoRA Alpha**: 32
33
+ - **Target Modules**: attention.self.query, attention.self.value, attention.output.dense, intermediate.dense, output.dense
34
+
35
+ ## Usage
36
+
37
+ ### With semantic-router (Recommended)
38
+
39
+ ```python
40
+ from semantic_router import SemanticRouter
41
+
42
+ # The model will be automatically downloaded and used
43
+ router = SemanticRouter()
44
+ results = router.classify_batch(["Your text here"])
45
+ ```
46
+
47
+ ### With Candle (Rust)
48
+
49
+ ```rust
50
+ use candle_core::{Device, Tensor};
51
+ use candle_transformers::models::bert::BertModel;
52
+
53
+ // Load the model using Candle
54
+ let device = Device::Cpu;
55
+ let model = BertModel::load(&device, &config, &weights)?;
56
+ ```
57
+
58
+ ## Training Details
59
+
60
+ This model was fine-tuned using LoRA (Low-Rank Adaptation) technique:
61
+
62
+ - **Rank**: 16
63
+ - **Alpha**: 32
64
+ - **Dropout**: 0.1
65
+ - **Target Modules**: attention.self.query, attention.self.value, attention.output.dense, intermediate.dense, output.dense
66
+
67
+ ## Performance
68
+
69
+ PII Detection - Detects personally identifiable information in text using token classification
70
+
71
+ For detailed performance metrics, see the [training results](https://github.com/vllm-project/semantic-router/blob/main/training-result.md).
72
+
73
+ ## Files
74
+
75
+ - `model.safetensors`: LoRA adapter weights
76
+ - `config.json`: Model configuration
77
+ - `lora_config.json`: LoRA-specific configuration
78
+ - `tokenizer.json`: Tokenizer configuration
79
+ - `label_mapping.json`: Label mappings for classification
80
+
81
+ ## Citation
82
+
83
+ If you use this model, please cite:
84
+
85
+ ```bibtex
86
+ @misc{semantic-router-lora,
87
+ title={LoRA Fine-tuned Models for Semantic Router},
88
+ author={Semantic Router Team},
89
+ year={2025},
90
+ url={https://github.com/vllm-project/semantic-router}
91
+ }
92
+ ```
93
+
94
+ ## License
95
+
96
+ Apache 2.0
config.json ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "RobertaForTokenClassification"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.1,
6
+ "bos_token_id": 0,
7
+ "classifier_dropout": null,
8
+ "dtype": "float32",
9
+ "eos_token_id": 2,
10
+ "hidden_act": "gelu",
11
+ "hidden_dropout_prob": 0.1,
12
+ "hidden_size": 768,
13
+ "id2label": {
14
+ "0": "O",
15
+ "1": "B-AGE",
16
+ "2": "I-AGE",
17
+ "3": "B-CREDIT_CARD",
18
+ "4": "I-CREDIT_CARD",
19
+ "5": "B-DATE_TIME",
20
+ "6": "I-DATE_TIME",
21
+ "7": "B-DOMAIN_NAME",
22
+ "8": "I-DOMAIN_NAME",
23
+ "9": "B-EMAIL_ADDRESS",
24
+ "10": "I-EMAIL_ADDRESS",
25
+ "11": "B-GPE",
26
+ "12": "I-GPE",
27
+ "13": "B-IBAN_CODE",
28
+ "14": "I-IBAN_CODE",
29
+ "15": "B-IP_ADDRESS",
30
+ "16": "I-IP_ADDRESS",
31
+ "17": "B-NRP",
32
+ "18": "I-NRP",
33
+ "19": "B-ORGANIZATION",
34
+ "20": "I-ORGANIZATION",
35
+ "21": "B-PERSON",
36
+ "22": "I-PERSON",
37
+ "23": "B-PHONE_NUMBER",
38
+ "24": "I-PHONE_NUMBER",
39
+ "25": "B-STREET_ADDRESS",
40
+ "26": "I-STREET_ADDRESS",
41
+ "27": "B-TITLE",
42
+ "28": "I-TITLE",
43
+ "29": "B-US_DRIVER_LICENSE",
44
+ "30": "I-US_DRIVER_LICENSE",
45
+ "31": "B-US_SSN",
46
+ "32": "I-US_SSN",
47
+ "33": "B-ZIP_CODE",
48
+ "34": "I-ZIP_CODE"
49
+ },
50
+ "initializer_range": 0.02,
51
+ "intermediate_size": 3072,
52
+ "label2id": {
53
+ "O": 0,
54
+ "B-AGE": 1,
55
+ "I-AGE": 2,
56
+ "B-CREDIT_CARD": 3,
57
+ "I-CREDIT_CARD": 4,
58
+ "B-DATE_TIME": 5,
59
+ "I-DATE_TIME": 6,
60
+ "B-DOMAIN_NAME": 7,
61
+ "I-DOMAIN_NAME": 8,
62
+ "B-EMAIL_ADDRESS": 9,
63
+ "I-EMAIL_ADDRESS": 10,
64
+ "B-GPE": 11,
65
+ "I-GPE": 12,
66
+ "B-IBAN_CODE": 13,
67
+ "I-IBAN_CODE": 14,
68
+ "B-IP_ADDRESS": 15,
69
+ "I-IP_ADDRESS": 16,
70
+ "B-NRP": 17,
71
+ "I-NRP": 18,
72
+ "B-ORGANIZATION": 19,
73
+ "I-ORGANIZATION": 20,
74
+ "B-PERSON": 21,
75
+ "I-PERSON": 22,
76
+ "B-PHONE_NUMBER": 23,
77
+ "I-PHONE_NUMBER": 24,
78
+ "B-STREET_ADDRESS": 25,
79
+ "I-STREET_ADDRESS": 26,
80
+ "B-TITLE": 27,
81
+ "I-TITLE": 28,
82
+ "B-US_DRIVER_LICENSE": 29,
83
+ "I-US_DRIVER_LICENSE": 30,
84
+ "B-US_SSN": 31,
85
+ "I-US_SSN": 32,
86
+ "B-ZIP_CODE": 33,
87
+ "I-ZIP_CODE": 34
88
+ },
89
+ "layer_norm_eps": 1e-05,
90
+ "max_position_embeddings": 514,
91
+ "model_type": "roberta",
92
+ "num_attention_heads": 12,
93
+ "num_hidden_layers": 12,
94
+ "pad_token_id": 1,
95
+ "position_embedding_type": "absolute",
96
+ "transformers_version": "4.56.1",
97
+ "type_vocab_size": 1,
98
+ "use_cache": true,
99
+ "vocab_size": 50265
100
+ }
label_mapping.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"label_to_id": {"O": 0, "B-AGE": 1, "I-AGE": 2, "B-CREDIT_CARD": 3, "I-CREDIT_CARD": 4, "B-DATE_TIME": 5, "I-DATE_TIME": 6, "B-DOMAIN_NAME": 7, "I-DOMAIN_NAME": 8, "B-EMAIL_ADDRESS": 9, "I-EMAIL_ADDRESS": 10, "B-GPE": 11, "I-GPE": 12, "B-IBAN_CODE": 13, "I-IBAN_CODE": 14, "B-IP_ADDRESS": 15, "I-IP_ADDRESS": 16, "B-NRP": 17, "I-NRP": 18, "B-ORGANIZATION": 19, "I-ORGANIZATION": 20, "B-PERSON": 21, "I-PERSON": 22, "B-PHONE_NUMBER": 23, "I-PHONE_NUMBER": 24, "B-STREET_ADDRESS": 25, "I-STREET_ADDRESS": 26, "B-TITLE": 27, "I-TITLE": 28, "B-US_DRIVER_LICENSE": 29, "I-US_DRIVER_LICENSE": 30, "B-US_SSN": 31, "I-US_SSN": 32, "B-ZIP_CODE": 33, "I-ZIP_CODE": 34}, "id_to_label": {"0": "O", "1": "B-AGE", "2": "I-AGE", "3": "B-CREDIT_CARD", "4": "I-CREDIT_CARD", "5": "B-DATE_TIME", "6": "I-DATE_TIME", "7": "B-DOMAIN_NAME", "8": "I-DOMAIN_NAME", "9": "B-EMAIL_ADDRESS", "10": "I-EMAIL_ADDRESS", "11": "B-GPE", "12": "I-GPE", "13": "B-IBAN_CODE", "14": "I-IBAN_CODE", "15": "B-IP_ADDRESS", "16": "I-IP_ADDRESS", "17": "B-NRP", "18": "I-NRP", "19": "B-ORGANIZATION", "20": "I-ORGANIZATION", "21": "B-PERSON", "22": "I-PERSON", "23": "B-PHONE_NUMBER", "24": "I-PHONE_NUMBER", "25": "B-STREET_ADDRESS", "26": "I-STREET_ADDRESS", "27": "B-TITLE", "28": "I-TITLE", "29": "B-US_DRIVER_LICENSE", "30": "I-US_DRIVER_LICENSE", "31": "B-US_SSN", "32": "I-US_SSN", "33": "B-ZIP_CODE", "34": "I-ZIP_CODE"}}
lora_config.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"rank": 16, "alpha": 32, "dropout": 0.1, "target_modules": ["attention.self.query", "attention.self.value", "attention.output.dense", "intermediate.dense", "output.dense"]}
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:eddb62f761ed51d93ac4cd9079f41869e11e5042f460011b0b760edb94b8f065
3
+ size 496351756
special_tokens_map.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "<s>",
3
+ "cls_token": "<s>",
4
+ "eos_token": "</s>",
5
+ "mask_token": {
6
+ "content": "<mask>",
7
+ "lstrip": true,
8
+ "normalized": false,
9
+ "rstrip": false,
10
+ "single_word": false
11
+ },
12
+ "pad_token": "<pad>",
13
+ "sep_token": "</s>",
14
+ "unk_token": "<unk>"
15
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": true,
3
+ "added_tokens_decoder": {
4
+ "0": {
5
+ "content": "<s>",
6
+ "lstrip": false,
7
+ "normalized": true,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ },
12
+ "1": {
13
+ "content": "<pad>",
14
+ "lstrip": false,
15
+ "normalized": true,
16
+ "rstrip": false,
17
+ "single_word": false,
18
+ "special": true
19
+ },
20
+ "2": {
21
+ "content": "</s>",
22
+ "lstrip": false,
23
+ "normalized": true,
24
+ "rstrip": false,
25
+ "single_word": false,
26
+ "special": true
27
+ },
28
+ "3": {
29
+ "content": "<unk>",
30
+ "lstrip": false,
31
+ "normalized": true,
32
+ "rstrip": false,
33
+ "single_word": false,
34
+ "special": true
35
+ },
36
+ "50264": {
37
+ "content": "<mask>",
38
+ "lstrip": true,
39
+ "normalized": false,
40
+ "rstrip": false,
41
+ "single_word": false,
42
+ "special": true
43
+ }
44
+ },
45
+ "bos_token": "<s>",
46
+ "clean_up_tokenization_spaces": false,
47
+ "cls_token": "<s>",
48
+ "eos_token": "</s>",
49
+ "errors": "replace",
50
+ "extra_special_tokens": {},
51
+ "mask_token": "<mask>",
52
+ "model_max_length": 512,
53
+ "pad_token": "<pad>",
54
+ "sep_token": "</s>",
55
+ "tokenizer_class": "RobertaTokenizer",
56
+ "trim_offsets": true,
57
+ "unk_token": "<unk>"
58
+ }