Irshadcse2k16 commited on
Commit
2f9781d
·
verified ·
1 Parent(s): df8494d

Upload 11 files

Browse files
app.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from transformers import RobertaTokenizerFast, RobertaForSequenceClassification
3
+ from peft import PeftModel, PeftConfig
4
+ import gradio as gr
5
+
6
+ def predict_phishing_url(url_to_predict, model_path="./roberta_classifier"):
7
+ config = PeftConfig.from_pretrained(model_path)
8
+ inference_model = RobertaForSequenceClassification.from_pretrained(config.base_model_name_or_path, num_labels=2)
9
+ inference_model = PeftModel.from_pretrained(inference_model, model_path)
10
+ inference_tokenizer = RobertaTokenizerFast.from_pretrained(model_path)
11
+
12
+ inference_model.to("cpu")
13
+ inference_model.eval()
14
+
15
+ inputs = inference_tokenizer(url_to_predict, padding='max_length', truncation=True, max_length=128, return_tensors="pt").to("cpu")
16
+
17
+ with torch.no_grad():
18
+ outputs = inference_model(**inputs)
19
+ predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
20
+ predicted_class_id = torch.argmax(predictions).item()
21
+ probability_phishing = predictions[0, 1].item()
22
+
23
+ result = "Phishing" if predicted_class_id == 1 else "Legitimate"
24
+ return f"{result} (Confidence: {probability_phishing:.2f})"
25
+
26
+ # Gradio interface
27
+ iface = gr.Interface(
28
+ fn=predict_phishing_url,
29
+ inputs=gr.Textbox(lines=1, placeholder="Enter URL..."),
30
+ outputs="text",
31
+ title="Phishing URL Detector",
32
+ description="Enter a URL to classify it as Phishing or Legitimate using RoBERTa-LoRA model."
33
+ )
34
+
35
+ iface.launch()
36
+
requirements.txt ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ accelerate==1.7.0
2
+ aiohappyeyeballs==2.6.1
3
+ aiohttp==3.12.0
4
+ aiosignal==1.3.2
5
+ anyio==4.9.0
6
+ argon2-cffi==23.1.0
7
+ argon2-cffi-bindings==21.2.0
8
+ arrow==1.3.0
9
+ asttokens==3.0.0
10
+ async-lru==2.0.5
11
+ async-timeout==5.0.1
12
+ attrs==25.3.0
13
+ babel==2.17.0
14
+ beautifulsoup4==4.13.4
15
+ bleach==6.2.0
16
+ certifi @ file:///croot/certifi_1745939216646/work/certifi
17
+ cffi==1.17.1
18
+ charset-normalizer @ file:///croot/charset-normalizer_1721748349566/work
19
+ comm==0.2.2
20
+ contourpy==1.3.2
21
+ cycler==0.12.1
22
+ datasets==3.6.0
23
+ debugpy==1.8.14
24
+ decorator==5.2.1
25
+ defusedxml==0.7.1
26
+ dill==0.3.8
27
+ exceptiongroup==1.3.0
28
+ executing==2.2.0
29
+ fastjsonschema==2.21.1
30
+ filelock @ file:///croot/filelock_1744281381737/work
31
+ fonttools==4.58.0
32
+ fqdn==1.5.1
33
+ frozenlist==1.6.0
34
+ fsspec==2025.3.0
35
+ gmpy2 @ file:///croot/gmpy2_1738085463648/work
36
+ h11==0.16.0
37
+ hf-xet==1.1.2
38
+ httpcore==1.0.9
39
+ httpx==0.28.1
40
+ huggingface-hub==0.32.0
41
+ idna @ file:///croot/idna_1714398848350/work
42
+ ipykernel==6.29.5
43
+ ipython==8.36.0
44
+ ipywidgets==8.1.7
45
+ isoduration==20.11.0
46
+ jedi==0.19.2
47
+ Jinja2 @ file:///croot/jinja2_1741710844255/work
48
+ joblib==1.5.1
49
+ json5==0.12.0
50
+ jsonpointer==3.0.0
51
+ jsonschema==4.23.0
52
+ jsonschema-specifications==2025.4.1
53
+ jupyter==1.1.1
54
+ jupyter-console==6.6.3
55
+ jupyter-events==0.12.0
56
+ jupyter-lsp==2.2.5
57
+ jupyter_client==8.6.3
58
+ jupyter_core==5.7.2
59
+ jupyter_server==2.16.0
60
+ jupyter_server_terminals==0.5.3
61
+ jupyterlab==4.4.2
62
+ jupyterlab_pygments==0.3.0
63
+ jupyterlab_server==2.27.3
64
+ jupyterlab_widgets==3.0.15
65
+ kiwisolver==1.4.8
66
+ MarkupSafe @ file:///croot/markupsafe_1738584038848/work
67
+ matplotlib==3.10.3
68
+ matplotlib-inline==0.1.7
69
+ mistune==3.1.3
70
+ mkl-service==2.4.0
71
+ mkl_fft @ file:///io/mkl313/mkl_fft_1730824109137/work
72
+ mkl_random @ file:///io/mkl313/mkl_random_1730823916628/work
73
+ mpmath @ file:///croot/mpmath_1690848262763/work
74
+ multidict==6.4.4
75
+ multiprocess==0.70.16
76
+ nbclient==0.10.2
77
+ nbconvert==7.16.6
78
+ nbformat==5.10.4
79
+ nest-asyncio==1.6.0
80
+ networkx @ file:///croot/networkx_1737039604450/work
81
+ notebook==7.4.2
82
+ notebook_shim==0.2.4
83
+ numpy @ file:///croot/numpy_and_numpy_base_1725470312869/work/dist/numpy-2.0.1-cp310-cp310-linux_x86_64.whl#sha256=120568f3fd675f59e4cb6de79a5c193b4067d90878d8bab2040fda8e3a2df6fa
84
+ overrides==7.7.0
85
+ packaging==25.0
86
+ pandas==2.2.3
87
+ pandocfilters==1.5.1
88
+ parso==0.8.4
89
+ peft==0.15.2
90
+ pexpect==4.9.0
91
+ pillow @ file:///croot/pillow_1744613067434/work
92
+ platformdirs==4.3.8
93
+ prometheus_client==0.22.0
94
+ prompt_toolkit==3.0.51
95
+ propcache==0.3.1
96
+ psutil==7.0.0
97
+ ptyprocess==0.7.0
98
+ pure_eval==0.2.3
99
+ pyarrow==20.0.0
100
+ pycparser==2.22
101
+ Pygments==2.19.1
102
+ pyparsing==3.2.3
103
+ PySocks @ file:///home/builder/ci_310/pysocks_1640793678128/work
104
+ python-dateutil==2.9.0.post0
105
+ python-json-logger==3.3.0
106
+ pytz==2025.2
107
+ PyYAML @ file:///croot/pyyaml_1728657952215/work
108
+ pyzmq==26.4.0
109
+ referencing==0.36.2
110
+ regex==2024.11.6
111
+ requests @ file:///croot/requests_1730999120400/work
112
+ rfc3339-validator==0.1.4
113
+ rfc3986-validator==0.1.1
114
+ rpds-py==0.25.1
115
+ safetensors==0.5.3
116
+ scikit-learn==1.6.1
117
+ scipy==1.15.3
118
+ seaborn==0.13.2
119
+ Send2Trash==1.8.3
120
+ six==1.17.0
121
+ sniffio==1.3.1
122
+ soupsieve==2.7
123
+ stack-data==0.6.3
124
+ sympy==1.13.1
125
+ terminado==0.18.1
126
+ threadpoolctl==3.6.0
127
+ tinycss2==1.4.0
128
+ tokenizers==0.21.1
129
+ tomli==2.2.1
130
+ torch==2.5.1
131
+ torchaudio==2.5.1
132
+ torchvision==0.20.1
133
+ tornado==6.5.1
134
+ tqdm==4.67.1
135
+ traitlets==5.14.3
136
+ transformers==4.52.3
137
+ triton==3.1.0
138
+ types-python-dateutil==2.9.0.20250516
139
+ typing_extensions @ file:///croot/typing_extensions_1734714854207/work
140
+ tzdata==2025.2
141
+ uri-template==1.3.0
142
+ urllib3 @ file:///croot/urllib3_1737133630106/work
143
+ wcwidth==0.2.13
144
+ webcolors==24.11.1
145
+ webencodings==0.5.1
146
+ websocket-client==1.8.0
147
+ widgetsnbextension==4.0.14
148
+ xxhash==3.5.0
149
+ yarl==1.20.0
roberta_classifier/README.md ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: roberta-base
3
+ library_name: peft
4
+ ---
5
+
6
+ # Model Card for Model ID
7
+
8
+ <!-- Provide a quick summary of what the model is/does. -->
9
+
10
+
11
+
12
+ ## Model Details
13
+
14
+ ### Model Description
15
+
16
+ <!-- Provide a longer summary of what this model is. -->
17
+
18
+
19
+
20
+ - **Developed by:** [More Information Needed]
21
+ - **Funded by [optional]:** [More Information Needed]
22
+ - **Shared by [optional]:** [More Information Needed]
23
+ - **Model type:** [More Information Needed]
24
+ - **Language(s) (NLP):** [More Information Needed]
25
+ - **License:** [More Information Needed]
26
+ - **Finetuned from model [optional]:** [More Information Needed]
27
+
28
+ ### Model Sources [optional]
29
+
30
+ <!-- Provide the basic links for the model. -->
31
+
32
+ - **Repository:** [More Information Needed]
33
+ - **Paper [optional]:** [More Information Needed]
34
+ - **Demo [optional]:** [More Information Needed]
35
+
36
+ ## Uses
37
+
38
+ <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
+
40
+ ### Direct Use
41
+
42
+ <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
+
44
+ [More Information Needed]
45
+
46
+ ### Downstream Use [optional]
47
+
48
+ <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
+
50
+ [More Information Needed]
51
+
52
+ ### Out-of-Scope Use
53
+
54
+ <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
+
56
+ [More Information Needed]
57
+
58
+ ## Bias, Risks, and Limitations
59
+
60
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
+
62
+ [More Information Needed]
63
+
64
+ ### Recommendations
65
+
66
+ <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
+
68
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
+
70
+ ## How to Get Started with the Model
71
+
72
+ Use the code below to get started with the model.
73
+
74
+ [More Information Needed]
75
+
76
+ ## Training Details
77
+
78
+ ### Training Data
79
+
80
+ <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
+
82
+ [More Information Needed]
83
+
84
+ ### Training Procedure
85
+
86
+ <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
+
88
+ #### Preprocessing [optional]
89
+
90
+ [More Information Needed]
91
+
92
+
93
+ #### Training Hyperparameters
94
+
95
+ - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
+
97
+ #### Speeds, Sizes, Times [optional]
98
+
99
+ <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
+
101
+ [More Information Needed]
102
+
103
+ ## Evaluation
104
+
105
+ <!-- This section describes the evaluation protocols and provides the results. -->
106
+
107
+ ### Testing Data, Factors & Metrics
108
+
109
+ #### Testing Data
110
+
111
+ <!-- This should link to a Dataset Card if possible. -->
112
+
113
+ [More Information Needed]
114
+
115
+ #### Factors
116
+
117
+ <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
+
119
+ [More Information Needed]
120
+
121
+ #### Metrics
122
+
123
+ <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
+
125
+ [More Information Needed]
126
+
127
+ ### Results
128
+
129
+ [More Information Needed]
130
+
131
+ #### Summary
132
+
133
+
134
+
135
+ ## Model Examination [optional]
136
+
137
+ <!-- Relevant interpretability work for the model goes here -->
138
+
139
+ [More Information Needed]
140
+
141
+ ## Environmental Impact
142
+
143
+ <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
+
145
+ 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).
146
+
147
+ - **Hardware Type:** [More Information Needed]
148
+ - **Hours used:** [More Information Needed]
149
+ - **Cloud Provider:** [More Information Needed]
150
+ - **Compute Region:** [More Information Needed]
151
+ - **Carbon Emitted:** [More Information Needed]
152
+
153
+ ## Technical Specifications [optional]
154
+
155
+ ### Model Architecture and Objective
156
+
157
+ [More Information Needed]
158
+
159
+ ### Compute Infrastructure
160
+
161
+ [More Information Needed]
162
+
163
+ #### Hardware
164
+
165
+ [More Information Needed]
166
+
167
+ #### Software
168
+
169
+ [More Information Needed]
170
+
171
+ ## Citation [optional]
172
+
173
+ <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
+
175
+ **BibTeX:**
176
+
177
+ [More Information Needed]
178
+
179
+ **APA:**
180
+
181
+ [More Information Needed]
182
+
183
+ ## Glossary [optional]
184
+
185
+ <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
+
187
+ [More Information Needed]
188
+
189
+ ## More Information [optional]
190
+
191
+ [More Information Needed]
192
+
193
+ ## Model Card Authors [optional]
194
+
195
+ [More Information Needed]
196
+
197
+ ## Model Card Contact
198
+
199
+ [More Information Needed]
200
+ ### Framework versions
201
+
202
+ - PEFT 0.12.0
roberta_classifier/adapter_config.json ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alpha_pattern": {},
3
+ "auto_mapping": null,
4
+ "base_model_name_or_path": "roberta-base",
5
+ "bias": "none",
6
+ "fan_in_fan_out": false,
7
+ "inference_mode": true,
8
+ "init_lora_weights": true,
9
+ "layer_replication": null,
10
+ "layers_pattern": null,
11
+ "layers_to_transform": null,
12
+ "loftq_config": {},
13
+ "lora_alpha": 32,
14
+ "lora_dropout": 0.05,
15
+ "megatron_config": null,
16
+ "megatron_core": "megatron.core",
17
+ "modules_to_save": [
18
+ "classifier",
19
+ "score"
20
+ ],
21
+ "peft_type": "LORA",
22
+ "r": 8,
23
+ "rank_pattern": {},
24
+ "revision": null,
25
+ "target_modules": [
26
+ "value",
27
+ "query"
28
+ ],
29
+ "task_type": "SEQ_CLS",
30
+ "use_dora": false,
31
+ "use_rslora": false
32
+ }
roberta_classifier/adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0a6ce7d7ff34da99997e1a5f2f370f65c696d300baf215d535577b61e9b252ff
3
+ size 3555504
roberta_classifier/merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
roberta_classifier/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
+ }
roberta_classifier/tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
roberta_classifier/tokenizer_config.json ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
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": true,
47
+ "cls_token": "<s>",
48
+ "eos_token": "</s>",
49
+ "errors": "replace",
50
+ "mask_token": "<mask>",
51
+ "model_max_length": 512,
52
+ "pad_token": "<pad>",
53
+ "sep_token": "</s>",
54
+ "tokenizer_class": "RobertaTokenizer",
55
+ "trim_offsets": true,
56
+ "unk_token": "<unk>"
57
+ }
roberta_classifier/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:46f37f0e45713ed68865f1e7a893aceb9712e4544f612ae9dc4673423bd9d048
3
+ size 5176
roberta_classifier/vocab.json ADDED
The diff for this file is too large to render. See raw diff