lwdgit commited on
Commit
597fe90
1 Parent(s): fb55bff

initial commit

Browse files
Files changed (4) hide show
  1. .gitignore +2 -0
  2. app.py +8 -0
  3. model.py +7 -0
  4. requirements.txt +1 -0
.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ __pycache__
2
+ /flagged
app.py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import model
3
+
4
+ def encode(text):
5
+ return model.encode(text)
6
+
7
+ iface = gr.Interface(fn=encode, inputs="text", outputs="text")
8
+ iface.launch()
model.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ from sentence_transformers import SentenceTransformer
2
+ model = SentenceTransformer('moka-ai/m3e-base')
3
+ # model = SentenceTransformer('nghuyong/ernie-3.0-base-zh')
4
+
5
+ def encode(text: str):
6
+ text = text.replace("\n", " ")
7
+ return model.encode([text], normalize_embeddings=True).tolist()[0]
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ sentence-transformers==2.2.2