A pipeline passes the output of one processing stage to the next. It helps turn several tools into one working application: a voice assistant captures speech, turns it into text, then sends that text to a language model for a reply. section 10.0
In a local voice assistant, the stages are:
- Capture audio with Streamlit’s st.audio_input(), which returns WAV data in memory. section 10.9
- Transcribe the audio with MLX Whisper. Because its transcribe() call receives a file path, write the WAV data to a temporary file and delete that file in a finally block. section 10.9
- Pass the resulting text to Ollama for a streaming response. Keyboard input can join the same path at this point, so one message-handling function serves both inputs. section 10.9
The pattern also applies when the stages are smaller than an app. A LangChain chain can fill a prompt template, call an LLM, then extract text from its output. The | operator connects those components so each feeds the next, much like a Unix pipe. section 16.4.3
from langchain_ollama import OllamaLLM
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.output_parsers import StrOutputParser
# Step 1: Define a prompt template
prompt = ChatPromptTemplate.from_messages([
("system", "You are a helpful assistant that explains concepts "
"simply. Always use an analogy in your explanation."),
("human", "Explain {concept} to a beginner.")
])
# Step 2: Create the LLM
llm = OllamaLLM(model="gemma3:4b")
# Step 3: Create a chain by connecting them with |
chain = prompt | llm | StrOutputParser()
# Step 4: Run the chain
result = chain.invoke({"concept": "machine learning"})
print(result)
The runnable chain shows the three components joined with | and invoked with a value for the prompt’s concept variable. section 16.4.3
Pipelines need not run entirely on one machine. A custom-model workflow fine-tunes a base model with Unsloth on a hosted GPU, exports it as GGUF, then creates and runs the model locally in Ollama. Check each stage separately when something fails: for a chatbot, test library imports, the Ollama connection, model availability, and Streamlit startup rather than debugging everything at once. section 17.7.1 section 15.3.2















































