Text Classification
Transformers
Safetensors
English
modernbert
fill-mask
phishing
phishing-detection
spam
spam-detection
email
sms
text-embeddings-inference
Instructions to use CobuildX-AI/cbx-phishing-detector-17M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use CobuildX-AI/cbx-phishing-detector-17M with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="CobuildX-AI/cbx-phishing-detector-17M")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForMaskedLM tokenizer = AutoTokenizer.from_pretrained("CobuildX-AI/cbx-phishing-detector-17M") model = AutoModelForMaskedLM.from_pretrained("CobuildX-AI/cbx-phishing-detector-17M", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Release v0.1
Browse files- LICENSE +201 -0
- NOTICE +32 -0
- README.md +116 -0
- cbx_config.json +91 -0
- cbx_phishing.py +120 -0
- checksums.sha256 +11 -0
- config.json +64 -0
- example.py +15 -0
- model.safetensors +3 -0
- requirements.txt +3 -0
- tokenizer.json +0 -0
- tokenizer_config.json +17 -0
LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Apache License
|
| 2 |
+
Version 2.0, January 2004
|
| 3 |
+
http://www.apache.org/licenses/
|
| 4 |
+
|
| 5 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
| 6 |
+
|
| 7 |
+
1. Definitions.
|
| 8 |
+
|
| 9 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
| 10 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
| 11 |
+
|
| 12 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
| 13 |
+
the copyright owner that is granting the License.
|
| 14 |
+
|
| 15 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
| 16 |
+
other entities that control, are controlled by, or are under common
|
| 17 |
+
control with that entity. For the purposes of this definition,
|
| 18 |
+
"control" means (i) the power, direct or indirect, to cause the
|
| 19 |
+
direction or management of such entity, whether by contract or
|
| 20 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
| 21 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
| 22 |
+
|
| 23 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
| 24 |
+
exercising permissions granted by this License.
|
| 25 |
+
|
| 26 |
+
"Source" form shall mean the preferred form for making modifications,
|
| 27 |
+
including but not limited to software source code, documentation
|
| 28 |
+
source, and configuration files.
|
| 29 |
+
|
| 30 |
+
"Object" form shall mean any form resulting from mechanical
|
| 31 |
+
transformation or translation of a Source form, including but
|
| 32 |
+
not limited to compiled object code, generated documentation,
|
| 33 |
+
and conversions to other media types.
|
| 34 |
+
|
| 35 |
+
"Work" shall mean the work of authorship, whether in Source or
|
| 36 |
+
Object form, made available under the License, as indicated by a
|
| 37 |
+
copyright notice that is included in or attached to the work
|
| 38 |
+
(an example is provided in the Appendix below).
|
| 39 |
+
|
| 40 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
| 41 |
+
form, that is based on (or derived from) the Work and for which the
|
| 42 |
+
editorial revisions, annotations, elaborations, or other modifications
|
| 43 |
+
represent, as a whole, an original work of authorship. For the purposes
|
| 44 |
+
of this License, Derivative Works shall not include works that remain
|
| 45 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
| 46 |
+
the Work and Derivative Works thereof.
|
| 47 |
+
|
| 48 |
+
"Contribution" shall mean any work of authorship, including
|
| 49 |
+
the original version of the Work and any modifications or additions
|
| 50 |
+
to that Work or Derivative Works thereof, that is intentionally
|
| 51 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
| 52 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
| 53 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
| 54 |
+
means any form of electronic, verbal, or written communication sent
|
| 55 |
+
to the Licensor or its representatives, including but not limited to
|
| 56 |
+
communication on electronic mailing lists, source code control systems,
|
| 57 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
| 58 |
+
Licensor for the purpose of discussing and improving the Work, but
|
| 59 |
+
excluding communication that is conspicuously marked or otherwise
|
| 60 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
| 61 |
+
|
| 62 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
| 63 |
+
on behalf of whom a Contribution has been received by Licensor and
|
| 64 |
+
subsequently incorporated within the Work.
|
| 65 |
+
|
| 66 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
| 67 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 68 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 69 |
+
copyright license to reproduce, prepare Derivative Works of,
|
| 70 |
+
publicly display, publicly perform, sublicense, and distribute the
|
| 71 |
+
Work and such Derivative Works in Source or Object form.
|
| 72 |
+
|
| 73 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
| 74 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 75 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 76 |
+
(except as stated in this section) patent license to make, have made,
|
| 77 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
| 78 |
+
where such license applies only to those patent claims licensable
|
| 79 |
+
by such Contributor that are necessarily infringed by their
|
| 80 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
| 81 |
+
with the Work to which such Contribution(s) was submitted. If You
|
| 82 |
+
institute patent litigation against any entity (including a
|
| 83 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
| 84 |
+
or a Contribution incorporated within the Work constitutes direct
|
| 85 |
+
or contributory patent infringement, then any patent licenses
|
| 86 |
+
granted to You under this License for that Work shall terminate
|
| 87 |
+
as of the date such litigation is filed.
|
| 88 |
+
|
| 89 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
| 90 |
+
Work or Derivative Works thereof in any medium, with or without
|
| 91 |
+
modifications, and in Source or Object form, provided that You
|
| 92 |
+
meet the following conditions:
|
| 93 |
+
|
| 94 |
+
(a) You must give any other recipients of the Work or
|
| 95 |
+
Derivative Works a copy of this License; and
|
| 96 |
+
|
| 97 |
+
(b) You must cause any modified files to carry prominent notices
|
| 98 |
+
stating that You changed the files; and
|
| 99 |
+
|
| 100 |
+
(c) You must retain, in the Source form of any Derivative Works
|
| 101 |
+
that You distribute, all copyright, patent, trademark, and
|
| 102 |
+
attribution notices from the Source form of the Work,
|
| 103 |
+
excluding those notices that do not pertain to any part of
|
| 104 |
+
the Derivative Works; and
|
| 105 |
+
|
| 106 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
| 107 |
+
distribution, then any Derivative Works that You distribute must
|
| 108 |
+
include a readable copy of the attribution notices contained
|
| 109 |
+
within such NOTICE file, excluding those notices that do not
|
| 110 |
+
pertain to any part of the Derivative Works, in at least one
|
| 111 |
+
of the following places: within a NOTICE text file distributed
|
| 112 |
+
as part of the Derivative Works; within the Source form or
|
| 113 |
+
documentation, if provided along with the Derivative Works; or,
|
| 114 |
+
within a display generated by the Derivative Works, if and
|
| 115 |
+
wherever such third-party notices normally appear. The contents
|
| 116 |
+
of the NOTICE file are for informational purposes only and
|
| 117 |
+
do not modify the License. You may add Your own attribution
|
| 118 |
+
notices within Derivative Works that You distribute, alongside
|
| 119 |
+
or as an addendum to the NOTICE text from the Work, provided
|
| 120 |
+
that such additional attribution notices cannot be construed
|
| 121 |
+
as modifying the License.
|
| 122 |
+
|
| 123 |
+
You may add Your own copyright statement to Your modifications and
|
| 124 |
+
may provide additional or different license terms and conditions
|
| 125 |
+
for use, reproduction, or distribution of Your modifications, or
|
| 126 |
+
for any such Derivative Works as a whole, provided Your use,
|
| 127 |
+
reproduction, and distribution of the Work otherwise complies with
|
| 128 |
+
the conditions stated in this License.
|
| 129 |
+
|
| 130 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
| 131 |
+
any Contribution intentionally submitted for inclusion in the Work
|
| 132 |
+
by You to the Licensor shall be under the terms and conditions of
|
| 133 |
+
this License, without any additional terms or conditions.
|
| 134 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
| 135 |
+
the terms of any separate license agreement you may have executed
|
| 136 |
+
with Licensor regarding such Contributions.
|
| 137 |
+
|
| 138 |
+
6. Trademarks. This License does not grant permission to use the trade
|
| 139 |
+
names, trademarks, service marks, or product names of the Licensor,
|
| 140 |
+
except as required for reasonable and customary use in describing the
|
| 141 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
| 142 |
+
|
| 143 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
| 144 |
+
agreed to in writing, Licensor provides the Work (and each
|
| 145 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
| 146 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
| 147 |
+
implied, including, without limitation, any warranties or conditions
|
| 148 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
| 149 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
| 150 |
+
appropriateness of using or redistributing the Work and assume any
|
| 151 |
+
risks associated with Your exercise of permissions under this License.
|
| 152 |
+
|
| 153 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
| 154 |
+
whether in tort (including negligence), contract, or otherwise,
|
| 155 |
+
unless required by applicable law (such as deliberate and grossly
|
| 156 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
| 157 |
+
liable to You for damages, including any direct, indirect, special,
|
| 158 |
+
incidental, or consequential damages of any character arising as a
|
| 159 |
+
result of this License or out of the use or inability to use the
|
| 160 |
+
Work (including but not limited to damages for loss of goodwill,
|
| 161 |
+
work stoppage, computer failure or malfunction, or any and all
|
| 162 |
+
other commercial damages or losses), even if such Contributor
|
| 163 |
+
has been advised of the possibility of such damages.
|
| 164 |
+
|
| 165 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
| 166 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
| 167 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
| 168 |
+
or other liability obligations and/or rights consistent with this
|
| 169 |
+
License. However, in accepting such obligations, You may act only
|
| 170 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
| 171 |
+
of any other Contributor, and only if You agree to indemnify,
|
| 172 |
+
defend, and hold each Contributor harmless for any liability
|
| 173 |
+
incurred by, or claims asserted against, such Contributor by reason
|
| 174 |
+
of your accepting any such warranty or additional liability.
|
| 175 |
+
|
| 176 |
+
END OF TERMS AND CONDITIONS
|
| 177 |
+
|
| 178 |
+
APPENDIX: How to apply the Apache License to your work.
|
| 179 |
+
|
| 180 |
+
To apply the Apache License to your work, attach the following
|
| 181 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
| 182 |
+
replaced with your own identifying information. (Don't include
|
| 183 |
+
the brackets!) The text should be enclosed in the appropriate
|
| 184 |
+
comment syntax for the file format. We also recommend that a
|
| 185 |
+
file or class name and description of purpose be included on the
|
| 186 |
+
same "printed page" as the copyright notice for easier
|
| 187 |
+
identification within third-party archives.
|
| 188 |
+
|
| 189 |
+
Copyright [yyyy] [name of copyright owner]
|
| 190 |
+
|
| 191 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 192 |
+
you may not use this file except in compliance with the License.
|
| 193 |
+
You may obtain a copy of the License at
|
| 194 |
+
|
| 195 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
| 196 |
+
|
| 197 |
+
Unless required by applicable law or agreed to in writing, software
|
| 198 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 199 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 200 |
+
See the License for the specific language governing permissions and
|
| 201 |
+
limitations under the License.
|
NOTICE
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cbx-phishing-detector-17M
|
| 2 |
+
Copyright 2026 Cobuild Tech Private Limited.
|
| 3 |
+
|
| 4 |
+
Licensed under the Apache License, Version 2.0 (see LICENSE): the model weights, configuration, tokenizer, scripts and documentation in this repository. Provided "as is", without warranties or conditions of any kind (LICENSE, sections 7 and 8); see "Intended use and disclaimer" in README.md.
|
| 5 |
+
|
| 6 |
+
This model contains or was built from the following third-party materials:
|
| 7 |
+
|
| 8 |
+
1. Ettin encoder (jhu-clsp/ettin-encoder-17m, revision 987607455c61e7a5bbc85f7758e0512ea6d0ae4c), the base model. Copyright (c) 2025 the Ettin authors (Weller, Ricci, Marone, Chaffin, Lawrie, Van Durme). MIT License:
|
| 9 |
+
|
| 10 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
| 11 |
+
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
| 12 |
+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
|
| 13 |
+
persons to whom the Software is furnished to do so, subject to the following conditions:
|
| 14 |
+
|
| 15 |
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
| 16 |
+
Software.
|
| 17 |
+
|
| 18 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
| 19 |
+
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
| 20 |
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
| 21 |
+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
| 22 |
+
|
| 23 |
+
2. Text (not distributed in this repository). The model was trained and tested on text from these datasets, whose authors we thank and credit:
|
| 24 |
+
- SMS Spam Collection, Almeida and Gómez Hidalgo (UCI Machine Learning Repository) (en): https://archive.ics.uci.edu/dataset/228/sms+spam+collection. Licence: CC BY 4.0. Used for: training and testing.
|
| 25 |
+
- Phishing corpus, Jose Nazario (en): https://www.monkey.org/~jose/phishing/. Licence: CC BY 4.0. Used for: validation, testing, and seeds for generated phishing variants (not training).
|
| 26 |
+
- Enron Email Dataset (CMU) (en): https://www.cs.cmu.edu/~enron/. Licence: no licence stated; testing only, not redistributed. Used for: testing.
|
| 27 |
+
- Enron Email Dataset (CMU), separate mailboxes (en): https://www.cs.cmu.edu/~enron/. Licence: no licence stated; not redistributed. Used for: validation (threshold tuning); outlines (message type and length only) for generated email.
|
| 28 |
+
- SpamAssassin public corpus (Apache SpamAssassin project) (en): https://spamassassin.apache.org/old/publiccorpus/. Licence: not stated; testing only, not redistributed. Used for: testing.
|
| 29 |
+
- SpamAssassin public corpus, separate mailboxes (en): https://spamassassin.apache.org/old/publiccorpus/. Licence: not stated; validation only, not redistributed. Used for: validation (threshold tuning), not training.
|
| 30 |
+
No dataset text is distributed with the model. Use of the model does not imply endorsement by any of these authors or publishers.
|
| 31 |
+
|
| 32 |
+
3. Labels. Generated training text: gpt-5.4-mini (OpenAI), Claude Haiku 5.5 (Anthropic), Qwen2.5-7B-Instruct and Mistral-7B-Instruct-v0.3. Label checks: Claude Haiku 5.5 checked the gpt, Qwen and Mistral text; gpt-5.4-mini checked the Haiku text. UCI SMS phishing relabels: Claude Haiku 5.5. Real test labels come from the source datasets, with the phishing in the SpamAssassin spam relabelled by Claude Haiku 5.5 under the same guide.
|
README.md
CHANGED
|
@@ -1,3 +1,119 @@
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
library_name: transformers
|
| 6 |
+
pipeline_tag: text-classification
|
| 7 |
+
base_model: jhu-clsp/ettin-encoder-17m
|
| 8 |
+
tags:
|
| 9 |
+
- phishing
|
| 10 |
+
- phishing-detection
|
| 11 |
+
- spam
|
| 12 |
+
- spam-detection
|
| 13 |
+
- email
|
| 14 |
+
- sms
|
| 15 |
+
- text-classification
|
| 16 |
---
|
| 17 |
+
|
| 18 |
+
# cbx-phishing-detector-17M
|
| 19 |
+
|
| 20 |
+
An English phishing and spam detector for email and SMS. Give it one message (subject and body, or an SMS) and it returns one label: `legitimate`, `spam` (unwanted bulk or promotional mail that does not try to deceive) or `phishing_scam` (a message that tries to trick the reader into giving up credentials, money or personal data, including advance-fee and prize scams). The phishing threshold is set for a chosen false-alarm rate: by default at most about 2% of legitimate messages are flagged as phishing, with 1% and 3% settings included.
|
| 21 |
+
|
| 22 |
+
It has 16.8M parameters: the Ettin encoder 17m fine-tuned on the same data. Other sizes: 68M.
|
| 23 |
+
On a CPU (8 threads, fp32) one short text (63 tokens) takes about 4 ms and a full 512-token text about 25 ms.
|
| 24 |
+
|
| 25 |
+
**Licence: Apache License, Version 2.0.** Read [Intended use and disclaimer](#intended-use-and-disclaimer) before using it.
|
| 26 |
+
|
| 27 |
+
## Labels
|
| 28 |
+
|
| 29 |
+
One label per text. F1 per label on Real messages (below).
|
| 30 |
+
|
| 31 |
+
| Label | Meaning | F1 |
|
| 32 |
+
|---|---|---:|
|
| 33 |
+
| `legitimate` | normal personal, work and transactional mail, including newsletters the reader signed up for | 0.93 |
|
| 34 |
+
| `spam` | unsolicited marketing and bulk promotion, openly priced offers, unsolicited newsletters | 0.63 |
|
| 35 |
+
| `phishing_scam` | credential phishing, fake invoices or deliveries, account-suspension lures, advance-fee, prize, investment and romance scams | 0.80 |
|
| 36 |
+
|
| 37 |
+
Phishing and scams are one label. A message is `phishing_scam` once it tries to deceive the reader into giving up credentials, money or personal data; open promotion without deception is `spam`.
|
| 38 |
+
|
| 39 |
+
## Quick start
|
| 40 |
+
|
| 41 |
+
```bash
|
| 42 |
+
pip install -r requirements.txt
|
| 43 |
+
python example.py
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
+
```python
|
| 47 |
+
from cbx_phishing import PhishingDetector
|
| 48 |
+
|
| 49 |
+
clf = PhishingDetector(".") # folder with the model files; CPU or GPU
|
| 50 |
+
r = clf.classify("Subject: Your mailbox is almost full\n\nDear user, your mailbox has reached 98% of its quota. Incoming messages will be rejected after 24 hours. Verify your account now to keep receiving mail: http://mail-quota-update.example-portal.com/verify")
|
| 51 |
+
r["label"], r["scores"] # top label and the probability of each label
|
| 52 |
+
clf.classify(["first text", "second text"]) # a list gives a list
|
| 53 |
+
```
|
| 54 |
+
|
| 55 |
+
`python example.py` prints (texts invented; any errors are the model's own):
|
| 56 |
+
|
| 57 |
+
```
|
| 58 |
+
phishing_scam 1.00 Subject: Your mailbox is almost full Dear user, your mailbox has reached 98% of its quota. Incoming messages will be rejected after 24 hours. Verify your account now to keep receiving mail: http://mail-quota-update.example-portal.com/verify
|
| 59 |
+
legitimate 1.00 Subject: Re: Thursday planning meeting Hi Priya, thanks for sending the draft. Can we move the meeting to 3 pm? I'll bring the budget numbers. Best, Tom
|
| 60 |
+
spam 1.00 Subject: 40% off all garden furniture this weekend Spring sale! Save 40% on chairs, tables and parasols until Sunday. Free delivery on orders over $99. Shop now at gardenhouse-deals.example.com. Unsubscribe here.
|
| 61 |
+
phishing_scam 0.99 Your parcel could not be delivered. Pay the $1.99 redelivery fee within 12 hours: https://parcel-redeliver.example.top/pay
|
| 62 |
+
legitimate 1.00 Hey, are we still on for dinner tonight? I can pick you up at 7.
|
| 63 |
+
```
|
| 64 |
+
|
| 65 |
+
## Input
|
| 66 |
+
|
| 67 |
+
- One English message. For email, pass `"Subject: <subject>\n\n<body>"`; for SMS, the text. Links can stay in the text. The model reads at most 512 tokens; longer text is cut (`"truncated": True`).
|
| 68 |
+
- Training text replaces personal details with placeholders such as `[NAME]`, `[EMAIL]` and `[PHONE]`; real names and addresses work too.
|
| 69 |
+
- The label comes from a threshold rule in `cbx_config.json` (`decision`): `phishing_scam` if its score reaches the phishing threshold, else `spam` if its score reaches the spam threshold, else `legitimate`. Three named settings are included (`operating_points`): `1%`, `2%` (default) and `3%`. Choose one with `PhishingDetector(".", operating_point="1%")` or `clf.use_operating_point("3%")`.
|
| 70 |
+
|
| 71 |
+
## Evaluation
|
| 72 |
+
|
| 73 |
+
**Real messages:** 6,349 real messages never used in training or for any choice: Enron mail (legitimate), the SpamAssassin public corpus (legitimate, spam and phishing), Jose Nazario's phishing corpus (2025 and any campaign touching 2025) and the UCI SMS Spam Collection test split. Macro F1 is the mean F1 over the 3 labels, at the default 2% setting.
|
| 74 |
+
|
| 75 |
+
**Generated hard cases:** 600 generated messages written to be hard (legitimate security notices, refund and delivery mails, and well-written phishing), held out from training.
|
| 76 |
+
|
| 77 |
+
| Model | Real messages (macro F1) | Generated hard cases (macro F1) |
|
| 78 |
+
|---|---:|---:|
|
| 79 |
+
| 68M (same family) | 0.819 | 1.000 |
|
| 80 |
+
| **this model (17M)** | 0.785 | 0.999 |
|
| 81 |
+
|
| 82 |
+
**Operating points** (Real messages). Each point is a threshold rule tuned on validation to keep the stated false-positive rate. Each cell: recall / precision of the target label, then the false-positive rate measured on this test set:
|
| 83 |
+
|
| 84 |
+
| Model | `1%` | `2%` | `3%` |
|
| 85 |
+
|---|---:|---:|---:|
|
| 86 |
+
| 68M (same family) | 0.83 / 0.87 / 1.6% | 0.87 / 0.84 / 2.5% | 0.89 / 0.80 / 3.5% |
|
| 87 |
+
| **this model (17M)** | 0.69 / 0.91 / 0.8% | 0.75 / 0.85 / 1.8% | 0.78 / 0.81 / 2.8% |
|
| 88 |
+
| cybersectony/phishing-email-detection-distilbert_v2.4.1 (2 classes, no spam) | 0.30 / 0.42 / 0.9% | 0.42 / 0.47 / 1.6% | 0.54 / 0.50 / 2.9% |
|
| 89 |
+
|
| 90 |
+
Recall and precision are for `phishing_scam` against everything else (spam counts as not phishing); the last number is the share of legitimate messages labelled `phishing_scam`. The thresholds were set on a separate validation set of real messages (other Enron and SpamAssassin mailboxes, Nazario and UCI rows), so the measured rate on this test set can land a little above or below the target. cybersectony was scored by us on the same test set, with its phishing threshold tuned on the same validation set in the same way; it has no spam class, and it may have seen older Nazario phishing in its own training.
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
**By channel** (this model, accuracy): email 0.87 (5839 texts), SMS 0.96 (510 texts)
|
| 95 |
+
|
| 96 |
+
## Training data
|
| 97 |
+
|
| 98 |
+
About 50,000 messages. Real: the UCI SMS Spam Collection train split (labels from the dataset, with phishing among the spam relabelled by Claude Haiku 5.5 under our label guide). Generated: English emails, SMS and chat messages for all three labels, written by LLMs from scenario lists, from outlines of real email, and (for phishing) as variants of Jose Nazario's phishing emails, then kept only when a second LLM, not told the intended label, agreed with it. No Nazario email itself is in the training set; Nazario rows are used for validation, testing and as seeds for the generated variants. Enron and SpamAssassin text is never used for training; only short outlines (message type and length, extracted on our own machines) from the non-test Enron mailboxes guided some generated emails. Thresholds were tuned on the real validation set.
|
| 99 |
+
|
| 100 |
+
| Dataset | Languages | Licence | Used for |
|
| 101 |
+
|---|---|---|---|
|
| 102 |
+
| [SMS Spam Collection, Almeida and Gómez Hidalgo (UCI Machine Learning Repository)](https://archive.ics.uci.edu/dataset/228/sms+spam+collection) | en | CC BY 4.0 | training and testing |
|
| 103 |
+
| [Phishing corpus, Jose Nazario](https://www.monkey.org/~jose/phishing/) | en | CC BY 4.0 | validation, testing, and seeds for generated phishing variants (not training) |
|
| 104 |
+
| [Enron Email Dataset (CMU)](https://www.cs.cmu.edu/~enron/) | en | no licence stated; testing only, not redistributed | testing |
|
| 105 |
+
| [Enron Email Dataset (CMU), separate mailboxes](https://www.cs.cmu.edu/~enron/) | en | no licence stated; not redistributed | validation (threshold tuning); outlines (message type and length only) for generated email |
|
| 106 |
+
| [SpamAssassin public corpus (Apache SpamAssassin project)](https://spamassassin.apache.org/old/publiccorpus/) | en | not stated; testing only, not redistributed | testing |
|
| 107 |
+
| [SpamAssassin public corpus, separate mailboxes](https://spamassassin.apache.org/old/publiccorpus/) | en | not stated; validation only, not redistributed | validation (threshold tuning), not training |
|
| 108 |
+
|
| 109 |
+
## Limitations
|
| 110 |
+
|
| 111 |
+
- **Newsletters.** Newsletters and mailing-list digests the reader signed up for are often labelled `spam`; from the text alone they look like unsolicited bulk mail. Spam recall on the real test set is lower than phishing recall for this reason.
|
| 112 |
+
- **Not a complete defence.** At the default setting this model catches 75% of the real test phishing, so some phishing gets through, and some legitimate mail is flagged. Use it alongside sender authentication (SPF, DKIM, DMARC), link and attachment scanning and user reporting.
|
| 113 |
+
- **Text only.** It does not see headers, sender reputation, the real link targets, attachments or images; a phishing message that is only an image or an attachment will not be caught.
|
| 114 |
+
- **English only**, and mostly business and consumer mail. Expect lower accuracy on other languages, on very short or very long messages, and on new phishing styles.
|
| 115 |
+
- **Old test mail.** Part of the real test set (Enron, SpamAssassin) is from the early 2000s; the phishing test set is from 2025.
|
| 116 |
+
|
| 117 |
+
## Intended use and disclaimer
|
| 118 |
+
|
| 119 |
+
**Intended use:** flagging likely phishing and spam in email and SMS for filtering, triage, or warning users, with people able to review and correct. **Not intended** as the only control against phishing, or for decisions about individual people. The model makes mistakes (see Limitations). It is provided "as is", without warranties of any kind; Cobuild Tech Private Limited is not liable for its use. You are responsible for checking that it suits your data and for complying with the laws that apply to your use, including privacy law when you process other people's messages.
|
cbx_config.json
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "cbx-phishing-detector-17M",
|
| 3 |
+
"version": "v0.1",
|
| 4 |
+
"labels": [
|
| 5 |
+
"legitimate",
|
| 6 |
+
"spam",
|
| 7 |
+
"phishing_scam"
|
| 8 |
+
],
|
| 9 |
+
"max_len": 512,
|
| 10 |
+
"decision": {
|
| 11 |
+
"rule": [
|
| 12 |
+
[
|
| 13 |
+
"phishing_scam",
|
| 14 |
+
0.47
|
| 15 |
+
],
|
| 16 |
+
[
|
| 17 |
+
"spam",
|
| 18 |
+
0.81
|
| 19 |
+
]
|
| 20 |
+
],
|
| 21 |
+
"fallback": "legitimate",
|
| 22 |
+
"operating_point": "2%"
|
| 23 |
+
},
|
| 24 |
+
"operating_points": {
|
| 25 |
+
"1%": {
|
| 26 |
+
"rule": [
|
| 27 |
+
[
|
| 28 |
+
"phishing_scam",
|
| 29 |
+
0.79
|
| 30 |
+
],
|
| 31 |
+
[
|
| 32 |
+
"spam",
|
| 33 |
+
0.81
|
| 34 |
+
]
|
| 35 |
+
],
|
| 36 |
+
"fallback": "legitimate",
|
| 37 |
+
"max_fpr": 0.01,
|
| 38 |
+
"limits": "legitimate -> phishing_scam"
|
| 39 |
+
},
|
| 40 |
+
"2%": {
|
| 41 |
+
"rule": [
|
| 42 |
+
[
|
| 43 |
+
"phishing_scam",
|
| 44 |
+
0.47
|
| 45 |
+
],
|
| 46 |
+
[
|
| 47 |
+
"spam",
|
| 48 |
+
0.81
|
| 49 |
+
]
|
| 50 |
+
],
|
| 51 |
+
"fallback": "legitimate",
|
| 52 |
+
"max_fpr": 0.02,
|
| 53 |
+
"limits": "legitimate -> phishing_scam"
|
| 54 |
+
},
|
| 55 |
+
"3%": {
|
| 56 |
+
"rule": [
|
| 57 |
+
[
|
| 58 |
+
"phishing_scam",
|
| 59 |
+
0.26
|
| 60 |
+
],
|
| 61 |
+
[
|
| 62 |
+
"spam",
|
| 63 |
+
0.81
|
| 64 |
+
]
|
| 65 |
+
],
|
| 66 |
+
"fallback": "legitimate",
|
| 67 |
+
"max_fpr": 0.03,
|
| 68 |
+
"limits": "legitimate -> phishing_scam"
|
| 69 |
+
}
|
| 70 |
+
},
|
| 71 |
+
"embedding_rank": null,
|
| 72 |
+
"base_model": "jhu-clsp/ettin-encoder-17m",
|
| 73 |
+
"base_revision": "987607455c61e7a5bbc85f7758e0512ea6d0ae4c",
|
| 74 |
+
"parameters": 16798211,
|
| 75 |
+
"scores": {
|
| 76 |
+
"test_real": {
|
| 77 |
+
"n": 6349,
|
| 78 |
+
"macro_f1": 0.7855
|
| 79 |
+
},
|
| 80 |
+
"test_synth_hard": {
|
| 81 |
+
"n": 600,
|
| 82 |
+
"macro_f1": 0.9992
|
| 83 |
+
}
|
| 84 |
+
},
|
| 85 |
+
"cpu_latency_ms": {
|
| 86 |
+
"threads": 8,
|
| 87 |
+
"short_tokens": 63,
|
| 88 |
+
"short_ms": 4.217343999926015,
|
| 89 |
+
"long_ms": 24.846139500141362
|
| 90 |
+
}
|
| 91 |
+
}
|
cbx_phishing.py
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2026 Cobuild Tech Private Limited
|
| 2 |
+
# SPDX-License-Identifier: Apache-2.0
|
| 3 |
+
"""CBX phishing detector: an English email or SMS in, legitimate / spam / phishing_scam out.
|
| 4 |
+
|
| 5 |
+
from cbx_phishing import PhishingDetector
|
| 6 |
+
clf = PhishingDetector(".") # folder with the model files; CPU or GPU
|
| 7 |
+
clf.classify("Subject: Your mailbox is almost full
|
| 8 |
+
|
| 9 |
+
Dear user, your mailbox has reached 98% of its quota. Incoming messages will be rejected after 24 hours. Verify your account now to keep receiving mail: http://mail-quota-update.example-portal.com/verify")
|
| 10 |
+
|
| 11 |
+
`classify` takes one text (returns one result) or a list (returns a list). A result:
|
| 12 |
+
|
| 13 |
+
{"label": "legitimate", "scores": {"legitimate": 0.9, "spam": 0.01, "phishing_scam": 0.02}, "truncated": False}
|
| 14 |
+
|
| 15 |
+
"label" is the label with the highest score, unless cbx_config.json has a "decision" rule: then the first label in
|
| 16 |
+
the rule whose score reaches its threshold wins, otherwise the rule's fallback label (thresholds tuned on validation;
|
| 17 |
+
see the model card). When cbx_config.json lists "operating_points" (named rules), pick one with
|
| 18 |
+
`PhishingDetector(".", operating_point="<name>")` or `clf.use_operating_point("<name>")`; the default is "decision". "scores" are softmax probabilities that sum to 1. The model reads at most 512 tokens;
|
| 19 |
+
longer text is cut ("truncated": True).
|
| 20 |
+
"""
|
| 21 |
+
import json
|
| 22 |
+
from pathlib import Path
|
| 23 |
+
|
| 24 |
+
import torch
|
| 25 |
+
import torch.nn as nn
|
| 26 |
+
from safetensors.torch import load_file
|
| 27 |
+
from transformers import AutoConfig, AutoModel, AutoTokenizer
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
class _Net(nn.Module):
|
| 31 |
+
def __init__(self, path, cfg):
|
| 32 |
+
super().__init__()
|
| 33 |
+
self.backbone = AutoModel.from_config(AutoConfig.from_pretrained(path), attn_implementation="sdpa")
|
| 34 |
+
h = self.backbone.config.hidden_size
|
| 35 |
+
if cfg.get("embedding_rank"): # factorised word table (smaller sizes)
|
| 36 |
+
self.backbone.embeddings.tok_embeddings = nn.Sequential(
|
| 37 |
+
nn.Embedding(self.backbone.config.vocab_size, cfg["embedding_rank"]),
|
| 38 |
+
nn.Linear(cfg["embedding_rank"], h, bias=False))
|
| 39 |
+
self.head = nn.Linear(h, len(cfg["labels"]))
|
| 40 |
+
|
| 41 |
+
def forward(self, input_ids, attention_mask):
|
| 42 |
+
hs = self.backbone(input_ids=input_ids, attention_mask=attention_mask).last_hidden_state.float()
|
| 43 |
+
m = attention_mask.unsqueeze(-1).float()
|
| 44 |
+
return self.head((hs[:, 0] + (hs * m).sum(1) / m.sum(1).clamp(min=1)) / 2)
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
class PhishingDetector:
|
| 48 |
+
def __init__(self, path=".", device=None, operating_point=None):
|
| 49 |
+
path = Path(path)
|
| 50 |
+
self.cfg = json.loads((path / "cbx_config.json").read_text())
|
| 51 |
+
if operating_point is not None:
|
| 52 |
+
self.use_operating_point(operating_point)
|
| 53 |
+
self.labels = self.cfg["labels"]
|
| 54 |
+
self.max_len = self.cfg["max_len"]
|
| 55 |
+
self.device = device or ("cuda" if torch.cuda.is_available() else "cpu")
|
| 56 |
+
self.tok = AutoTokenizer.from_pretrained(path)
|
| 57 |
+
self.net = _Net(path, self.cfg)
|
| 58 |
+
self.net.load_state_dict(load_file(str(path / "model.safetensors")))
|
| 59 |
+
self.net.to(self.device).eval()
|
| 60 |
+
|
| 61 |
+
@torch.inference_mode()
|
| 62 |
+
def logits(self, texts, max_tokens=16384):
|
| 63 |
+
"""Raw logits [n][labels] in input order, and a truncated flag per text."""
|
| 64 |
+
texts = list(texts)
|
| 65 |
+
full = [len(x) for x in self.tok(texts, verbose=False)["input_ids"]]
|
| 66 |
+
enc = self.tok(texts, truncation=True, max_length=self.max_len, verbose=False)["input_ids"]
|
| 67 |
+
out = [None] * len(enc)
|
| 68 |
+
order = sorted(range(len(enc)), key=lambda i: len(enc[i]))
|
| 69 |
+
i = 0
|
| 70 |
+
while i < len(order):
|
| 71 |
+
j, n = i, 0
|
| 72 |
+
while j < len(order) and (j - i + 1) * max(n, len(enc[order[j]])) <= max_tokens:
|
| 73 |
+
n = max(n, len(enc[order[j]]))
|
| 74 |
+
j += 1
|
| 75 |
+
j = max(j, i + 1)
|
| 76 |
+
idx = order[i:j]
|
| 77 |
+
n = max(len(enc[k]) for k in idx)
|
| 78 |
+
ids = torch.full((len(idx), n), self.tok.pad_token_id, dtype=torch.long)
|
| 79 |
+
mask = torch.zeros((len(idx), n), dtype=torch.long)
|
| 80 |
+
for r, k in enumerate(idx):
|
| 81 |
+
ids[r, :len(enc[k])] = torch.tensor(enc[k])
|
| 82 |
+
mask[r, :len(enc[k])] = 1
|
| 83 |
+
lg = self.net(ids.to(self.device), mask.to(self.device)).float().cpu().tolist()
|
| 84 |
+
for r, k in enumerate(idx):
|
| 85 |
+
out[k] = lg[r]
|
| 86 |
+
i = j
|
| 87 |
+
return out, [f > self.max_len for f in full]
|
| 88 |
+
|
| 89 |
+
def use_operating_point(self, name):
|
| 90 |
+
"""Switch the decision rule to a named operating point from cbx_config.json (see the model card)."""
|
| 91 |
+
pts = self.cfg.get("operating_points") or {}
|
| 92 |
+
if name not in pts:
|
| 93 |
+
raise ValueError(f"unknown operating point {name!r}; available: {sorted(pts)}")
|
| 94 |
+
self.cfg["decision"] = {**pts[name], "operating_point": name}
|
| 95 |
+
|
| 96 |
+
def decide(self, probs):
|
| 97 |
+
"""Label indices from probability rows: the decision rule if the config has one, else the argmax."""
|
| 98 |
+
rule = (self.cfg.get("decision") or {}).get("rule")
|
| 99 |
+
out = []
|
| 100 |
+
for p in probs:
|
| 101 |
+
k = max(range(len(p)), key=p.__getitem__)
|
| 102 |
+
if rule:
|
| 103 |
+
k = self.labels.index(self.cfg["decision"]["fallback"])
|
| 104 |
+
for lab, t in rule:
|
| 105 |
+
if p[self.labels.index(lab)] >= t:
|
| 106 |
+
k = self.labels.index(lab)
|
| 107 |
+
break
|
| 108 |
+
out.append(k)
|
| 109 |
+
return out
|
| 110 |
+
|
| 111 |
+
def classify(self, texts):
|
| 112 |
+
single = isinstance(texts, str)
|
| 113 |
+
texts = [texts] if single else list(texts)
|
| 114 |
+
lg, tr = self.logits(texts)
|
| 115 |
+
out = []
|
| 116 |
+
probs = [torch.softmax(torch.tensor(row), -1).tolist() for row in lg]
|
| 117 |
+
for p, k, t in zip(probs, self.decide(probs), tr):
|
| 118 |
+
out.append({"label": self.labels[k], "scores": {l: round(v, 4) for l, v in zip(self.labels, p)},
|
| 119 |
+
"truncated": t})
|
| 120 |
+
return out[0] if single else out
|
checksums.sha256
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 LICENSE
|
| 2 |
+
63d7f9fdfa0748427193e13f422cc20e9a6888fd91e5cdbf3bd59ed88c9e07d5 NOTICE
|
| 3 |
+
9d877360820b32b107c6c37a24849dedb6f9c64ac892b07e7acb388bbd56c470 README.md
|
| 4 |
+
2d553c0fd97221e96268bfbb1a60009a705b0204e5ae5c4069761ba2642518a5 cbx_config.json
|
| 5 |
+
3ad1bfd33e82a0946c314d8f1f8292e8ef66fac3868774c9f34207cb9f192929 cbx_phishing.py
|
| 6 |
+
84e5c91a5ddaef064cc1a29dae646b30a2b7a6e0624e7e2baf00db70efef8105 config.json
|
| 7 |
+
e1acf09a4ff94f60b9fc987b0aeb03372a393bfbb4acfe23381832bb2bb5ef25 example.py
|
| 8 |
+
f76e039db503ec99033bd2514d3090112606ed372ef8960fb20429c021ad1b51 model.safetensors
|
| 9 |
+
ee71b13268fabbacc0925339898205f92239cf331d3c54ec1f7008f8587bab6f requirements.txt
|
| 10 |
+
ca870c678352403d107496dc78899fa666ed0f56fef63e88ae398fafe5d78c45 tokenizer.json
|
| 11 |
+
5926e6ec4294f80294bd98d9176defa9fbae7f140525d06a1da987488e74a973 tokenizer_config.json
|
config.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"ModernBertForMaskedLM"
|
| 4 |
+
],
|
| 5 |
+
"attention_bias": false,
|
| 6 |
+
"attention_dropout": 0.0,
|
| 7 |
+
"bos_token_id": 50281,
|
| 8 |
+
"causal_mask": false,
|
| 9 |
+
"classifier_activation": "gelu",
|
| 10 |
+
"classifier_bias": false,
|
| 11 |
+
"classifier_dropout": 0.0,
|
| 12 |
+
"classifier_pooling": "mean",
|
| 13 |
+
"cls_token_id": 50281,
|
| 14 |
+
"decoder_bias": true,
|
| 15 |
+
"deterministic_flash_attn": false,
|
| 16 |
+
"dtype": "float32",
|
| 17 |
+
"embedding_dropout": 0.0,
|
| 18 |
+
"eos_token_id": 50282,
|
| 19 |
+
"global_attn_every_n_layers": 3,
|
| 20 |
+
"gradient_checkpointing": false,
|
| 21 |
+
"hidden_activation": "gelu",
|
| 22 |
+
"hidden_size": 256,
|
| 23 |
+
"initializer_cutoff_factor": 2.0,
|
| 24 |
+
"initializer_range": 0.02,
|
| 25 |
+
"intermediate_size": 384,
|
| 26 |
+
"is_causal": false,
|
| 27 |
+
"layer_norm_eps": 1e-05,
|
| 28 |
+
"layer_types": [
|
| 29 |
+
"full_attention",
|
| 30 |
+
"sliding_attention",
|
| 31 |
+
"sliding_attention",
|
| 32 |
+
"full_attention",
|
| 33 |
+
"sliding_attention",
|
| 34 |
+
"sliding_attention",
|
| 35 |
+
"full_attention"
|
| 36 |
+
],
|
| 37 |
+
"local_attention": 128,
|
| 38 |
+
"max_position_embeddings": 7999,
|
| 39 |
+
"mlp_bias": false,
|
| 40 |
+
"mlp_dropout": 0.0,
|
| 41 |
+
"model_type": "modernbert",
|
| 42 |
+
"norm_bias": false,
|
| 43 |
+
"norm_eps": 1e-05,
|
| 44 |
+
"num_attention_heads": 4,
|
| 45 |
+
"num_hidden_layers": 7,
|
| 46 |
+
"pad_token_id": 50283,
|
| 47 |
+
"position_embedding_type": "sans_pos",
|
| 48 |
+
"rope_parameters": {
|
| 49 |
+
"full_attention": {
|
| 50 |
+
"rope_theta": 160000.0,
|
| 51 |
+
"rope_type": "default"
|
| 52 |
+
},
|
| 53 |
+
"sliding_attention": {
|
| 54 |
+
"rope_theta": 160000.0,
|
| 55 |
+
"rope_type": "default"
|
| 56 |
+
}
|
| 57 |
+
},
|
| 58 |
+
"sep_token_id": 50282,
|
| 59 |
+
"sparse_pred_ignore_index": -100,
|
| 60 |
+
"sparse_prediction": false,
|
| 61 |
+
"tie_word_embeddings": true,
|
| 62 |
+
"transformers_version": "5.23.0",
|
| 63 |
+
"vocab_size": 50368
|
| 64 |
+
}
|
example.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2026 Cobuild Tech Private Limited
|
| 2 |
+
# SPDX-License-Identifier: Apache-2.0
|
| 3 |
+
"""Run from the model folder: python example.py (every text below is invented for this example)"""
|
| 4 |
+
from cbx_phishing import PhishingDetector
|
| 5 |
+
|
| 6 |
+
clf = PhishingDetector(".")
|
| 7 |
+
texts = [
|
| 8 |
+
"Subject: Your mailbox is almost full\n\nDear user, your mailbox has reached 98% of its quota. Incoming messages will be rejected after 24 hours. Verify your account now to keep receiving mail: http://mail-quota-update.example-portal.com/verify",
|
| 9 |
+
"Subject: Re: Thursday planning meeting\n\nHi Priya, thanks for sending the draft. Can we move the meeting to 3 pm? I'll bring the budget numbers. Best, Tom",
|
| 10 |
+
"Subject: 40% off all garden furniture this weekend\n\nSpring sale! Save 40% on chairs, tables and parasols until Sunday. Free delivery on orders over $99. Shop now at gardenhouse-deals.example.com. Unsubscribe here.",
|
| 11 |
+
"Your parcel could not be delivered. Pay the $1.99 redelivery fee within 12 hours: https://parcel-redeliver.example.top/pay",
|
| 12 |
+
"Hey, are we still on for dinner tonight? I can pick you up at 7.",
|
| 13 |
+
]
|
| 14 |
+
for text, r in zip(texts, clf.classify(texts)):
|
| 15 |
+
print(f"{r['label']:<9} {max(r['scores'].values()):.2f} {' '.join(text.split())}")
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f76e039db503ec99033bd2514d3090112606ed372ef8960fb20429c021ad1b51
|
| 3 |
+
size 67197540
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
torch>=2.4
|
| 2 |
+
transformers>=5.0
|
| 3 |
+
safetensors>=0.4
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"backend": "tokenizers",
|
| 3 |
+
"clean_up_tokenization_spaces": true,
|
| 4 |
+
"cls_token": "[CLS]",
|
| 5 |
+
"is_local": true,
|
| 6 |
+
"local_files_only": false,
|
| 7 |
+
"mask_token": "[MASK]",
|
| 8 |
+
"model_input_names": [
|
| 9 |
+
"input_ids",
|
| 10 |
+
"attention_mask"
|
| 11 |
+
],
|
| 12 |
+
"model_max_length": 8192,
|
| 13 |
+
"pad_token": "[PAD]",
|
| 14 |
+
"sep_token": "[SEP]",
|
| 15 |
+
"tokenizer_class": "TokenizersBackend",
|
| 16 |
+
"unk_token": "[UNK]"
|
| 17 |
+
}
|