Multimodal input and output
Choose a task and modality
Multimodal AI accepts or produces more than one kind of information, such as text and images. Input support does not imply output support: a model that reads an image may only emit text. Extraction returns fields, description explains content, classification selects labels, and generation creates new content. Choose the narrowest task that meets the goal; a deterministic parser may beat a model on clean tables. This lesson extends computer vision, speech and foundation models from Chapters 26, 27 and 30. The example is a host policy with fictional capability metadata, not an actual provider call.
def eligible(inputs, output, supported_inputs, supported_outputs, authorized, units, cap): # Trusted fixture metadata, not a file parser or model catalog. if type(units) is not int or type(cap) is not int or min(units,cap)<0: raise ValueError("invalid budget") return (authorized and bool(inputs) and set(inputs) <= set(supported_inputs) and output in supported_outputs and units <= cap)
print(eligible(["image","text"], "text", ["image","text"], ["text"], True, 4, 5))print(eligible(["audio"], "text", ["image","text"], ["text"], True, 4, 5))print(eligible(["image"], "text", ["image"], ["text"], False, 4, 5))Prepare each modality
Text needs consistent encoding and language metadata. Images need correct orientation, suitable resolution and preserved aspect ratio; excessive downsampling can erase small labels. Audio needs a supported format, sampling rate, channel layout and time offsets; avoid losing speech through aggressive trimming. Video combines sampled frames and possibly audio: sparse sampling can miss brief events, so retain timestamps and disclose coverage. Documents may combine searchable text, scanned pages, layout and tables; OCR (optical character recognition) converts visible text to characters but can confuse digits and reading order. Preserve page/region provenance and units. Validate actual file type, size and decoded resource limits in a sandbox; metadata alone is insufficient.
Verify capabilities and permissions
Inspect the selected model revision, accepted media types, output types, context budget, retention settings and account permissions before dispatch. The first example returns True for authorized image-plus-text within a fictional cap, False for unsupported audio, and False for denied access. Units are abstract integer budget units, not tokens or bytes. Real requests need separate limits and actual decoding. Never upload personal documents or recordings for this lab. Strip unnecessary metadata, minimize collected data, enforce access controls, and use non-person illustrations rather than identity recognition or voice cloning.
Build a chart with known answers
Use a fictional count chart with one hash mark per unit. North has three, South five and West zero. This text rendering gives a visual pattern and explicit values; it is deliberately not a raster image or OCR benchmark. A visual extraction system should preserve the label, numeric value and unit and distinguish zero from an unreadable label. A caption that says South has six is wrong even if the overall trend is correct. A truncated or blurred axis can make a comparison uncertain; abstain rather than guess.
def chart(rows): # Fixed labels, one # per fictional unit, no hidden scale. if any(type(value) is not int or not 0 <= value <= 20 for _,value in rows): raise ValueError("invalid count") return "\n".join(f"{label}: {'#'*value} ({value})" for label,value in rows)
print(chart([("North",3),("South",5),("West",0)]))Practice and next step
Predict the output if South becomes zero or the cap becomes smaller than the requested units. Explain which change affects input eligibility and which affects the ground truth. Compare extracting counts with describing the largest category, classifying the chart type and generating a new chart: each requires different evidence. For a video, ask which events a one-frame-per-second sample could miss. Reference: ref-ai-multimodal-input-and-output. Next, evaluate extraction and produce accessible alternatives.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Multimodal input and output quiz
Assess modality selection, fidelity, accessibility and trust boundaries.
A model reads images and returns text. What can you infer?
What can aggressive image downsampling remove?
Why retain video timestamps?
What does West = 0 mean in the chart?
When should a media request be dispatched?