vinayakdev commited on
Commit
13b79aa
1 Parent(s): 46db2ba

Added load_model

Browse files
Files changed (1) hide show
  1. generator.py +8 -8
generator.py CHANGED
@@ -33,10 +33,15 @@ import streamlit as st
33
  # text= "The abolition of feudal privileges by the National Constituent Assembly on 4 August 1789 and the Declaration \\nof the Rights of Man and of the Citizen (La Déclaration des Droits de l'Homme et du Citoyen), drafted by Lafayette \\nwith the help of Thomas Jefferson and adopted on 26 August, paved the way to a Constitutional Monarchy \\n(4 September 1791 – 21 September 1792). Despite these dramatic changes, life at the court continued, while the situation \\nin Paris was becoming critical because of bread shortages in September. On 5 October 1789, a crowd from Paris descended upon Versailles \\nand forced the royal family to move to the Tuileries Palace in Paris, where they lived under a form of house arrest under \\nthe watch of Lafayette's Garde Nationale, while the Comte de Provence and his wife were allowed to reside in the \\nPetit Luxembourg, where they remained until they went into exile on 20 June 1791."
34
  # hftokenizer = pickle.load(open('models/hftokenizer.sav', 'rb'))
35
  # hfmodel = pickle.load(open('models/hfmodel.sav', 'rb'))
36
- hfmodel = alwm.from_pretrained("ThomasSimonini/t5-end2end-question-generation")
37
-
38
- hftokenizer = T5TokenizerFast.from_pretrained("t5-base")
 
 
 
39
  @st.cache(suppress_st_warning=True)
 
 
40
  def run_model(input_string, **generator_args):
41
  generator_args = {
42
  "max_length": 256,
@@ -57,13 +62,8 @@ def run_model(input_string, **generator_args):
57
 
58
  # al_tokenizer = att.from_pretrained("deepset/electra-base-squad2")
59
  # al_model = amqa.from_pretrained("deepset/electra-base-squad2")
60
-
61
- tokenizer = att.from_pretrained("ahotrod/albert_xxlargev1_squad2_512")
62
-
63
- model = amqa.from_pretrained("ahotrod/albert_xxlargev1_squad2_512")
64
  # al_model = pickle.load(open('models/al_model.sav', 'rb'))
65
  # al_tokenizer = pickle.load(open('models/al_tokenizer.sav', 'rb'))
66
- @st.cache
67
  def QA(question, context):
68
  # model_name="deepset/electra-base-squad2"
69
  # nlp = pipeline("question-answering",model=al_model,tokenizer=al_tokenizer)
 
33
  # text= "The abolition of feudal privileges by the National Constituent Assembly on 4 August 1789 and the Declaration \\nof the Rights of Man and of the Citizen (La Déclaration des Droits de l'Homme et du Citoyen), drafted by Lafayette \\nwith the help of Thomas Jefferson and adopted on 26 August, paved the way to a Constitutional Monarchy \\n(4 September 1791 – 21 September 1792). Despite these dramatic changes, life at the court continued, while the situation \\nin Paris was becoming critical because of bread shortages in September. On 5 October 1789, a crowd from Paris descended upon Versailles \\nand forced the royal family to move to the Tuileries Palace in Paris, where they lived under a form of house arrest under \\nthe watch of Lafayette's Garde Nationale, while the Comte de Provence and his wife were allowed to reside in the \\nPetit Luxembourg, where they remained until they went into exile on 20 June 1791."
34
  # hftokenizer = pickle.load(open('models/hftokenizer.sav', 'rb'))
35
  # hfmodel = pickle.load(open('models/hfmodel.sav', 'rb'))
36
+ @st.cache
37
+ def load_model():
38
+ hfmodel = alwm.from_pretrained("ThomasSimonini/t5-end2end-question-generation")
39
+ hftokenizer = T5TokenizerFast.from_pretrained("t5-base")
40
+ tokenizer = att.from_pretrained("ahotrod/albert_xxlargev1_squad2_512")
41
+ model = amqa.from_pretrained("ahotrod/albert_xxlargev1_squad2_512")
42
  @st.cache(suppress_st_warning=True)
43
+ load_model()
44
+
45
  def run_model(input_string, **generator_args):
46
  generator_args = {
47
  "max_length": 256,
 
62
 
63
  # al_tokenizer = att.from_pretrained("deepset/electra-base-squad2")
64
  # al_model = amqa.from_pretrained("deepset/electra-base-squad2")
 
 
 
 
65
  # al_model = pickle.load(open('models/al_model.sav', 'rb'))
66
  # al_tokenizer = pickle.load(open('models/al_tokenizer.sav', 'rb'))
 
67
  def QA(question, context):
68
  # model_name="deepset/electra-base-squad2"
69
  # nlp = pipeline("question-answering",model=al_model,tokenizer=al_tokenizer)