AyoubChLin commited on
Commit
e282d16
1 Parent(s): 010c788

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +45 -0
README.md CHANGED
@@ -1,3 +1,48 @@
1
  ---
2
  license: apache-2.0
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
+ datasets:
4
+ - AyoubChLin/CNN_News_Articles_2011-2022
5
+ language:
6
+ - en
7
+ metrics:
8
+ - accuracy
9
+ pipeline_tag: text-classification
10
  ---
11
+ # BertForSequenceClassification on CNN News Dataset
12
+
13
+ This repository contains a fine-tuned Bert base model for sequence classification on the CNN News dataset. The model is able to classify news articles into one of six categories: business, entertainment, health, news, politics, and sport.
14
+
15
+ The model was fine-tuned for four epochs achieving a validation loss of 0.190814, accuracy of 0.956690, precision of 0.956393, recall of 0.956690, and F1-score of 0.956144.
16
+
17
+ ## Model Description
18
+
19
+ This model was fine-tuned by AyoubChLin and is based on the Bert base model. The tokenizer and model were created using the Hugging Face Transformers library.
20
+
21
+ ## Usage
22
+
23
+ You can use this model with the Hugging Face Transformers library for a variety of natural language processing tasks, such as text classification, sentiment analysis, and more.
24
+
25
+ Here's an example of how to use this model for text classification in Python:
26
+
27
+ ```python
28
+ from transformers import AutoTokenizer, BertForSequenceClassification
29
+
30
+ model_name = "AyoubChLin/bert_cnn_news"
31
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
32
+ model = TFAutoModelForSequenceClassification.from_pretrained(model_name)
33
+
34
+ text = "This is a news article about politics."
35
+ inputs = tokenizer(text, padding=True, truncation=True, return_tensors="tf")
36
+
37
+ outputs = model(inputs)
38
+ predicted_class_id = tf.argmax(outputs.logits, axis=-1).numpy()[0]
39
+
40
+ labels = ["business", "entertainment", "health", "news", "politics", "sport"]
41
+ predicted_label = labels[predicted_class_id]
42
+ ```
43
+
44
+ In this example, we first load the tokenizer and the model using their respective `from_pretrained` methods. We then encode a news article using the tokenizer, pass the inputs through the model, and extract the predicted label using the `argmax` function. Finally, we map the predicted label to its corresponding category using a list of labels.
45
+
46
+ ## Contributors
47
+
48
+ This model was fine-tuned by AyoubChLin.