GithubHelp home page GithubHelp logo

talkingwallace / chatgpt-paper-reader Goto Github PK

View Code? Open in Web Editor NEW
714.0 13.0 110.0 1.85 MB

This repo offers a simple interface that helps you to read&summerize research papers in pdf format. You can ask some questions after reading. This interface is developed based on openai API and using GPT-3.5-turbo model.

Python 100.00%

chatgpt-paper-reader's Introduction

CHATGPT-PAPER-READER

This repository provides a simple interface that utilizes the gpt-3.5-turbo model to read academic papers in PDF format locally.

Recent Updates

  • Cut paper by section titles
  • Support handling longer articles and produce summaries for each subsections
  • Code refactorization

How Does This Work

This repo will use ChatGPT to read complete academic papers:

  • Splitting a PDF paper into multiple parts for reading and generating a summary of each part. When reading each part, it will refer to the context of the previous part within the token limit.
  • Before reading the paper, you can set the questions you are interested in the prompt. This will help ChatGPT focus on the relevant information when reading and summarizing, resulting in better reading performance.
  • Answer your question based on all the summaries of all parts of the paper.

By default, the initialized prompt will ask ChatGPT to focus on these points:

  • Who are the authors?
  • What is the process of the proposed method?
  • What is the performance of the proposed method? Please note down its performance metrics.
  • What are the baseline models and their performances? Please note down these baseline methods.
  • What dataset did this paper use?

These questions are designed for research articles in the field of computer science. After finishing reading the paper, you can ask questions using the question() interface.

Example: Read AlexNet Paper

Summarize AlexNet

import pickle
from gpt_reader.paper.paper import Paper
from gpt_reader.pdf_reader import PaperReader

reader = PaperReader(openai_key='')
paper = Paper('./alexnet.pdf')
summary = reader.summarize(paper)

# save paper & load
pickle.dump(paper, open('digested_paper.pkl', 'wb'))
paper = pickle.load(open('digested_paper.pkl', 'rb'))
# print summary of a section
print(paper.paper_summaries[4])
# console print
Beep....Beep....Beep.... Parsing
Beep....Beep....Beep.... I am reading
100%|██████████| 16/16 [02:20<00:00,  8.78s/it]
Bzzzt-klonk... Reading Done, I have built memories for this paper.

reply: ('3 The Architecture\n', "Summary:\nThe authors present the architecture of their network, which contains eight learned layers, including five convolutional and three fully-connected layers. They describe some novel or unusual features of their network's architecture, sorted according to their estimation of their importance.") ...

Ask some questions

session.question(paper, 'Authors of this paper?')

reply: The authors of this paper are Alex Krizhevsky, Ilya Sutskever, and Geoffrey E. Hinton from the University of Toronto.

session.question(paper, 'Describe the proposed method in details.')

reply:The proposed method is based on a large, deep convolutional neural network that is trained with stochastic gradient descent using techniques like weight decay, momentum, and dropout for regularization. The network consists of eight layers (five convolutional and three fully-connected) with the output layer consisting of a 1000-way softmax to produce a distribution over 1000 class labels. The authors used a ReLU activation function and local response normalization to improve training speed, and overlapping pooling to improve generalization. They also reduced overfitting by augmenting the training data with techniques like image translations, horizontal reflections, and altering the intensities of the RGB channels in training images using PCA. The proposed method was trained on subsets of the ImageNet dataset used in the ILSVRC-2010 and ILSVRC-2012 competitions, which contain roughly 1.2 million training images, 50,000 validation images, and 150,000 testing images. By using a large, deep convolutional neural network with various optimization strategies, the proposed method achieved top-5 error rates of 16.4% and 15.3% on the ILSVRC-2012 validation and test sets, respectively, outperforming the previous state-of-the-art results.

session.question(paper, 'What dataset does this paper use for experiment?')

reply: The authors used subsets of the ImageNet dataset used in the ILSVRC-2010 and ILSVRC-2012 competitions for their experiments. These subsets contain approximately 1.2 million training images, 50,000 validation images, and 150,000 testing images.

session.question(paper, 'What metrics does this paper use to evaluate the performace?')

reply: The paper evaluated the performance of their proposed method using Top-1 and Top-5 error rates on the validation and test sets of the ILSVRC-2010 and ILSVRC-2012 image recognition challenges. The Top-1 error rate measures the percentage of images for which the predicted class label is not the correct label, while the Top-5 error rate measures the percentage of images for which the correct label is not among the five most probable labels predicted by the model.

session.question(paper, 'Summarize this paper and your anwsers above, then translate the result into Chinese')

reply: 这篇论文的作者是来自Toronto大学的Alex Krizhevsky、Ilya Sutskever和Geoffrey E. Hinton。该论文提出了一种基于卷积神经网络的深度学习方法,该方法在 ImageNet LSVRC-2010 和 ImageNet LSVRC-2012 图像识别挑战中达到了最佳结果。\n\n该方法使用了一系列技术来优化性能,包括使用ReLU激活函数和局部响应归一化等方法提高训练速度,使用重叠池化等方法提高泛化能力。为了减少过拟合,该方法还使用了数据增强技术,如图像平移、水**射和使用PCA修改训练图像的RGB通道强度。作者在多个GPU上使用随机梯度下降进行训练,通过调整学习速率和使用权重衰减、动量和dropout等技术来优化性能。\n\n用于实验的数据集是 ImageNet LSVRC-2010 和 ImageNet LSVRC-2012 数据集的子集,其中包括大约120万个训练图像、5万个验证图像和15万个测试图像。该方法相比之前的最佳结果,达到了 更好的Top-1错误率和Top-5错误率。作者使用这两个错误率来评估性能,Top-1错误率表示预测的类别不是正确标签的百分率,而Top-5错误率表示真实标签不在模型预测的五个最可能标签中的百分率。

GUI Interface

alt

  1. Install gradio in your python environment.
pip install gradio
  1. Run gui.py. The link to the web page is output in the console.
python gui.py

alt 3. Fill in your API_KEY in the appropriate places on the web page and upload the required analysis PDF file. After you wait for the program to finish analyzing, you can switch to the second TAB and ask the program questions about the PDF.

TODO

  • You may exceed the token limit when asking questions.
  • More prompt tuning needed to let it outputs stable results.
  • Imporve summary accuracies

chatgpt-paper-reader's People

Contributors

fengh16 avatar kir-gadjello avatar slyne avatar talkingwallace avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chatgpt-paper-reader's Issues

NameError: name 'session' is not defined

请问下,我在python运行完pdf之后,在python console”输入“session. question('Authors of this paper?')”
但是得到的回答是
Traceback (most recent call last):
File "", line 1, in
NameError: name 'session' is not defined
请问这种情况,应该如何解决

Paper length exceeds maximum context length

Got this error:
openai.error.InvalidRequestError: This model's maximum context length is 4097 tokens. However, your messages resulted in 7328 tokens. Please reduce the length of the messages.

Is it possible to break the paper into multiple pieces then query one paper piece at a time to avoid this issue?

GUI version after drag report cant read a empty file

File "C:\Users\shiel\AppData\Roaming\Python\Python310\site-packages\PyPDF2_reader.py", line 1414, in read
self._basic_validation(stream)
File "C:\Users\shiel\AppData\Roaming\Python\Python310\site-packages\PyPDF2_reader.py", line 1455, in _basic_validation
raise EmptyFileError("Cannot read an empty file")
PyPDF2.errors.EmptyFileError: Cannot read an empty file

HOCR Converter, open_filename, FileOrName, AnyIO doesn't exist in the pdfminer library

Python version:
Python 3.9.7

pdfminer version:
pdfminer==20191125 from the repo's requirements.txt

Problem:

After installing all dependencies and running python example.py, there are functions in pdfminer that don't exist in the installed library.

Error Message:

ImportError: cannot import name 'HOCRConverter' from 'pdfminer.converter' (/Users/junkim/Development/projects/ai/ChatGPT-Paper-Reader/pdf-gpt/lib/python3.9/site-packages/pdfminer/converter.py)

After commenting out the HOCRConverter from
from .converter import ( XMLConverter, HTMLConverter, TextConverter, PDFPageAggregator, HOCRConverter, ),

from .utils import open_filename, FileOrName, AnyIO
also isn't able to import the three functions open_filename, FileOrName, and AnyIO.

Would love to figure out what's going wrong and be able to check out the program!

TypeError: Unsupported input type

When I ran the GUI version of this Python code and selected alexnet.pdf as an example to analyze, I got the following error:

File "/opt/homebrew/lib/python3.10/site-packages/pdfminer/utils.py", line 59, in init raise TypeError("Unsupported input type: %s" % type(filename))
TypeError: Unsupported input type: <class 'tempfile._TemporaryFileWrapper'>"

My Gradio version is 3.15.0.

Unexpected ERROR

After inputting the API KEY and proxy address, it still faces some errors when running the program. (saddd)
Must I use a USA proxy to run the program if I am in China?🤔
螢幕截圖 2023-12-06 13 20 12

apikey访问频率问题

openai.error.RateLimitError: Rate limit reached for default-gpt-3.5-turbo in organization org-PanV93eoQzPe3QALIzkJ8Iof on requests per min. Limit: 3 / min. Please try again in 20s.

请问这是因为访问频率过快吗?怎么解决这个问题呢?

drop_conversation 逻辑错误

由于msg 长度永远为2 zip(msg[1::2], msg[2::2]),导致drop_conversation 总对于过长的信息只是保留,并没有截断。

Cannot read an empty file

PyPDF2.errors.EmptyFileError: Cannot read an empty file.

Right after I upload the pdf, and click Start Analyze.
The feedback that I got at "Ask question about your PDF" is always: I'm sorry, I still don't have enough information to provide you with a specific answer. Can you please provide me with the title of the paper or any additional information so I can assist you better?

Request: Requirement txt or pyproject.toml

Hi,

Thank you for sharing this app. I just want to ask if you can provide your requirement.txt in README.md, so we don't need to install them one by one when running it.

PyPDF2.errors.EmptyFileError: Cannot read an empty file

Traceback (most recent call last):
File "D:\Anaconda3\lib\site-packages\gradio\routes.py", line 393, in run_predict
output = await app.get_blocks().process_api(
File "D:\Anaconda3\lib\site-packages\gradio\blocks.py", line 1069, in process_api
result = await self.call_function(
File "D:\Anaconda3\lib\site-packages\gradio\blocks.py", line 878, in call_function
prediction = await anyio.to_thread.run_sync(
File "D:\Anaconda3\lib\site-packages\anyio\to_thread.py", line 28, in run_sync
return await get_asynclib().run_sync_in_worker_thread(func, *args, cancellable=cancellable, File "D:\Anaconda3\lib\site-packages\anyio_backends_asyncio.py", line 818, in run_sync_in_worker_thread
return await future
File "D:\Anaconda3\lib\site-packages\anyio_backends_asyncio.py", line 754, in run
result = context.run(func, *args)
File "c:\Users\Administrator\Desktop\Paper-Reader\gui.py", line 14, in analyse
return self.session.read_pdf_and_summarize(pdf_file)
File "c:\Users\Administrator\Desktop\Paper-Reader\gpt_reader\pdf_reader.py", line 100, in read_pdf_and_summarize
pdf_reader = PdfReader(pdf_path)
File "D:\Anaconda3\lib\site-packages\PyPDF2_reader.py", line 319, in init
self.read(stream)
File "D:\Anaconda3\lib\site-packages\PyPDF2_reader.py", line 1414, in read
self._basic_validation(stream)
File "D:\Anaconda3\lib\site-packages\PyPDF2_reader.py", line 1455, in _basic_validation
raise EmptyFileError("Cannot read an empty file")

"Error" After start anlyse.

Despite placing the key correctly, when I click start analyse I get the message "error". it even doesn't work with the template PDF.

TypeError: Unsupported input type: <class 'tempfile._TemporaryFileWrapper'>

I upload the alexnet.pdf and click start analyse ,it return an Error.
And I check the IDE it show this.

Beep....Beep....Beep.... Parsing
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\gradio\routes.py", line 292, in run_predict
output = await app.blocks.process_api(
File "C:\ProgramData\Anaconda3\lib\site-packages\gradio\blocks.py", line 1007, in process_api
result = await self.call_function(fn_index, inputs, iterator, request)
File "C:\ProgramData\Anaconda3\lib\site-packages\gradio\blocks.py", line 848, in call_function
prediction = await anyio.to_thread.run_sync(
File "C:\ProgramData\Anaconda3\lib\site-packages\anyio\to_thread.py", line 28, in run_sync
return await get_asynclib().run_sync_in_worker_thread(func, *args, cancellable=cancellable,
File "C:\ProgramData\Anaconda3\lib\site-packages\anyio_backends_asyncio.py", line 818, in run_sync_in_worker_thread
return await future
File "C:\ProgramData\Anaconda3\lib\site-packages\anyio_backends_asyncio.py", line 754, in run
result = context.run(func, *args)
File "F:\yjj\ChatGPT-Paper-Reader\gui.py", line 15, in analyse
return self.session.summarize(self.paper)
File "F:\yjj\ChatGPT-Paper-Reader\gpt_reader\pdf_reader.py", line 30, in summarize
paper = self.bot.read_paper(paper)
File "F:\yjj\ChatGPT-Paper-Reader\gpt_reader\bot\openai.py", line 139, in read_paper
titles = self.parse_pdf_title(paper.pdf_path)
File "F:\yjj\ChatGPT-Paper-Reader\gpt_reader\bot\openai.py", line 72, in parse_pdf_title
for page_layout in extract_pages(pdf_path):
File "C:\ProgramData\Anaconda3\lib\site-packages\pdfminer\high_level.py", line 203, in extract_pages
with open_filename(pdf_file, "rb") as fp:
File "C:\ProgramData\Anaconda3\lib\site-packages\pdfminer\utils.py", line 59, in init
raise TypeError("Unsupported input type: %s" % type(filename))
TypeError: Unsupported input type: <class 'tempfile._TemporaryFileWrapper'>

I copy it to the GPT4,it answered me :

The error is caused by the pdfminer.high_level.extract_pages() function expecting a file path (a string) or a file-like object as its argument, but it appears to be receiving a tempfile._TemporaryFileWrapper object instead.

To fix this issue, you should pass a proper file path or a file-like object to the extract_pages() function. You can make the following changes in your gpt_reader\bot\openai.py file:

1.If you are using a temporary file, make sure to call the name attribute to get the file path before passing it to the extract_pages() function:

temp_file_path = tempfile_object.name
for page_layout in extract_pages(temp_file_path):

2.Alternatively, if you want to pass a file-like object, you can open the temporary file in binary mode and pass it to the extract_pages() function:

with open(tempfile_object.name, "rb") as file_object:
for page_layout in extract_pages(file_object):

By ensuring that you are passing the correct file path or file-like object to the extract_pages() function, you should be able to avoid the TypeError raised in your script.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.