omykhailiv
commited on
Commit
•
6ae5094
1
Parent(s):
a16b9a2
Update README.md
Browse files
README.md
CHANGED
@@ -1,12 +1,17 @@
|
|
1 |
---
|
2 |
library_name: transformers
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
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
|
@@ -14,115 +19,132 @@ tags: []
|
|
14 |
### Model Description
|
15 |
|
16 |
<!-- Provide a longer summary of what this model is. -->
|
|
|
|
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
- **
|
21 |
-
- **
|
22 |
-
- **
|
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 |
-
###
|
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 |
-
|
|
|
|
|
63 |
|
64 |
### Recommendations
|
65 |
|
66 |
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
67 |
-
|
68 |
-
|
|
|
69 |
|
70 |
## How to Get Started with the Model
|
71 |
|
72 |
Use the code below to get started with the model.
|
73 |
|
74 |
-
|
|
|
|
|
75 |
|
76 |
-
|
|
|
|
|
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 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
|
92 |
|
93 |
#### Training Hyperparameters
|
94 |
-
|
95 |
-
|
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 |
-
|
106 |
-
|
107 |
-
### Testing Data, Factors & Metrics
|
108 |
|
109 |
#### Testing Data
|
110 |
|
111 |
<!-- This should link to a Dataset Card if possible. -->
|
112 |
|
113 |
-
|
114 |
-
|
115 |
-
|
|
|
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 |
|
@@ -131,71 +153,6 @@ Use the code below to get started with the model.
|
|
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 |
-
|
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 |
-
|
201 |
-
|
|
|
1 |
---
|
2 |
library_name: transformers
|
3 |
+
license: apache-2.0
|
4 |
+
language:
|
5 |
+
- en
|
6 |
+
metrics:
|
7 |
+
- accuracy
|
8 |
+
pipeline_tag: text-classification
|
9 |
---
|
10 |
|
11 |
# Model Card for Model ID
|
12 |
|
13 |
<!-- Provide a quick summary of what the model is/does. -->
|
14 |
+
Predicts whether the news article's title is fake or real.
|
15 |
|
16 |
|
17 |
## Model Details
|
|
|
19 |
### Model Description
|
20 |
|
21 |
<!-- Provide a longer summary of what this model is. -->
|
22 |
+
This model's purpose is to classify, whether the information, given in the news article, is true or false. It was trained on 2 datasets,
|
23 |
+
combined and preprocessed. 0 (LABEL_0) stands for false and 1 stands for true.
|
24 |
|
25 |
+
- **Developed by:** Ostap Mykhailiv
|
26 |
+
- **Model type:** Classification
|
27 |
+
- **Language(s) (NLP):** English
|
28 |
+
- **License:** apache-2.0
|
29 |
+
- **Finetuned from model:** google-bert/bert-base-uncased
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
+
### Model Usage
|
32 |
+
This model can be used for whatever reason you need, also a site hosted, based on this model is here: (todo)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
## Bias, Risks, and Limitations
|
35 |
|
36 |
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
37 |
+
As a Bert model, this also has bias. It can't be considered as a somewhat state-of-the-art model, because
|
38 |
+
it was trained on old data (about 2022 and older), so it may not be considered as a reliable fake-news checker
|
39 |
+
about military conflicts in Ukraine, Israel, and so on. Please consider, that the names of people in the data were not preprocessed, so
|
40 |
+
it might be also biased toward certain names.
|
41 |
|
42 |
### Recommendations
|
43 |
|
44 |
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
45 |
+
To get better overall results, I decided to make a title truncation in training. Though it increased the overall result for both longer and
|
46 |
+
shorter text, one should not give less than 6 and more than 12 words for predictions, excluding stopwords. For the preprocess operations look below.
|
47 |
+
One can translate news from language into English, though it may not give the expected results.
|
48 |
|
49 |
## How to Get Started with the Model
|
50 |
|
51 |
Use the code below to get started with the model.
|
52 |
|
53 |
+
from transformers import pipeline
|
54 |
+
pipe = pipeline("text-classification", model="omykhailiv/bert-fake-news-recognition")
|
55 |
+
pipe.predict('Some text')
|
56 |
|
57 |
+
It will return something like this:
|
58 |
+
[{'label': 'LABEL_0', 'score': 0.7248537290096283}]
|
59 |
+
Where 'LABEL_0' means false and score means the probability of it.
|
60 |
|
61 |
### Training Data
|
62 |
|
63 |
<!-- 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. -->
|
64 |
+
https://huggingface.co/datasets/GonzaloA/fake_news
|
65 |
+
https://github.com/GeorgeMcIntire/fake_real_news_dataset
|
66 |
+
|
67 |
+
#### Preprocessing
|
68 |
+
Preprocessing was made by using this function:
|
69 |
+
import re
|
70 |
+
import string
|
71 |
+
import spacy
|
72 |
+
from nltk.corpus import stopwords
|
73 |
+
lem = spacy.load('en_core_web_sm')
|
74 |
+
stop_words = set(stopwords.words('english'))
|
75 |
+
def testing_data_prep(text):
|
76 |
+
"""
|
77 |
+
Args:
|
78 |
+
text (str): The input text string.
|
79 |
+
|
80 |
+
Returns:
|
81 |
+
str: The preprocessed text string, or an empty string if the length
|
82 |
+
does not meet the specified criteria (8 to 12 words).
|
83 |
+
"""
|
84 |
+
# Convert text to lowercase for case-insensitive processing
|
85 |
+
text = str(text).lower()
|
86 |
+
|
87 |
+
# Remove HTML tags and their contents (e.g., "<tag>text</tag>")
|
88 |
+
text = re.sub('<.*?>+\w+<.*?>', '', text)
|
89 |
+
|
90 |
+
# Remove punctuation using regular expressions and string escaping
|
91 |
+
text = re.sub('[%s]' % re.escape(string.punctuation), '', text)
|
92 |
+
|
93 |
+
# Remove words containing alphanumeric characters followed by digits
|
94 |
+
# (e.g., "model2023", "data10")
|
95 |
+
text = re.sub('\w*\d\w*', '', text)
|
96 |
+
|
97 |
+
# Remove newline characters
|
98 |
+
text = re.sub('\n', '', text)
|
99 |
+
|
100 |
+
# Replace multiple whitespace characters with a single space
|
101 |
+
text = re.sub('\\s+', ' ', text)
|
102 |
+
|
103 |
+
# Lemmatize words (convert them to their base form)
|
104 |
+
text = lem(text)
|
105 |
+
words = [word.lemma_ for word in text]
|
106 |
+
|
107 |
+
# Removing stopwords, such as do, not, as, etc. (https://gist.github.com/sebleier/554280)
|
108 |
+
new_filtered_words = [
|
109 |
+
word for word in words if word not in stopwords.words('english')]
|
110 |
+
if 12 >= len(new_filtered_words) >= 6:
|
111 |
+
return ' '.join(new_filtered_words)
|
112 |
+
return ' '.join(new_filtered_words)
|
113 |
|
114 |
|
115 |
#### Training Hyperparameters
|
116 |
+
The following hyperparameters were used during training:
|
117 |
+
|
118 |
+
- learning_rate: 2e-5
|
119 |
+
- train_batch_size: 32
|
120 |
+
- eval_batch_size: 32
|
121 |
+
- num_epochs: 5
|
122 |
+
- warmup_steps: 500
|
123 |
+
- weight_decay: 0.03
|
124 |
+
- random seed: 42
|
125 |
+
|
126 |
#### Speeds, Sizes, Times [optional]
|
127 |
|
128 |
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
129 |
|
130 |
[More Information Needed]
|
131 |
|
|
|
132 |
|
133 |
+
### Testing Data, Metrics
|
|
|
|
|
134 |
|
135 |
#### Testing Data
|
136 |
|
137 |
<!-- This should link to a Dataset Card if possible. -->
|
138 |
|
139 |
+
https://huggingface.co/datasets/GonzaloA/fake_news
|
140 |
+
https://github.com/GeorgeMcIntire/fake_real_news_dataset
|
141 |
+
https://onlineacademiccommunity.uvic.ca/isot/2022/11/27/fake-news-detection-datasets/
|
142 |
+
https://arxiv.org/pdf/1806.00749v1, the dataset download link: https://drive.google.com/file/d/0B3e3qZpPtccsMFo5bk9Ib3VCc2c/view?resourcekey=0-_eqAfKOCKbuE-xFFCmEzyg
|
143 |
|
|
|
|
|
|
|
144 |
|
145 |
#### Metrics
|
|
|
146 |
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
147 |
+
Accuracy
|
|
|
148 |
|
149 |
### Results
|
150 |
|
|
|
153 |
#### Summary
|
154 |
|
155 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
#### Hardware
|
157 |
|
158 |
+
Tesla T4 GPU, available for free in Google Collab
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|