jonathanjordan21 commited on
Commit
c3ffdd7
·
verified ·
1 Parent(s): f897f91

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -4
app.py CHANGED
@@ -76,12 +76,21 @@ codes = """001 - Pendaftaran Kendaraan (Baru)
76
 
77
  undetected = "099 - Lainnya/Tidak Terdeteksi"
78
 
 
 
 
 
 
 
 
 
79
  # model_id = "sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2"
80
  # model_id = "Alibaba-NLP/gte-multilingual-base"
81
- model_id = "BAAI/bge-m3"
82
- model_id = "sentence-transformers/paraphrase-multilingual-mpnet-base-v2"
83
- model_id = "intfloat/multilingual-e5-small"
84
  # model_id = "sentence-transformers/distiluse-base-multilingual-cased-v2"
 
85
  model = SentenceTransformer(model_id, trust_remote_code=True)
86
 
87
  codes_emb = model.encode([x[6:] for x in codes])
@@ -90,10 +99,17 @@ def respond(
90
  message,
91
  history: list[tuple[str, str]],
92
  threshold,
93
- is_multiple
 
94
  ):
95
  global codes_emb
96
  global undetected
 
 
 
 
 
 
97
 
98
  undetected_code = undetected[:3]
99
 
@@ -193,6 +209,7 @@ with gr.Blocks() as demo:
193
  additional_inputs=[
194
  gr.Number(0.5, label="confidence threshold", show_label=True, minimum=0., maximum=1.0, step=0.1),
195
  gr.Checkbox(label="multiple", info="Allow multiple request code numbers"),
 
196
  ]
197
  )
198
 
 
76
 
77
  undetected = "099 - Lainnya/Tidak Terdeteksi"
78
 
79
+ model_ids = [
80
+ "sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2",
81
+ "Alibaba-NLP/gte-multilingual-base",
82
+ "BAAI/bge-m3",
83
+ "sentence-transformers/paraphrase-multilingual-mpnet-base-v2",
84
+ "intfloat/multilingual-e5-small",
85
+ "sentence-transformers/distiluse-base-multilingual-cased-v2"
86
+ ]
87
  # model_id = "sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2"
88
  # model_id = "Alibaba-NLP/gte-multilingual-base"
89
+ # model_id = "BAAI/bge-m3"
90
+ # model_id = "sentence-transformers/paraphrase-multilingual-mpnet-base-v2"
91
+ # model_id = "intfloat/multilingual-e5-small"
92
  # model_id = "sentence-transformers/distiluse-base-multilingual-cased-v2"
93
+ model_id = model_ids[-1]
94
  model = SentenceTransformer(model_id, trust_remote_code=True)
95
 
96
  codes_emb = model.encode([x[6:] for x in codes])
 
99
  message,
100
  history: list[tuple[str, str]],
101
  threshold,
102
+ is_multiple,
103
+ chosen_model_id
104
  ):
105
  global codes_emb
106
  global undetected
107
+ global model
108
+ global model_id
109
+
110
+ if chosen_model_id != model_id:
111
+ model = SentenceTransformer(chosen_model_id, trust_remote_code=True)
112
+ model_id = chosen_model_id
113
 
114
  undetected_code = undetected[:3]
115
 
 
209
  additional_inputs=[
210
  gr.Number(0.5, label="confidence threshold", show_label=True, minimum=0., maximum=1.0, step=0.1),
211
  gr.Checkbox(label="multiple", info="Allow multiple request code numbers"),
212
+ gradio.Dropdown(choices=model_ids, value=model_ids[0])
213
  ]
214
  )
215