Views
No views yet
Topic-xDistil is a model based on
xtremedistil-l12-h384-uncased
fine-tuned for classifying the topic of news headlines on a dataset annotated by
Chat GPT 3.5. It is built, together with
Sentiment-xDistil,
as a tool for filtering out financial news headlines and classifying their sentiment.
The code used to train both models and build the dataset are found here.Economics or Other. The model is suitable for English.| Model | Test Set Size | Accuracy | F1 Score |
|---|---|---|---|
topic-xdistil-uncased | 32 799 | 94.44 % | 92.59 % |
sentiment-xdistil-uncased | 17 527 | 94.59 % | 93.44 % |
1"""
2[...]
3 - Economic headlines generally cover topics such as financial markets, \
4 business, financial assets, trade, employment, GDP, inflation, or fiscal \
5and monetary policy.
6 - Non-economic headlines might include sports, entertainment, politics, \
7science, weather, health, or other unrelated news events.
8[...]
9"""1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2
3model = AutoModelForSequenceClassification.from_pretrained("hakonmh/topic-xdistil-uncased")
4tokenizer = AutoTokenizer.from_pretrained("hakonmh/topic-xdistil-uncased")
5
6SENTENCE = "Global Growth Surges as New Technologies Drive Innovation and Productivity!"
7inputs = tokenizer(SENTENCE, return_tensors="pt")
8output = model(**inputs).logits
9predicted_label = model.config.id2label[output.argmax(-1).item()]
10
11print(predicted_label)EconomicsSentiment-xDistil:1from transformers import pipeline
2
3topic_classifier = pipeline("sentiment-analysis",
4 model="hakonmh/topic-xdistil-uncased",
5 tokenizer="hakonmh/topic-xdistil-uncased")
6sentiment_classifier = pipeline("sentiment-analysis",
7 model="hakonmh/sentiment-xdistil-uncased",
8 tokenizer="hakonmh/sentiment-xdistil-uncased")
9
10SENTENCE = "Global Growth Surges as New Technologies Drive Innovation and Productivity!"
11print(topic_classifier(SENTENCE))
12print(sentiment_classifier(SENTENCE))1[{'label': 'Economics', 'score': 0.9970171451568604}]
2[{'label': 'Positive', 'score': 0.9997037053108215}]transformers 4.30.1, and torch 2.0.0.