Spaces:
Sleeping
Sleeping
initial commit
Browse files- .gitignore +2 -0
- app.py +8 -0
- model.py +7 -0
- 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
|