AbstractBrain Answers About us →

How to summarize a long text using LLM like ChatGPT that have token limits


I need to summarize a long text (e.g. a book or a document) using the OpenAI API. However it has a token limit (e.g. 4k words) that is much shorter compared to an entire book. Is there any solution to summarize a long text that exceeds the token limit?


You can split the text into chunks and summarize each chunk separately. Then you can concatenate the partial summaries to get a summary of the book. If this summary is still too long you can repeat the same process to summarize the text that you got. For better results you should also try to break the text into chunks naturally: for example you should not break words or paragraphs.

Here’s an algorithm that you can use: