Paula Leonova
commited on
Commit
·
ae7b1b1
1
Parent(s):
662dc37
Add cache to models
Browse files
models.py
CHANGED
|
@@ -1,5 +1,7 @@
|
|
| 1 |
import torch
|
| 2 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
|
|
|
|
|
|
|
| 3 |
|
| 4 |
import spacy
|
| 5 |
nlp = spacy.load('en_core_web_sm')
|
|
@@ -28,6 +30,7 @@ def create_nest_sentences(document:str, token_max_length = 1024):
|
|
| 28 |
return nested
|
| 29 |
|
| 30 |
# Reference: https://huggingface.co/facebook/bart-large-mnli
|
|
|
|
| 31 |
def load_summary_model():
|
| 32 |
model_name = "facebook/bart-large-mnli"
|
| 33 |
summarizer = pipeline(task='summarization', model=model_name)
|
|
@@ -57,6 +60,7 @@ def summarizer_gen(summarizer, sequence:str, maximum_tokens:int, minimum_tokens:
|
|
| 57 |
|
| 58 |
|
| 59 |
# Reference: https://huggingface.co/spaces/team-zero-shot-nli/zero-shot-nli/blob/main/utils.py
|
|
|
|
| 60 |
def load_model():
|
| 61 |
model_name = "facebook/bart-large-mnli"
|
| 62 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
|
|
|
| 1 |
import torch
|
| 2 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
|
| 3 |
+
import streamlit as st
|
| 4 |
+
|
| 5 |
|
| 6 |
import spacy
|
| 7 |
nlp = spacy.load('en_core_web_sm')
|
|
|
|
| 30 |
return nested
|
| 31 |
|
| 32 |
# Reference: https://huggingface.co/facebook/bart-large-mnli
|
| 33 |
+
@st.cache(allow_output_mutation=True)
|
| 34 |
def load_summary_model():
|
| 35 |
model_name = "facebook/bart-large-mnli"
|
| 36 |
summarizer = pipeline(task='summarization', model=model_name)
|
|
|
|
| 60 |
|
| 61 |
|
| 62 |
# Reference: https://huggingface.co/spaces/team-zero-shot-nli/zero-shot-nli/blob/main/utils.py
|
| 63 |
+
@st.cache(allow_output_mutation=True)
|
| 64 |
def load_model():
|
| 65 |
model_name = "facebook/bart-large-mnli"
|
| 66 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|