RunnableParallel is a LangChain runnable for executing independent operations concurrently. It is useful when the same input must pass through several chains, or when every item in a sequence can be processed independently before a later reduction step. section 3.1.3 section 4.8
Use RunnableParallel in two closely related ways:
- Wrap named operations such as search, extraction, or summarization to run them concurrently on the same input. section 4.8
- Apply a runnable with .map() so each document chunk, URL, or search result receives its own chain execution. section 3.4 section 4.8
- Combine the parallel results with a later reduce or synthesis stage; MapReduce favors speed and lower token costs over complete context. section 3.1.3 section 3.4
Parallel document summarization
Create a prompt-to-model chain, parse its output into text, and place it inside RunnableParallel under the key "summary". Applying the resulting map chain to a list of chunks runs the same summarizer for each chunk independently. A later chain can combine those partial summaries into a final result. section 3.1.3 section 3.4
summarize_chunk_prompt_template = """
Write a concise summary of the following text, and include the main details.
Text: {chunk}
"""
summarize_chunk_prompt =
PromptTemplate.from_template(summarize_chunk_prompt_template)
summarize_chunk_chain = summarize_chunk_prompt | llm
summarize_map_chain = (
RunnableParallel (
{
'summary': summarize_chunk_chain | StrOutputParser()
}
)
)
The listing shows the implementation shape: construct a PromptTemplate, pipe it through an LLM and StrOutputParser, then wrap the chain in RunnableParallel. section 3.1.3

