manue commited on
Commit
2cae640
·
1 Parent(s): 359f489

Refactor sentiment model initialization to use AutoTokenizer and AutoModelForSequenceClassification

Browse files
Files changed (1) hide show
  1. model/sentiment.py +4 -2
model/sentiment.py CHANGED
@@ -1,8 +1,10 @@
1
- from transformers import pipeline
2
  from typing import Any
3
 
4
  class Sentiment:
5
  def __init__(self, line: str) -> (list | list[Any] | Any | None):
6
- self.pipe = pipeline("text-classification", model="MilaNLProc/feel-it-italian-sentiment")
 
 
7
  self.result = self.pipe(line)
8
 
 
1
+ from transformers import AutoModelForSequenceClassification, AutoTokenizer, pipeline
2
  from typing import Any
3
 
4
  class Sentiment:
5
  def __init__(self, line: str) -> (list | list[Any] | Any | None):
6
+ tokenizer = AutoTokenizer.from_pretrained("MilaNLProc/feel-it-italian-sentiment")
7
+ model = AutoModelForSequenceClassification.from_pretrained("MilaNLProc/feel-it-italian-sentiment")
8
+ self.pipe = pipeline("text-classification", model=model, tokenizer=tokenizer)
9
  self.result = self.pipe(line)
10