new encoder + api fix
Browse files
app.py
CHANGED
@@ -1,16 +1,16 @@
|
|
1 |
import gradio as gr
|
2 |
from sentence_transformers import CrossEncoder
|
3 |
|
4 |
-
ce = CrossEncoder("cross-encoder/
|
5 |
|
6 |
def rerank(query, docs):
|
7 |
-
|
8 |
-
texts = [d.get("A", str(d)) for d in docs]
|
9 |
pairs = [[query, txt] for txt in texts]
|
10 |
scores = ce.predict(pairs)
|
11 |
rows = [[txt, float(score)] for txt, score in zip(texts, scores)]
|
12 |
return rows
|
13 |
|
|
|
14 |
iface = gr.Interface(
|
15 |
fn=rerank,
|
16 |
inputs=[
|
|
|
1 |
import gradio as gr
|
2 |
from sentence_transformers import CrossEncoder
|
3 |
|
4 |
+
ce = CrossEncoder("cross-encoder/mmarco-mMiniLMv2-L12-H384-v1")
|
5 |
|
6 |
def rerank(query, docs):
|
7 |
+
texts = [str(d) for d in docs] # просто список строк
|
|
|
8 |
pairs = [[query, txt] for txt in texts]
|
9 |
scores = ce.predict(pairs)
|
10 |
rows = [[txt, float(score)] for txt, score in zip(texts, scores)]
|
11 |
return rows
|
12 |
|
13 |
+
|
14 |
iface = gr.Interface(
|
15 |
fn=rerank,
|
16 |
inputs=[
|