CoolFace
Apppublic

hwca96/CS_Paper_Abstract_Semantic_Search

sourceHugging Faceupdated 3y agoView on Hugging Face
1likes
app.py64 linesDownload Raw Back to root
1import gradio as gr2from MongoSearch import MongoSearch3 4# Initialize MongoSearch5mongo_search = MongoSearch()6 7with gr.Blocks(title="Research Paper Semantic Search App") as demo:8    gr.Markdown(9        """10        # Research Paper Semantic Search App11        12        Enter a query to perform semantic search on sample arXiv cs papers13        """       14        )15    with gr.Row():16        input = gr.Text(label="Query")17    with gr.Row():18        output = gr.DataFrame(wrap=True, height=700, interactive=True)19    button = gr.Button(value="Search")20    button.click(mongo_search.search, inputs=input, outputs=output)21    gr.Markdown(22        """23        Use the examples below to get started!24        """       25        )26    examples = gr.Examples(27        [ 28            ["Using machine learning to speed up drug discovery"],29            ["Applying deep learning to the stock market"],30            ["Computer vision to detect cancer in medical images"]31        ],32        label="Examples",33        inputs=input,34        outputs=output,35        cache_examples=True,36        fn=mongo_search.search,37        preprocess=True38    )39    gr.Markdown(40        """41        You can access each paper directly on [ArXiv](https://arxiv.org/) using these links:42        - `https://arxiv.org/abs/{id}`: Page for this paper including its abstract and further links43        - `https://arxiv.org/pdf/{id}`: Direct link to download the PDF44        """       45        )46 47# Create the Gradio interface48# iface = gr.Interface(49#     title="Research Paper Semantic Search App",50#     fn=mongo_search.search,51#     inputs=gr.Textbox(placeholder="Enter a query to perform semantic search on sample arXiv cs papers"),52#     description="Enter a query to perform semantic search on sample arXiv cs papers",53#     examples=[54#         ["Using machine learning to speed up drug discovery"],55#         ["Applying deep learning to the stock market"],56#         ["Computer vision to detect cancer in medical images"]57#     ],58#     cache_examples=True,59#     outputs=gr.DataFrame(wrap=True, min_width=1000)60# )61 62# Run the Gradio interface63demo.launch()64