import gradio as gr from arxiv_tool.core import SentenceEncoder from arxiv_tool.plot import EmbeddingPlotter TITLE = "Search tool for ArXiv papers" DESCRIPTION = "
Find your most beloved ArXiv papers!
" EXAMPLES = [ "RoBERTa optimisation", "Permutation invariant AI models", "Gradient descent", "Black hole information theory", ] ARTICLE = r"""
This application uses Sentence-BERT embeddings. Sentence Embedding is achieved via Siamese BERT-Networks from this paper
After embedding, encoded papers are projected into the unit sphere and a nearest neighbours search is done to extract best matching results.
Done by dr. Gabriel Lopez
For more please visit: My Page
""" # interface function def search_and_plot(querry): # search df, model, embeddings = SentenceEncoder().load_and_encode() df, result = SentenceEncoder().transform(df, querry, model, embeddings) # plot fig1, fig2 = EmbeddingPlotter().transform(df, embeddings) return result[["title", "similarity"]], fig1, fig2 # gradio elements in_textbox = gr.Textbox( label="Search on ArXiv:", placeholder="what do you want to learn today?...", lines=1 ) out_dataframe = gr.DataFrame(label="Most similar papers on ArXiv:") out_plot_sphere = gr.Plot(label="Embedding projection over a unit sphere") out_plot_projected_sphere = gr.Plot( label="Lambert-conformal projection over a plane", visible=False ) # launch interface gr.Interface( inputs=in_textbox, outputs=[out_dataframe, out_plot_sphere, out_plot_projected_sphere], examples=EXAMPLES, fn=search_and_plot, title=TITLE, description=DESCRIPTION, article=ARTICLE, ).launch()