DEV Community

Cover image for Introducing Your Ultimate Research Paper Analyst 🚀
harshit-lyzr
harshit-lyzr

Posted on

Introducing Your Ultimate Research Paper Analyst 🚀

In the rapidly evolving landscape of academic research, the sheer volume of published papers is growing exponentially. Researchers, students, and professionals in academia are often overwhelmed by the need to read and comprehend a vast number of research papers to stay current in their fields. This can be a time-consuming and arduous task, diverting valuable time and energy away from actual research and innovation.

The process of reading and summarizing research papers manually is highly inefficient and prone to human error. It often leads to:
Time Consumption: Researchers spend significant amounts of time reading through lengthy papers, which delays their own research activities.
Information Overload: The inability to quickly distill essential information from numerous papers can lead to cognitive overload, reducing overall productivity and comprehension.
Inconsistent Summarization: Manual summarization varies greatly between individuals, leading to inconsistencies in the quality and completeness of the summaries.
Accessibility Issues: Non-native English speakers and researchers with limited time resources face additional challenges in digesting large volumes of academic text.

The Lyzr Research Paper Analyst App, powered by the Lyzr SDK and OpenAI's state-of-the-art language models, is designed to:
Automate Summarization: Extract and summarize the content of research papers efficiently, reducing the time researchers spend on reading.
Enhance Comprehension: Provide clear and structured summaries that highlight key points and findings, making it easier to understand complex information.
Maintain Consistency: Deliver consistent and high-quality summaries regardless of the document length or complexity.
Increase Accessibility: Aid non-native English speakers and busy researchers by presenting information in a concise and accessible format.

Setting Up the Environment

pip install lyzr pypdf streamlit
Enter fullscreen mode Exit fullscreen mode
from pypdf import PdfReader
from lyzr import Summarizer
import streamlit as st
from PIL import Image
import utils
import os
Enter fullscreen mode Exit fullscreen mode

Libraries like PdfReader from pypdf, Summarizer from lyzr, st from streamlit, Image from PIL, and helper functions from utils are imported.

data = "data"
os.makedirs(data, exist_ok=True)
Enter fullscreen mode Exit fullscreen mode

os library is used to create a directory named data if it doesn't exist.

OpenAI API Key Input:

api = st.sidebar.text_input("Enter Your OPENAI API KEY HERE",type="password")
if api:
    summarizer = Summarizer(api_key=api)
else:
    st.sidebar.error("Please Enter Your OPENAI API KEY Here")
Enter fullscreen mode Exit fullscreen mode

If an API key is provided, a Summarizer object is created using the key.
If not, an error message is displayed in the sidebar.

Summary Instructions:

instructions = f"""Summaries this article and follow below instructions:
1/ Ensure that all main points are covered
2/ Give Summaries Topic wise
3/ make bullet points for description
"""
Enter fullscreen mode Exit fullscreen mode

Instructions for summarizing the paper are displayed as a markdown string.

research_summary Function:

def research_summary():
    uploaded_file = st.file_uploader("Please Upload Your Research Paper", type=['pdf'])
    if uploaded_file is not None:
        st.success(f"File uploaded: {uploaded_file.name} (PDF)")
        file_path = utils.save_uploaded_file(uploaded_file)
        if st.button("Get Summary"):
            if file_path is not None:
                reader = PdfReader(file_path)
                paper = ""
                for i in range(len(reader.pages)):
                    page = reader.pages[i]
                    text = page.extract_text()
                    paper += text

                if len(paper) < 30000:
                    summary = summarizer.summarize(paper, instructions)
                    st.markdown(summary)
                else:
                    st.error("Please Upload Document with only text and have less than 30K Characters")
    else:
        st.warning("Please Upload your Research Paper")
Enter fullscreen mode Exit fullscreen mode

This function handles uploading and summarizing the research paper:
A file uploader is created that accepts only PDF files.
If a file is uploaded:
A success message is displayed.
The uploaded file is saved using the utils.save_uploaded_file function (assumed to be defined in utils.py).
A button "Get Summary" is displayed.
Clicking the button checks if the saved file path exists.
If the path exists:
A PdfReader object is created to read the PDF.
Text is extracted from each page and concatenated into a single string (paper).
The character count of the paper is checked.
If the character count is less than 30,000:

 The summarizer.summarize function is called with the extracted text (paper) and the summary instructions.
The generated summary is displayed as markdown.
If the character count is greater than or equal to 30,000, an error message is displayed about exceeding the character limit.
If no file is uploaded, a warning message is displayed.

Main Execution:

if __name__ == "__main__":
    style_app()
    research_summary()
Enter fullscreen mode Exit fullscreen mode

This part ensures the code runs only when the script is executed directly (not imported as a module).
It calls the style_app function to apply custom styling (if applicable).
Finally, it calls the research_summary function to handle the research paper upload and summarization.

try it now: https://lyzr-researchpaper-analyst.streamlit.app/
For more information explore the website: Lyzr

Top comments (0)