VinMir commited on
Commit
cb056ea
·
1 Parent(s): e49663c

Added model files for sentiment

Browse files
LICENSE.md ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # LICENSE
2
+
3
+ SOFTWARE LICENSE AGREEMENT
4
+
5
+ Copyright (c) 2024 Vincenzo Miracula. All Rights Reserved.
6
+
7
+ By using this software, you agree to the following terms and conditions:
8
+
9
+ 1. You are granted a non-exclusive, non-transferable license to use this software for personal, non-commercial purposes only.
10
+ 2. You may not modify, distribute, or reverse-engineer the software.
11
+ 3. You may not sell, lease, sublicense, or otherwise transfer the software to any third party.
12
+ 4. This software is provided "as is" without any warranty, express or implied, including but not limited to the warranties of merchantability or fitness for a particular purpose.
13
+ 5. The copyright notice and this license agreement must be retained in all copies or substantial portions of the software.
14
+
15
+ For further inquiries or permissions, please contact the copyright holder.
MANIFEST.in ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ recursive-include GordonAI/models/sentiment *
2
+ recursive-include GordonAI/models/emotion *
3
+ recursive-include GordonAI/models/factchecker *
4
+ include README.md
5
+ include LICENSE
README.md CHANGED
@@ -1,3 +1,78 @@
1
- ---
2
- license: cc-by-4.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # GordonAI
2
+
3
+ GordonAI is an AI package designed for sentiment analysis, emotion detection, and fact-checking classification. The models are pre-trained on three languages: **Italian**, **English**, and **Spanish**.
4
+
5
+ ## Features
6
+
7
+ - **Sentiment Analysis**: Classifies text into three categories: **positive**, **negative**, and **neutral**.
8
+ - **Emotion Detection**: Identifies the six basic emotions defined by Paul Ekman (1992): **joy**, **sadness**, **fear**, **anger**, **surprise**, **disgust** (plus **neutral**).
9
+ - **Fact-Checking Classification**: Classifies text into **disinformation**, **hoax**, **fake news**, or **true news**.
10
+
11
+ ## Installation
12
+
13
+ You can install the package using `pip`. Simply run the following command:
14
+
15
+ ```bash
16
+ pip install GordonAI
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ### Sentiment Analysis
22
+
23
+ You can use the `SentimentAnalyzer` to predict the sentiment of a text. The analyzer classifies texts as positive, negative, or neutral.
24
+
25
+ ```python
26
+ from GordonAI.models import SentimentAnalyzer
27
+ # Initialize the sentiment analyzer
28
+ analyzer = SentimentAnalyzer()
29
+ # Predict sentiment of a list of texts
30
+ result = analyzer.predict(["This is a great product!", "This is a terrible mistake."])
31
+ # Output the predictions
32
+ print(result)
33
+ ```
34
+
35
+ ### Emotion Detection
36
+
37
+ You can use the `EmotionAnalyzer` to predict the emotion of a text. The analyzer classifies texts as joy, sadness, fear, anger, surprise, disgust or neutral.
38
+
39
+ ```python
40
+ from GordonAI.models import EmotionAnalyzer
41
+ # Initialize the emotion analyzer
42
+ emotion_analyzer = EmotionAnalyzer()
43
+ # Predict emotions of a list of texts
44
+ result = emotion_analyzer.predict(["I'm so happy today!", "I'm feeling really sad."])
45
+ # Output the predictions
46
+ print(result)
47
+ ```
48
+
49
+ ### Fact-Checking Classification
50
+ You can use the `FactAnalyzer` to predict whether a texts or a claim falls into categories like disinformation, fake news, hoax, or true news.
51
+
52
+ ```python
53
+ from GordonAI.models import FactAnalyzer
54
+ # Initialize the emotion analyzer
55
+ fact_analyzer = FactAnalyzer()
56
+ # Predict emotions of a list of texts
57
+ result = fact_analyzer.predict(["This news story is about a real event.", "This news article is based on fake information."])
58
+ # Output the predictions
59
+ print(result)
60
+ ```
61
+
62
+ ## Requirements
63
+ Python >= 3.9
64
+ transformers
65
+ torch
66
+
67
+ You can install the dependencies using:
68
+ ```bash
69
+ pip install transformers torch
70
+ ```
71
+
72
+ ## Acknowledgments
73
+
74
+ This package is part of the work for my doctoral thesis. I would like to thank **NeoData** and **Università di Catania** for their valuable contributions to the development of this project.
75
+
76
+
77
+
78
+
added_tokens.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {
2
+ "[MASK]": 128000
3
+ }
config.json ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "microsoft/deberta-v3-large",
3
+ "architectures": [
4
+ "DebertaV2ForSequenceClassification"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "hidden_act": "gelu",
8
+ "hidden_dropout_prob": 0.1,
9
+ "hidden_size": 1024,
10
+ "id2label": {
11
+ "0": "LABEL_0",
12
+ "1": "LABEL_1",
13
+ "2": "LABEL_2"
14
+ },
15
+ "initializer_range": 0.02,
16
+ "intermediate_size": 4096,
17
+ "label2id": {
18
+ "LABEL_0": 0,
19
+ "LABEL_1": 1,
20
+ "LABEL_2": 2
21
+ },
22
+ "layer_norm_eps": 1e-07,
23
+ "max_position_embeddings": 512,
24
+ "max_relative_positions": -1,
25
+ "model_type": "deberta-v2",
26
+ "norm_rel_ebd": "layer_norm",
27
+ "num_attention_heads": 16,
28
+ "num_hidden_layers": 24,
29
+ "pad_token_id": 0,
30
+ "pooler_dropout": 0,
31
+ "pooler_hidden_act": "gelu",
32
+ "pooler_hidden_size": 1024,
33
+ "pos_att_type": [
34
+ "p2c",
35
+ "c2p"
36
+ ],
37
+ "position_biased_input": false,
38
+ "position_buckets": 256,
39
+ "relative_attention": true,
40
+ "share_att_key": true,
41
+ "torch_dtype": "float32",
42
+ "transformers_version": "4.44.2",
43
+ "type_vocab_size": 0,
44
+ "vocab_size": 128100
45
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:73082a4efd62700ff17fe9c218df11b7f7acda6c5359d5ba88cce0638ea5cd19
3
+ size 1740308548
special_tokens_map.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "[CLS]",
3
+ "cls_token": "[CLS]",
4
+ "eos_token": "[SEP]",
5
+ "mask_token": "[MASK]",
6
+ "pad_token": "[PAD]",
7
+ "sep_token": "[SEP]",
8
+ "unk_token": {
9
+ "content": "[UNK]",
10
+ "lstrip": false,
11
+ "normalized": true,
12
+ "rstrip": false,
13
+ "single_word": false
14
+ }
15
+ }
spm.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c679fbf93643d19aab7ee10c0b99e460bdbc02fedf34b92b05af343b4af586fd
3
+ size 2464616
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
+ "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
+ "1": {
12
+ "content": "[CLS]",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "2": {
20
+ "content": "[SEP]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "3": {
28
+ "content": "[UNK]",
29
+ "lstrip": false,
30
+ "normalized": true,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "128000": {
36
+ "content": "[MASK]",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "bos_token": "[CLS]",
45
+ "clean_up_tokenization_spaces": true,
46
+ "cls_token": "[CLS]",
47
+ "do_lower_case": false,
48
+ "eos_token": "[SEP]",
49
+ "mask_token": "[MASK]",
50
+ "model_max_length": 1000000000000000019884624838656,
51
+ "pad_token": "[PAD]",
52
+ "sep_token": "[SEP]",
53
+ "sp_model_kwargs": {},
54
+ "split_by_punct": false,
55
+ "tokenizer_class": "DebertaV2Tokenizer",
56
+ "unk_token": "[UNK]",
57
+ "vocab_type": "spm"
58
+ }