Update app.py
Browse files
app.py
CHANGED
@@ -4,15 +4,15 @@ import os
|
|
4 |
import gradio as gr
|
5 |
|
6 |
#ds_with_embeddings = load_dataset("svjack/bloom-dialogue-generate-ds-zh", split="train")
|
7 |
-
ds_with_embeddings = load_dataset("svjack/context-dialogue-generate-ds-zh", split="train")
|
8 |
-
ds_with_embeddings.add_faiss_index(column='
|
9 |
from sentence_transformers import SentenceTransformer
|
10 |
-
|
11 |
-
encoder = SentenceTransformer("sentence-transformers/clip-ViT-B-32-multilingual-v1")
|
12 |
|
13 |
def retrieve_search_df(question = "这座教堂建在山上", top_k = 10):
|
14 |
question_embedding = encoder.encode(question)
|
15 |
-
scores, retrieved_examples = ds_with_embeddings.get_nearest_examples('
|
16 |
sdf = pd.DataFrame(retrieved_examples)
|
17 |
sdf["scores"] = scores
|
18 |
return sdf[["sent", "dialogue", "scores"]]
|
|
|
4 |
import gradio as gr
|
5 |
|
6 |
#ds_with_embeddings = load_dataset("svjack/bloom-dialogue-generate-ds-zh", split="train")
|
7 |
+
ds_with_embeddings = load_dataset("svjack/context-dialogue-generate-ds-zh-v1", split="train")
|
8 |
+
ds_with_embeddings.add_faiss_index(column='L_emb')
|
9 |
from sentence_transformers import SentenceTransformer
|
10 |
+
encoder = SentenceTransformer("sentence-transformers/LaBSE")
|
11 |
+
#encoder = SentenceTransformer("sentence-transformers/clip-ViT-B-32-multilingual-v1")
|
12 |
|
13 |
def retrieve_search_df(question = "这座教堂建在山上", top_k = 10):
|
14 |
question_embedding = encoder.encode(question)
|
15 |
+
scores, retrieved_examples = ds_with_embeddings.get_nearest_examples('L_emb', question_embedding, k=top_k)
|
16 |
sdf = pd.DataFrame(retrieved_examples)
|
17 |
sdf["scores"] = scores
|
18 |
return sdf[["sent", "dialogue", "scores"]]
|