rlucatoor commited on
Commit
78c1011
·
0 Parent(s):

initial commit

Browse files
.gitattributes ADDED
@@ -0,0 +1 @@
 
 
1
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: en
3
+ license: mit
4
+ tags:
5
+ - text-classification
6
+ - topic-classification
7
+ - small-model
8
+ - synthetic-data
9
+ - tanaos
10
+ - artifex
11
+ base_model:
12
+ - FacebookAI/roberta-base
13
+ datasets:
14
+ - tanaos/synthetic-topic-classification-dataset-v1
15
+ library_name: transformers
16
+ ---
17
+
18
+ <p align="center">
19
+ <img src="https://raw.githubusercontent.com/tanaos/.github/master/assets/logo.png" width="250px" alt="Tanaos – Train task specific LLMs without training data, for offline NLP and Text Classification">
20
+ </p>
21
+
22
+ # tanaos-topic-classification-v1: A small but performant topic classification model
23
+
24
+ This model was created by Tanaos with the [Artifex Python library](https://github.com/tanaos/artifex).
25
+
26
+ This is a **topic classification model** based on [FacebookAI/roberta-base](https://huggingface.co/FacebookAI/roberta-base) and fine-tuned on [a synthetic dataset](https://huggingface.co/datasets/tanaos/synthetic-topic-classification-dataset-v1) to classify text into one of 15 different intent categories:
27
+
28
+ | Topic | Description |
29
+ |--------|-------------|
30
+ | `politics` | elections, policies, scandals, ideology. |
31
+ | `health` | physical health, mental health, fitness, diets, medical advice. |
32
+ | `technology` | gadgets, software, AI, cybersecurity. |
33
+ | `entertainment` | movies, TV shows, music, celebrities, streaming platforms. |
34
+ | `money_finance` | investing, budgeting, crypto, real estate. |
35
+ | `relationships_dating` | romance, breakups, marriage, family drama. |
36
+ | `education_learning` | schools, universities, self-study, online courses.,
37
+ | `work_careers` | job hunting, workplace culture, remote work, career advice. |
38
+ | `science` | research, space, climate, biology, physics, chemistry and the scientific method. |
39
+ | `society_culture` | identity, inequality, norms, language, and society. |
40
+ | `gaming` | video games, esports, hardware, mods, and gaming culture. |
41
+ | `lifestyle_hobbies` | travel, food, fashion, DIY, productivity systems. |
42
+ | `sports` | teams, athletes, events, scores, and sports culture. |
43
+ | `automotive` | cars, motorcycles, reviews, maintenance, and industry news. |
44
+ | `other` | miscellaneous topics not covered by the other categories. |
45
+
46
+ ## How to Use
47
+
48
+ ### Via the Artifex library (`pip install artifex`)
49
+
50
+ ```python
51
+ from artifex import Artifex
52
+
53
+ topic_classification = Artifex().topic_classification
54
+
55
+ print(topic_classification("What do you think about the latest AI advancements?"))
56
+ # >>> [{'label': 'technology', 'score': 0.9910}]
57
+ ```
58
+
59
+ ### Via the Transformers library
60
+
61
+ ```python
62
+ from transformers import pipeline
63
+
64
+ clf = pipeline("text-classification", model="tanaos/tanaos-topic-classification-v1")
65
+
66
+ print(clf("What do you think about the latest AI advancements?"))
67
+ # >>> [{'label': 'technology', 'score': 0.9910}]
68
+ ```
69
+
70
+ ## Model Description
71
+
72
+ - **Base model:** `FacebookAI/roberta-base`
73
+ - **Task:** Text classification (topic classification)
74
+ - **Languages:** English
75
+ - **Fine-tuning data:** A synthetic, custom dataset of 10,000 utterances, each belonging to one of 15 different topic categories.
76
+
77
+ ## Training Details
78
+
79
+ This model was trained using the [Artifex Python library](https://github.com/tanaos/artifex)
80
+
81
+ ```bash
82
+ pip install artifex
83
+ ```
84
+
85
+ by providing the following instructions and generating 10,000 synthetic training samples:
86
+
87
+ ```python
88
+ from artifex import Artifex
89
+
90
+
91
+ topic_classification = Artifex().topic_classification
92
+
93
+ topic_classification.train(
94
+ domain="general",
95
+ classes={
96
+ "politics": "elections, policies, scandals, ideology",
97
+ "health": "physical health, mental health, fitness, diets, medical advice.",
98
+ "technology": "gadgets, software, AI, cybersecurity.",
99
+ "entertainment": "movies, TV shows, music, celebrities, streaming platforms.",
100
+ "money_finance": "investing, budgeting, crypto, real estate.",
101
+ "relationships_dating": "romance, breakups, marriage, family drama.",
102
+ "education_learning": "schools, universities, self-study, online courses.",
103
+ "work_careers": "job hunting, workplace culture, remote work, career advice.",
104
+ "science": "research, space, climate, biology, physics, chemistry and the scientific method.",
105
+ "society_culture": "identity, inequality, norms, language, and society.",
106
+ "gaming": "video games, esports, hardware, mods, and gaming culture.",
107
+ "lifestyle_hobbies": "travel, food, fashion, DIY, productivity systems.",
108
+ "sports": "teams, athletes, events, scores, and sports culture.",
109
+ "automotive": "cars, motorcycles, reviews, maintenance, and industry news.",
110
+ "other": "miscellaneous topics not covered by the other categories."
111
+ },
112
+ num_samples=10000
113
+ )
114
+ ```
115
+
116
+ ## Intended Uses
117
+
118
+ This model is intended to:
119
+ - Classify conversations, reviews, articles, or any text into one of the predefined topic categories.
120
+ - Be used in applications such as chatbots, content categorization, and sentiment analysis.
121
+ - Serve as a lightweight alternative for topic classification tasks.
122
+
123
+ Not intended for:
124
+ - Use cases requiring extremely high accuracy or domain-specific knowledge without further fine-tuning.
config.json ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "RobertaForSequenceClassification"
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": "politics",
15
+ "1": "health",
16
+ "2": "technology",
17
+ "3": "entertainment",
18
+ "4": "money_finance",
19
+ "5": "relationships_dating",
20
+ "6": "education_learning",
21
+ "7": "work_careers",
22
+ "8": "science",
23
+ "9": "society_culture",
24
+ "10": "gaming",
25
+ "11": "lifestyle_hobbies",
26
+ "12": "sports",
27
+ "13": "automotive",
28
+ "14": "other"
29
+ },
30
+ "initializer_range": 0.02,
31
+ "intermediate_size": 3072,
32
+ "label2id": {
33
+ "automotive": 13,
34
+ "education_learning": 6,
35
+ "entertainment": 3,
36
+ "gaming": 10,
37
+ "health": 1,
38
+ "lifestyle_hobbies": 11,
39
+ "money_finance": 4,
40
+ "other": 14,
41
+ "politics": 0,
42
+ "relationships_dating": 5,
43
+ "science": 8,
44
+ "society_culture": 9,
45
+ "sports": 12,
46
+ "technology": 2,
47
+ "work_careers": 7
48
+ },
49
+ "layer_norm_eps": 1e-05,
50
+ "max_position_embeddings": 514,
51
+ "model_type": "roberta",
52
+ "num_attention_heads": 12,
53
+ "num_hidden_layers": 12,
54
+ "pad_token_id": 1,
55
+ "position_embedding_type": "absolute",
56
+ "problem_type": "single_label_classification",
57
+ "transformers_version": "4.57.3",
58
+ "type_vocab_size": 1,
59
+ "use_cache": true,
60
+ "vocab_size": 50265
61
+ }
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e7668d593244fd9212f063cda17ccbfa7fe2f0283a04adc486568f113b8beb43
3
+ size 498652812
notebook.ipynb ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "id": "b71a1322",
6
+ "metadata": {},
7
+ "source": [
8
+ "# Get started with `tanaos-topic-classification-v1`"
9
+ ]
10
+ },
11
+ {
12
+ "cell_type": "markdown",
13
+ "id": "469712c1",
14
+ "metadata": {},
15
+ "source": [
16
+ "## Option 1 - Use through the [Artifex library](https://github.com/tanaos/artifex)"
17
+ ]
18
+ },
19
+ {
20
+ "cell_type": "code",
21
+ "execution_count": null,
22
+ "id": "c4bfa886",
23
+ "metadata": {
24
+ "vscode": {
25
+ "languageId": "plaintext"
26
+ }
27
+ },
28
+ "outputs": [],
29
+ "source": [
30
+ "!pip install artifex"
31
+ ]
32
+ },
33
+ {
34
+ "cell_type": "code",
35
+ "execution_count": null,
36
+ "id": "7a8f8ec7",
37
+ "metadata": {
38
+ "vscode": {
39
+ "languageId": "plaintext"
40
+ }
41
+ },
42
+ "outputs": [],
43
+ "source": [
44
+ "from artifex import Artifex\n",
45
+ "\n",
46
+ "topic_classification = Artifex().topic_classification\n",
47
+ "\n",
48
+ "print(topic_classification(\"What do you think about the latest AI advancements?\"))"
49
+ ]
50
+ },
51
+ {
52
+ "cell_type": "markdown",
53
+ "id": "afcc6d57",
54
+ "metadata": {},
55
+ "source": [
56
+ "## Option 2 - Use through the Transformers library"
57
+ ]
58
+ },
59
+ {
60
+ "cell_type": "code",
61
+ "execution_count": null,
62
+ "id": "ff2b44c9",
63
+ "metadata": {
64
+ "vscode": {
65
+ "languageId": "plaintext"
66
+ }
67
+ },
68
+ "outputs": [],
69
+ "source": [
70
+ "!pip install transformers"
71
+ ]
72
+ },
73
+ {
74
+ "cell_type": "code",
75
+ "execution_count": null,
76
+ "id": "ae5368d6",
77
+ "metadata": {
78
+ "vscode": {
79
+ "languageId": "plaintext"
80
+ }
81
+ },
82
+ "outputs": [],
83
+ "source": [
84
+ "from transformers import pipeline\n",
85
+ "\n",
86
+ "clf = pipeline(\"text-classification\", model=\"tanaos/tanaos-topic-classification-v1\")\n",
87
+ "\n",
88
+ "print(clf(\"What do you think about the latest AI advancements?\"))"
89
+ ]
90
+ }
91
+ ],
92
+ "metadata": {
93
+ "language_info": {
94
+ "name": "python"
95
+ }
96
+ },
97
+ "nbformat": 4,
98
+ "nbformat_minor": 5
99
+ }
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": 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": 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
+ }
vocab.json ADDED
The diff for this file is too large to render. See raw diff