langchain icon indicating copy to clipboard operation
langchain copied to clipboard

How to handle a long prompt?

Open gameveloster opened this issue 2 years ago • 2 comments

Hi, if we need to pass a long prompt to the openai LLM, what is the general strategy to handle this?

Summarize then pass it as a single prompt that fits inside the window? Or split the long prompt into multiple smaller ones, each send smaller prompt to the openai API, and summarize the combined results from the multiple smaller prompts? Is there an example on how to do the later?

Thank you

gameveloster avatar Feb 01 '23 17:02 gameveloster

i would check out the map_reduce method in the following documentation: https://langchain.readthedocs.io/en/latest/use_cases/summarization.html

does that answer your question

hwchase17 avatar Feb 03 '23 04:02 hwchase17

Yes it does! Trying it out now :) Thanks

gameveloster avatar Feb 05 '23 05:02 gameveloster