The pipe operator (|) passes one component’s output directly into the next component’s input, turning separate operations into a sequential chain. In LangChain Expression Language, a prompt can feed an LLM, whose response then feeds an output parser. section 3.1.3 section 4.8
Use the operator to build progressively richer workflows:
- Connect a prompt template to an LLM, then parse the model response into clean text. section 3.1.3
- Apply a chain to every document chunk with .map(), or use RunnableParallel to process independent operations concurrently. section 3.4 section 4.8
- Choose parallel MapReduce processing for speed and lower token costs, or sequential refinement when preserving more context matters. section 3.4
Summarizing a document chunk
Define a prompt for one chunk, then compose it with the model and a string parser: summarize_chunk_prompt | llm, followed by summarize_chunk_chain | StrOutputParser(). RunnableParallel can apply this chain across chunks. section 3.1.3
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()
}
)
)
Inspect the complete prompt-to-model-to-parser chain and its RunnableParallel wrapper. section 3.1.3





