Spaces:
Runtime error
Runtime error
File size: 1,792 Bytes
d6585f5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
import argparse
import gradio as gr
from search_online import OnlineSearcher
K = 10
# default input
DEFAULT_QUERY_MRTYDI="""μ¬μ©μ μ§μμ κ΄λ ¨λ λ¬Έλ¨λ€μ Wikipedia νκ΅μ΄ μ½νΌμ€μμ λ°νν©λλ€.\n
μλ₯Όλ€μ΄\n
- μ΅μ΄λ‘ μ κΈ° μλμ°¨λ₯Ό κ°λ°ν κΈ°μ
μ μ΄λμΌ?
- μ€μΏ λ² λ€μ΄λΉ μ μ κ°λ₯ κΉμ΄λ μ΅λ λͺλ―Έν°μΈκ°μ?
- λ
μ κ·μ λ² μμ κΈ°μ
κ²°ν©μ¬μ¬κΈ°μ€μ κΈ°μ
κ²°ν©μ μ΄λ»κ² ꡬλΆνμ¬ κ²½μμ νμ±μ νλ¨νλμ?
"""
# manual arguments (FIXME)
args = argparse.Namespace
args.index_type='hybrid'
args.index="/root/indexes/mrtydi-korean/sparse,/root/indexes/mrtydi-korean/dense"
args.encoder="castorini/mdpr-question-nq"
args.device="cuda:0"
args.alpha=1000000
args.normalization=True
args.lang_abbr='ko'
# initialize qabot
print("initialize Mr.tydi retrieval bot")
searcher = OnlineSearcher(args)
def Retrieve(query):
hits = searcher.search(query, K)
result = searcher.print_result(hits, K)
return result
gr.Interface(
fn=Retrieve,
inputs=[
gr.inputs.Textbox(
default=DEFAULT_QUERY_MRTYDI,
label="μ§μ"),
],
outputs=[
gr.inputs.Textbox(
default="κ²μλ λ¬Έλ¨λ€κ³Ό μ μλ₯Ό μΆλ ₯ν©λλ€",
label="κ²μ κ²°κ³Ό")
],
title="Hybrid (term + neural) κ²μ",
theme='dark-grass',
description=f"νΉμ μ§μλ² μ΄μ€μ λν΄ νμ΅ν κ²μ μμ€ν
μ ν
μ€νΈν©λλ€.\nμ§μλ² μ΄μ€μ λ§μΆμ΄ μ¬νμ΅μ΄ κ°λ₯νλ©°, νμ¬ λ°λͺ¨μμλ Wikipedia νκ΅μ΄ μ½νΌμ€ (2020 dump, mr.Tydi ver, #λ¬Έλ¨=1496126)μ λν΄ νμ΅ν λͺ¨λΈμ μ¬μ©ν©λλ€. \n\n neural: castorini/mdpr-[passage,question]-nq, term: BM25"
).launch(share=True) |