huggingface error model

This commit is contained in:
szymonj98 2023-05-31 16:50:59 +02:00
parent 176ba1c9ad
commit 66a0b1c6bc
2 changed files with 6 additions and 5 deletions

View File

@ -1,11 +1,12 @@
from transformers import AutoTokenizer from transformers import AutoTokenizer
from transformers import pipeline from transformers import pipeline
#from transformers import BartForConditionalGeneration
# model = 'application/models/errors_model' tokenizer = AutoTokenizer.from_pretrained("szymonj/polish-simple-error-correction")
# tokenizer = AutoTokenizer.from_pretrained('application/tokenizers/errors_tokenizer') #model = BartForConditionalGeneration.from_pretrained("szymonj/polish-simple-error-correction")
pipe = pipeline("text2text-generation",model="szymonj/polish-simple-error-correction",tokenizer=tokenizer,max_length=2000)
def errors_correction(data): def errors_correction(data):
pipe = pipeline("text2text-generation",model=model,tokenizer=tokenizer,max_length=2000)
result = pipe(data) result = pipe(data)
return result return result

View File

@ -6,11 +6,11 @@ from facebook_scraper import get_posts
# model = 'application/models/sentiment_model' # model = 'application/models/sentiment_model'
# tokenizer = AutoTokenizer.from_pretrained('application/tokenizers/sentiment_tokenizer') # tokenizer = AutoTokenizer.from_pretrained('application/tokenizers/sentiment_tokenizer')
model = GPT2ForSequenceClassification.from_pretrained("Scigi/sentiment-analysis-model", num_labels=3) #model = GPT2ForSequenceClassification.from_pretrained("Scigi/sentiment-analysis-model", num_labels=3)
tokenizer = AutoTokenizer.from_pretrained("Scigi/sentiment-analysis-model") tokenizer = AutoTokenizer.from_pretrained("Scigi/sentiment-analysis-model")
pipe = pipeline('text-classification', model="Scigi/sentiment-analysis-model", tokenizer = tokenizer)
def sentiment_prediction(data): def sentiment_prediction(data):
pipe = pipeline('text-classification', model=model, tokenizer = tokenizer)
result = pipe(data) result = pipe(data)
return result return result