Spaces:
Runtime error
Runtime error
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) |