Commit ·
c1ce783
0
Parent(s):
minor fix
Browse files- .gitattributes +1 -0
- README.md +78 -0
- config.json +33 -0
- model.safetensors +3 -0
- notebook.ipynb +59 -0
- special_tokens_map.json +7 -0
- tokenizer.json +0 -0
- tokenizer_config.json +56 -0
- vocab.txt +0 -0
.gitattributes
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: en
|
| 3 |
+
license: mit
|
| 4 |
+
tags:
|
| 5 |
+
- text-classification
|
| 6 |
+
- spam-detection
|
| 7 |
+
- content-moderation
|
| 8 |
+
- small-model
|
| 9 |
+
- tanaos
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
<p align="center">
|
| 13 |
+
<img src="https://raw.githubusercontent.com/tanaos/.github/master/assets/logo.png" width="250px" alt="Tanaos – Private Small Language Models for all your needs">
|
| 14 |
+
</p>
|
| 15 |
+
|
| 16 |
+
# A small, private Spam Detection model for English text
|
| 17 |
+
|
| 18 |
+
This is a **spam detection model** trained to classify English text as ***spam*** or ***not_spam***. It is intended to be used as a first-layer spam filter for email systems, messaging applications or any other text-based communication platform.
|
| 19 |
+
|
| 20 |
+
The following categories are considered spam:
|
| 21 |
+
|
| 22 |
+
1. Unsolicited commercial advertisement or non-commercial proselytizing.
|
| 23 |
+
2. Fraudulent schemes. including get-rich-quick and pyramid schemes.
|
| 24 |
+
3. Phishing attempts. unrealistic offers or announcements.
|
| 25 |
+
4. Content with deceptive or misleading information.
|
| 26 |
+
5. Malware or harmful links.
|
| 27 |
+
6. Adult content or explicit material.
|
| 28 |
+
7. Excessive use of capitalization or punctuation to grab attention.
|
| 29 |
+
|
| 30 |
+
## Why you should use this model
|
| 31 |
+
|
| 32 |
+
This model can be used 100% locally on CPU. No processing is done in the cloud, and no data is sent to any third party. This makes it ideal for applications where privacy is a concern, or where internet connectivity is limited.
|
| 33 |
+
|
| 34 |
+
<!-- ## Languages
|
| 35 |
+
|
| 36 |
+
The main model language is English, but we have spam detection models specialized in other languages as well:
|
| 37 |
+
- Spanish: [https://huggingface.co/tanaos/tanaos-spam-detection-spanish](https://huggingface.co/tanaos/tanaos-spam-detection-spanish) -->
|
| 38 |
+
|
| 39 |
+
## How to Use
|
| 40 |
+
|
| 41 |
+
1. Sign up for a free account at [https://platform.tanaos.com/](https://platform.tanaos.com/)
|
| 42 |
+
2. Create a free API Key from the [API Keys section](https://platform.tanaos.com/profile/api-keys)
|
| 43 |
+
3. Download the [`tanaos_spam_detection_english-0.1.0-py3-none-any.whl` file](https://huggingface.co/tanaos/tanaos-spam-detection-v1/resolve/main/tanaos_spam_detection_english-0.1.0-py3-none-any.whl?download=true)
|
| 44 |
+
4. Install the model
|
| 45 |
+
```bash
|
| 46 |
+
uv init
|
| 47 |
+
uv add tanaos_spam_detection_english-0.1.0-py3-none-any.whl
|
| 48 |
+
#--- Linux/MacOS ---
|
| 49 |
+
source .venv/bin/activate
|
| 50 |
+
#--- Windows ---
|
| 51 |
+
.venv\Scripts\activate
|
| 52 |
+
```
|
| 53 |
+
5. Warm up the model for faster inference (optional but recommended):
|
| 54 |
+
```bash
|
| 55 |
+
python -m tanaos_spam_detection_english --api-key <YOUR_API_KEY> --serve
|
| 56 |
+
```
|
| 57 |
+
This will start a local IPC server that serves the model. Inference will be faster for as long as the server is running. Simply type CTRL+C to stop the local server when you're done.
|
| 58 |
+
6. Use the model for inference:
|
| 59 |
+
```python
|
| 60 |
+
from tanaos_spam_detection_english import run_inference
|
| 61 |
+
|
| 62 |
+
result = run_inference(
|
| 63 |
+
text="You won an IPhone 16! Click here to claim your prize.",
|
| 64 |
+
api_key="<YOUR_API_KEY>"
|
| 65 |
+
)
|
| 66 |
+
print(result)
|
| 67 |
+
|
| 68 |
+
# >>> [{'label': 'spam', 'confidence': 0.9975}]
|
| 69 |
+
```
|
| 70 |
+
|
| 71 |
+
## Intended Uses
|
| 72 |
+
|
| 73 |
+
This model is intended to:
|
| 74 |
+
- Serve as a first-layer spam filter for email systems, messaging applications, or any other text-based communication platform.
|
| 75 |
+
- Help reduce unwanted or harmful messages by classifying text as spam or not spam.
|
| 76 |
+
|
| 77 |
+
Not intended for:
|
| 78 |
+
- Use in high-stakes scenarios where misclassification could lead to significant consequences without further human review.
|
config.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"activation": "gelu",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"DistilBertForSequenceClassification"
|
| 5 |
+
],
|
| 6 |
+
"attention_dropout": 0.1,
|
| 7 |
+
"dim": 768,
|
| 8 |
+
"dropout": 0.1,
|
| 9 |
+
"dtype": "float32",
|
| 10 |
+
"hidden_dim": 3072,
|
| 11 |
+
"id2label": {
|
| 12 |
+
"0": "not_spam",
|
| 13 |
+
"1": "spam"
|
| 14 |
+
},
|
| 15 |
+
"initializer_range": 0.02,
|
| 16 |
+
"label2id": {
|
| 17 |
+
"not_spam": 0,
|
| 18 |
+
"spam": 1
|
| 19 |
+
},
|
| 20 |
+
"max_position_embeddings": 512,
|
| 21 |
+
"model_type": "distilbert",
|
| 22 |
+
"n_heads": 12,
|
| 23 |
+
"n_layers": 6,
|
| 24 |
+
"output_past": true,
|
| 25 |
+
"pad_token_id": 0,
|
| 26 |
+
"problem_type": "single_label_classification",
|
| 27 |
+
"qa_dropout": 0.1,
|
| 28 |
+
"seq_classif_dropout": 0.2,
|
| 29 |
+
"sinusoidal_pos_embds": false,
|
| 30 |
+
"tie_weights_": true,
|
| 31 |
+
"transformers_version": "4.57.3",
|
| 32 |
+
"vocab_size": 119547
|
| 33 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:55f90cf08bd50f0bdce1f545953ed9f6c94f9fe8bf989d591a1b880eb639917a
|
| 3 |
+
size 541317368
|
notebook.ipynb
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "markdown",
|
| 5 |
+
"id": "b71a1322",
|
| 6 |
+
"metadata": {},
|
| 7 |
+
"source": [
|
| 8 |
+
"# Get started with `tanaos-spam-detection-v1`"
|
| 9 |
+
]
|
| 10 |
+
},
|
| 11 |
+
{
|
| 12 |
+
"cell_type": "markdown",
|
| 13 |
+
"id": "23bacd31",
|
| 14 |
+
"metadata": {},
|
| 15 |
+
"source": [
|
| 16 |
+
"Use this model for free via the [Tanaos API](https://tanaos.com/) in 3 simple steps:\n",
|
| 17 |
+
"\n",
|
| 18 |
+
"1. Sign up for a free account at [https://platform.tanaos.com/](https://platform.tanaos.com/)\n",
|
| 19 |
+
"2. Create a free API Key from the [API Keys section](https://platform.tanaos.com/profile/api-keys)\n",
|
| 20 |
+
"3. Replace `<YOUR_API_KEY>` in the code below with your API Key and use this snippet:\n"
|
| 21 |
+
]
|
| 22 |
+
},
|
| 23 |
+
{
|
| 24 |
+
"cell_type": "code",
|
| 25 |
+
"execution_count": null,
|
| 26 |
+
"id": "814ab3a8",
|
| 27 |
+
"metadata": {
|
| 28 |
+
"vscode": {
|
| 29 |
+
"languageId": "plaintext"
|
| 30 |
+
}
|
| 31 |
+
},
|
| 32 |
+
"outputs": [],
|
| 33 |
+
"source": [
|
| 34 |
+
"import requests\n",
|
| 35 |
+
"\n",
|
| 36 |
+
"session = requests.Session()\n",
|
| 37 |
+
"\n",
|
| 38 |
+
"sd_out = session.post(\n",
|
| 39 |
+
" \"https://slm.tanaos.com/models/spam-detection\",\n",
|
| 40 |
+
" headers={\n",
|
| 41 |
+
" \"X-API-Key\": \"<YOUR_API_KEY>\",\n",
|
| 42 |
+
" },\n",
|
| 43 |
+
" json={\n",
|
| 44 |
+
" \"text\": \"You won an IPhone 16! Click here to claim your prize.\"\n",
|
| 45 |
+
" }\n",
|
| 46 |
+
")\n",
|
| 47 |
+
"\n",
|
| 48 |
+
"print(sd_out.json()[\"data\"])"
|
| 49 |
+
]
|
| 50 |
+
}
|
| 51 |
+
],
|
| 52 |
+
"metadata": {
|
| 53 |
+
"language_info": {
|
| 54 |
+
"name": "python"
|
| 55 |
+
}
|
| 56 |
+
},
|
| 57 |
+
"nbformat": 4,
|
| 58 |
+
"nbformat_minor": 5
|
| 59 |
+
}
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cls_token": "[CLS]",
|
| 3 |
+
"mask_token": "[MASK]",
|
| 4 |
+
"pad_token": "[PAD]",
|
| 5 |
+
"sep_token": "[SEP]",
|
| 6 |
+
"unk_token": "[UNK]"
|
| 7 |
+
}
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"added_tokens_decoder": {
|
| 3 |
+
"0": {
|
| 4 |
+
"content": "[PAD]",
|
| 5 |
+
"lstrip": false,
|
| 6 |
+
"normalized": false,
|
| 7 |
+
"rstrip": false,
|
| 8 |
+
"single_word": false,
|
| 9 |
+
"special": true
|
| 10 |
+
},
|
| 11 |
+
"100": {
|
| 12 |
+
"content": "[UNK]",
|
| 13 |
+
"lstrip": false,
|
| 14 |
+
"normalized": false,
|
| 15 |
+
"rstrip": false,
|
| 16 |
+
"single_word": false,
|
| 17 |
+
"special": true
|
| 18 |
+
},
|
| 19 |
+
"101": {
|
| 20 |
+
"content": "[CLS]",
|
| 21 |
+
"lstrip": false,
|
| 22 |
+
"normalized": false,
|
| 23 |
+
"rstrip": false,
|
| 24 |
+
"single_word": false,
|
| 25 |
+
"special": true
|
| 26 |
+
},
|
| 27 |
+
"102": {
|
| 28 |
+
"content": "[SEP]",
|
| 29 |
+
"lstrip": false,
|
| 30 |
+
"normalized": false,
|
| 31 |
+
"rstrip": false,
|
| 32 |
+
"single_word": false,
|
| 33 |
+
"special": true
|
| 34 |
+
},
|
| 35 |
+
"103": {
|
| 36 |
+
"content": "[MASK]",
|
| 37 |
+
"lstrip": false,
|
| 38 |
+
"normalized": false,
|
| 39 |
+
"rstrip": false,
|
| 40 |
+
"single_word": false,
|
| 41 |
+
"special": true
|
| 42 |
+
}
|
| 43 |
+
},
|
| 44 |
+
"clean_up_tokenization_spaces": false,
|
| 45 |
+
"cls_token": "[CLS]",
|
| 46 |
+
"do_lower_case": false,
|
| 47 |
+
"extra_special_tokens": {},
|
| 48 |
+
"mask_token": "[MASK]",
|
| 49 |
+
"model_max_length": 512,
|
| 50 |
+
"pad_token": "[PAD]",
|
| 51 |
+
"sep_token": "[SEP]",
|
| 52 |
+
"strip_accents": null,
|
| 53 |
+
"tokenize_chinese_chars": true,
|
| 54 |
+
"tokenizer_class": "DistilBertTokenizer",
|
| 55 |
+
"unk_token": "[UNK]"
|
| 56 |
+
}
|
vocab.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|