wanderer2k1 commited on
Commit
6c58f90
1 Parent(s): c6a60d2
Files changed (2) hide show
  1. app.py +3 -8
  2. requirements.txt +2 -2
app.py CHANGED
@@ -50,8 +50,8 @@ def selectbox_with_default(text, values, default=DEFAULT, sidebar=False):
50
  func = st.sidebar.selectbox if sidebar else st.selectbox
51
  return func(text, np.insert(np.array(values, object), 0, default))
52
 
53
- @st.cache(allow_output_mutation=True)
54
- def neuralqa():
55
  model = T5ForConditionalGeneration.from_pretrained("wanderer2k1/T5-LawsQA")
56
  tokenizer = T5TokenizerFast.from_pretrained("wanderer2k1/T5-LawsQA")
57
 
@@ -98,16 +98,11 @@ if 'bm25' not in st.session_state:
98
 
99
  #4: model
100
  if 'model' not in st.session_state:
101
- st.session_state['tokenizer'], st.session_state['model'], st.session_state['bi_encoder'] = neuralqa()
102
 
103
  #%%
104
 
105
-
106
- #%%
107
-
108
-
109
  def deploy(question):
110
- # tokenizer, model, bi_encoder = neuralqa()
111
  top_k = returns # Number of passages we want to retrieve with the bi-encoder
112
 
113
  tokenized_query = preprocess(question).split()
 
50
  func = st.sidebar.selectbox if sidebar else st.selectbox
51
  return func(text, np.insert(np.array(values, object), 0, default))
52
 
53
+ @st.cache_resource()
54
+ def loadmodels():
55
  model = T5ForConditionalGeneration.from_pretrained("wanderer2k1/T5-LawsQA")
56
  tokenizer = T5TokenizerFast.from_pretrained("wanderer2k1/T5-LawsQA")
57
 
 
98
 
99
  #4: model
100
  if 'model' not in st.session_state:
101
+ st.session_state['tokenizer'], st.session_state['model'], st.session_state['bi_encoder'] = loadmodels()
102
 
103
  #%%
104
 
 
 
 
 
105
  def deploy(question):
 
106
  top_k = returns # Number of passages we want to retrieve with the bi-encoder
107
 
108
  tokenized_query = preprocess(question).split()
requirements.txt CHANGED
@@ -1,8 +1,8 @@
1
- streamlit==1.3.1
2
  sentence_transformers==2.2.2
3
  numpy==1.20.1
4
  transformers==4.28.0
5
- pandas==1.2.3
6
  textwrap3==0.9.2
7
  torch==1.12.0
8
  joblib==1.0.1
 
1
+ streamlit==1.25.0
2
  sentence_transformers==2.2.2
3
  numpy==1.20.1
4
  transformers==4.28.0
5
+ pandas==1.3.0
6
  textwrap3==0.9.2
7
  torch==1.12.0
8
  joblib==1.0.1