liveBook · Manning

Pipeline

As explained in Build Applications with Local AI Models on a Mac

A sequence of processing stages in which each stage feeds its output to the next.

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

How Build Applications with Local AI Models on a Mac covers it

How deep it goes
Works through stage handoffs, a temporary-file bridge, and separate startup checks; leaves branching multistep chains for later exploration.
Examples
Uses a voice chatbot, a prompt-to-LLM-to-parser chain, and a fine-tuned model exported to Ollama.
What it assumes
Introduces command-line and machine-learning concepts from zero while noting that basic Python fundamentals help when coding begins.
What you can do after
Build it from scratch as a local voice chatbot, then diagnose failures by testing its prerequisites separately.
How it connects
Links speech recognition, LLM inference, Streamlit, LangChain chains, and fine-tuning.

Also explained in

Compare how 48 books explain pipeline →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build Applications with Local AI Models on a Mac. The section links point to the parts of the book it draws on.