georad commited on
Commit
7aca895
Β·
verified Β·
1 Parent(s): 73fcf1f

Update pages/type_text.py

Browse files
Files changed (1) hide show
  1. pages/type_text.py +11 -9
pages/type_text.py CHANGED
@@ -46,12 +46,13 @@ numMAPPINGS_input = 5
46
  def load_model():
47
  model = SentenceTransformer('all-MiniLM-L6-v2') # fastest
48
  return model
 
 
49
  model = SentenceTransformer('all-MiniLM-L6-v2') # fastest
50
  #model = SentenceTransformer('all-mpnet-base-v2') # best performance
51
  #model = SentenceTransformers('all-distilroberta-v1')
52
  #model = SentenceTransformer('sentence-transformers/msmarco-bert-base-dot-v5')
53
  #model = SentenceTransformer('clips/mfaq')
54
- load_model()
55
 
56
  INTdesc_embedding = model.encode(INTdesc_input)
57
 
@@ -74,12 +75,13 @@ HF_model_results = util.semantic_search(INTdesc_embedding, SBScorpus_embeddings)
74
  HF_model_results_sorted = sorted(HF_model_results, key=lambda x: x[1], reverse=True)
75
  HF_model_results_displayed = HF_model_results_sorted[0:numMAPPINGS_input]
76
 
77
- @st.cache_resource
78
- def load_model_pipe():
79
- pipe = pipeline("text-generation", model="meta-llama/Llama-3.2-1B-Instruct", device_map=device,) # device_map="auto", torch_dtype=torch.bfloat16
80
- return pipe
 
 
81
  pipe = pipeline("text-generation", model="meta-llama/Llama-3.2-1B-Instruct", device_map=device,) # device_map="auto", torch_dtype=torch.bfloat16
82
- load_model_pipe()
83
 
84
  dictA = {"Score": [], "SBS Code": [], "SBS Description V2.0": []}
85
  dfALL = pd.DataFrame.from_dict(dictA)
@@ -120,10 +122,10 @@ if INTdesc_input is not None and createSBScodes_clicked == True:
120
  bs, b1, b2, b3, bLast = st.columns([0.75, 1.5, 1.5, 1.5, 0.75])
121
  with b1:
122
  #csvbutton = download_button(results, "results.csv", "πŸ“₯ Download .csv")
123
- csvbutton = st.download_button(label="πŸ“₯ Download .csv", data=convert_df(dfA), file_name= "results.csv", mime='text/csv', key='csv_b')
124
  with b2:
125
  #textbutton = download_button(results, "results.txt", "πŸ“₯ Download .txt")
126
- textbutton = st.download_button(label="πŸ“₯ Download .txt", data=convert_df(dfA), file_name= "results.text", mime='text/plain', key='text_b')
127
  with b3:
128
  #jsonbutton = download_button(results, "results.json", "πŸ“₯ Download .json")
129
- jsonbutton = st.download_button(label="πŸ“₯ Download .json", data=convert_json(dfA), file_name= "results.json", mime='application/json', key='json_b')
 
46
  def load_model():
47
  model = SentenceTransformer('all-MiniLM-L6-v2') # fastest
48
  return model
49
+ load_model()
50
+
51
  model = SentenceTransformer('all-MiniLM-L6-v2') # fastest
52
  #model = SentenceTransformer('all-mpnet-base-v2') # best performance
53
  #model = SentenceTransformers('all-distilroberta-v1')
54
  #model = SentenceTransformer('sentence-transformers/msmarco-bert-base-dot-v5')
55
  #model = SentenceTransformer('clips/mfaq')
 
56
 
57
  INTdesc_embedding = model.encode(INTdesc_input)
58
 
 
75
  HF_model_results_sorted = sorted(HF_model_results, key=lambda x: x[1], reverse=True)
76
  HF_model_results_displayed = HF_model_results_sorted[0:numMAPPINGS_input]
77
 
78
+ #@st.cache_resource
79
+ #def load_model_pipe():
80
+ # pipe = pipeline("text-generation", model="meta-llama/Llama-3.2-1B-Instruct", device_map=device,) # device_map="auto", torch_dtype=torch.bfloat16
81
+ # return pipe
82
+ #load_model_pipe()
83
+
84
  pipe = pipeline("text-generation", model="meta-llama/Llama-3.2-1B-Instruct", device_map=device,) # device_map="auto", torch_dtype=torch.bfloat16
 
85
 
86
  dictA = {"Score": [], "SBS Code": [], "SBS Description V2.0": []}
87
  dfALL = pd.DataFrame.from_dict(dictA)
 
122
  bs, b1, b2, b3, bLast = st.columns([0.75, 1.5, 1.5, 1.5, 0.75])
123
  with b1:
124
  #csvbutton = download_button(results, "results.csv", "πŸ“₯ Download .csv")
125
+ csvbutton = st.download_button(label="πŸ“₯ Download .csv", data=convert_df(dfALL), file_name= "results.csv", mime='text/csv', key='csv_b')
126
  with b2:
127
  #textbutton = download_button(results, "results.txt", "πŸ“₯ Download .txt")
128
+ textbutton = st.download_button(label="πŸ“₯ Download .txt", data=convert_df(dfALL), file_name= "results.text", mime='text/plain', key='text_b')
129
  with b3:
130
  #jsonbutton = download_button(results, "results.json", "πŸ“₯ Download .json")
131
+ jsonbutton = st.download_button(label="πŸ“₯ Download .json", data=convert_json(dfALL), file_name= "results.json", mime='application/json', key='json_b')