georad commited on
Commit
f6b860f
·
verified ·
1 Parent(s): 8315d30

Update pages/type_text.py

Browse files
Files changed (1) hide show
  1. pages/type_text.py +17 -25
pages/type_text.py CHANGED
@@ -103,26 +103,26 @@ numMAPPINGS_input = 5
103
  #numMAPPINGS_input = st.text_input("Type number of mappings and hit Enter", key="user_input_numMAPPINGS")
104
  #st.button("Clear text", on_click=on_click)
105
 
106
- SentenceTransformer = st.selectbox(
107
- "Select the Sentence Transformer model",
108
- ("all-MiniLM-L6-v2 (original model for general domain)", "all-MiniLM-L6-v2 (fine-tuned model for medical domain)",
109
- "all-mpnet-base-v2 (original model for general domain)", "all-mpnet-base-v2 (fine-tuned model for medical domain)")
110
- )
111
- st.write("You selected:", SentenceTransformer)
112
-
113
-
114
-
115
-
116
-
117
-
118
-
119
-
120
-
121
-
122
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  @st.cache_resource
124
  def load_model():
125
- model = SentenceTransformer('all-MiniLM-L6-v2') # fastest
126
  return model
127
  model = load_model()
128
 
@@ -136,14 +136,6 @@ model = load_model()
136
 
137
 
138
 
139
-
140
-
141
-
142
-
143
-
144
-
145
-
146
-
147
  INTdesc_embedding = model.encode(INTdesc_input)
148
 
149
  # Semantic search, Compute cosine similarity between INTdesc_embedding and SBS descriptions
 
103
  #numMAPPINGS_input = st.text_input("Type number of mappings and hit Enter", key="user_input_numMAPPINGS")
104
  #st.button("Clear text", on_click=on_click)
105
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
 
107
+ ## Define the SentTrans models
108
+ st_models = {
109
+ 'original model for general domain, fastest: all-MiniLM-L6-v2': 'all-MiniLM-L6-v2',
110
+ 'fine-tuned model for medical domain: all-MiniLM-L6-v2': 'all-MiniLM-L6-v2',
111
+ 'original model for general domain, best performance: all-mpnet-base-v2': 'all-mpnet-base-v2',
112
+ 'fine-tuned model for medical domain: all-mpnet-base-v2': 'all-mpnet-base-v2',
113
+ }
114
+
115
+ ## Create the select box
116
+ selected_st_model = st.selectbox('Choose a model:', list(st_models.keys()))
117
+ st.write("You selected:", selected_st_model)
118
+
119
+ ## Get the selected model
120
+ SentTrans_model = st_models[selected_st_model]
121
+
122
+ ## Use the model...
123
  @st.cache_resource
124
  def load_model():
125
+ model = SentenceTransformer(SentTrans_model)
126
  return model
127
  model = load_model()
128
 
 
136
 
137
 
138
 
 
 
 
 
 
 
 
 
139
  INTdesc_embedding = model.encode(INTdesc_input)
140
 
141
  # Semantic search, Compute cosine similarity between INTdesc_embedding and SBS descriptions