Commit
89d1633
1 Parent(s): e28fc91

Update model_functions.py (#4)

Browse files

- Update model_functions.py (92c19487aec2d0780de454861d86578e1eea9fc9)


Co-authored-by: Marcelo Moreno <marcelomoreno26@users.noreply.huggingface.co>

Files changed (1) hide show
  1. model_functions.py +5 -6
model_functions.py CHANGED
@@ -3,16 +3,17 @@ from transformers import (AutoModelForSequenceClassification, AutoModelForSeq2Se
3
  AutoConfig, AutoModelForTokenClassification,
4
  AutoTokenizer, pipeline)
5
  from peft import PeftModel, PeftConfig
 
6
 
7
 
8
-
9
-
10
  def load_sentiment_analyzer():
11
  tokenizer = AutoTokenizer.from_pretrained("aliciiavs/sentiment-analysis-whatsapp2")
12
  model = AutoModelForSequenceClassification.from_pretrained("aliciiavs/sentiment-analysis-whatsapp2")
13
 
14
  return tokenizer, model
15
 
 
16
  def load_summarizer():
17
  config = PeftConfig.from_pretrained("marcelomoreno26/bart-large-samsum-adapter")
18
  model = AutoModelForSeq2SeqLM.from_pretrained("facebook/bart-large")
@@ -23,6 +24,7 @@ def load_summarizer():
23
 
24
  return tokenizer, model
25
 
 
26
  def load_NER():
27
  config = AutoConfig.from_pretrained("hannahisrael03/wikineural-multilingual-ner-finetuned-wikiann")
28
  model = AutoModelForTokenClassification.from_pretrained("hannahisrael03/wikineural-multilingual-ner-finetuned-wikiann",config=config)
@@ -96,7 +98,4 @@ def get_NER(text, pipe):
96
  # Add non-ORG entities without filtering
97
  filtered_results.append(entity)
98
 
99
- return filtered_results
100
-
101
-
102
-
 
3
  AutoConfig, AutoModelForTokenClassification,
4
  AutoTokenizer, pipeline)
5
  from peft import PeftModel, PeftConfig
6
+ import streamlit as st
7
 
8
 
9
+ @st.cache_resource
 
10
  def load_sentiment_analyzer():
11
  tokenizer = AutoTokenizer.from_pretrained("aliciiavs/sentiment-analysis-whatsapp2")
12
  model = AutoModelForSequenceClassification.from_pretrained("aliciiavs/sentiment-analysis-whatsapp2")
13
 
14
  return tokenizer, model
15
 
16
+ @st.cache_resource
17
  def load_summarizer():
18
  config = PeftConfig.from_pretrained("marcelomoreno26/bart-large-samsum-adapter")
19
  model = AutoModelForSeq2SeqLM.from_pretrained("facebook/bart-large")
 
24
 
25
  return tokenizer, model
26
 
27
+ @st.cache_resource
28
  def load_NER():
29
  config = AutoConfig.from_pretrained("hannahisrael03/wikineural-multilingual-ner-finetuned-wikiann")
30
  model = AutoModelForTokenClassification.from_pretrained("hannahisrael03/wikineural-multilingual-ner-finetuned-wikiann",config=config)
 
98
  # Add non-ORG entities without filtering
99
  filtered_results.append(entity)
100
 
101
+ return filtered_results