How to
How do I prepare multimodal data for AI?
To prepare images, video, audio, and documents for AI search, retrieval, and inference at scale: store the files by reference with their metadata, extract model-ready units (frames, transcripts, page chunks), embed them, index them, version the result, and keep all of it updating incrementally as files arrive. That is AI-ready data. A data lake is optional, not a prerequisite.
Updated · Part of How do I ... in Python?
Before you start
About 30 min.
- Python 3.11+
- pip install -U 'pixeltable[serve]'
- pxt init in the project root
- spacy and tiktoken for sentence,token_limit splitting
- sentence-transformers for all-MiniLM-L6-v2
- torch for CLIP
- ffmpeg
- openai-whisper
1. Store images, video, audio, and documents as typed tables
AI-ready data starts as files plus metadata, not as a folder of paths in a spreadsheet. Keep each modality as rows the engine understands: an Image, a Video, an Audio file, or a Document. A path or URL fills the column after you apply the schema. Separate tables keep types non-nullable.
import pixeltable as pxtfrom pixeltable.functions.audio import audio_splitterfrom pixeltable.functions.document import document_splitterfrom pixeltable.functions.huggingface import clip, sentence_transformerfrom pixeltable.functions.video import extract_audio, frame_iteratorfrom pixeltable.functions.whisper import transcribeTableModel = pxt.model_base()text_embed = sentence_transformer.using(model_id='all-MiniLM-L6-v2')clip_embed = clip.using(model_id='openai/clip-vit-base-patch32')class Images(TableModel, name='images'):title: pxt.Stringimage: pxt.Image__indexes__ = [pxt.EmbeddingIndex(image, embedding=clip_embed)]class Videos(TableModel, name='videos'):title: pxt.Stringvideo: pxt.Videoaudio = extract_audio(video)transcript = transcribe(audio, model='base').text.astype(pxt.String)__indexes__ = [pxt.EmbeddingIndex(transcript, string_embed=text_embed)]class Recordings(TableModel, name='recordings'):title: pxt.Stringaudio: pxt.Audioclass Docs(TableModel, name='docs'):title: pxt.Stringdocument: pxt.Document
2. Extract frames, transcript slices, and page chunks
Models do not search a whole file. Split each document into sentence windows with a token limit. Split each recording into timestamped audio slices and transcribe them. Walk each clip at one frame per second. Those rows are the retrieval units. Each still keeps frame_attrs so a hit is a moment.
class Chunks(TableModel,name='chunks',base=Docs,iterator=document_splitter(document=Docs.document, separators='sentence,token_limit', limit=300),):__indexes__ = [pxt.EmbeddingIndex(text, string_embed=text_embed)]class MeetingSegments(TableModel,name='meeting_segments',base=Recordings,iterator=audio_splitter(audio=Recordings.audio, duration=30.0),):transcript = transcribe(audio_segment, model='base').text.astype(pxt.String)__indexes__ = [pxt.EmbeddingIndex(transcript, string_embed=text_embed)]class Frames(TableModel,name='frames',base=Videos,iterator=frame_iterator(video=Videos.video, fps=1),):__indexes__ = [pxt.EmbeddingIndex(frame, embedding=clip_embed)]
3. Query the indexes for search and retrieval
A similarity query ranks document chunks or video stills. Retrieval is those rows. Inserting a new file later updates only that file: new chunks, new slices, new frames, and their indexes.
@pxt.querydef search_passages(question: str, limit: int = 5):sim = Chunks.text.similarity(string=question)return (Chunks.order_by(sim, asc=False).limit(limit).select(title=Docs.title, text=Chunks.text, score=sim))@pxt.querydef search_video(question: str, limit: int = 5):sim = Frames.frame.similarity(string=question)return (Frames.order_by(sim, asc=False).limit(limit).select(title=Videos.title, frame_attrs=Frames.frame_attrs, score=sim))
4. Apply the schema, insert files, and version
Apply the schema first. Insert through the bound tables. Each insert or schema change creates a table version. Snapshot the document chunks, video frames, and transcript slices you will query. history lists versions. revert undoes the last operation for every user of the table and is irreversible.
# pxt schema update app.py prep -fimport pixeltable as pxtimages = pxt.get_table('prep.images')videos = pxt.get_table('prep.videos')recordings = pxt.get_table('prep.recordings')docs = pxt.get_table('prep.docs')chunks = pxt.get_table('prep.chunks')frames = pxt.get_table('prep.frames')meeting_segments = pxt.get_table('prep.meeting_segments')images.insert([{'title': 'Dock still', 'image': 'stills/dock.jpg'}])videos.insert([{'title': 'Dock camera', 'video': 'clips/dock-0930.mp4'}])recordings.insert([{'title': 'Weekly sync', 'audio': 'recordings/weekly-sync.mp3'}])docs.insert([{'title': 'Handbook', 'document': 'docs/handbook.pdf'}])pxt.create_snapshot('prep.docs_v1', docs)pxt.create_snapshot('prep.chunks_v1', chunks)pxt.create_snapshot('prep.frames_v1', frames)pxt.create_snapshot('prep.meeting_segments_v1', meeting_segments)print(docs.history(n=5))# docs.revert() # irreversible; restores the previous version
How to prepare multimodal data without one schema (last reviewed: November 2026)
| Step | Glue stack | One application schema |
|---|---|---|
| Store files | Object storage (S3 or R2) plus a metadata table | Typed Image, Video, Audio, and Document columns, by reference |
| Extract units | Unstructured or Docling for PDFs; FFmpeg for frames; a speech job for audio | document_splitter, frame_iterator, audio_splitter plus Whisper on insert |
| Embed and index | A batch embedding job that upserts into a vector DB | EmbeddingIndex on the source table or view; insert keeps it current |
| Orchestrate | Airflow, Dagster, Prefect, or Kestra around those jobs | Computed columns and views; not a general-purpose scheduler |
| Version and query | A snapshot of the lake plus a search service you deploy | column.similarity in the schema file; create_snapshot and history after pxt schema update |
Where Pixeltable fits
Pixeltable is the unified multimodal AI backend for this job: typed media columns, iterators that emit frames and chunks, embedding indexes that stay current on insert, and snapshots of the tables. It is not a DAG scheduler, not a vector database, not a lakehouse, not an annotation tool, and not a hosted document-parsing API. Keep Unstructured or Docling if PDF conversion is the product. Keep Airflow for warehouse DAGs. See Pixeltable vs Airflow when the stack is Airflow plus a vector DB.
import pixeltable as pxtfrom pixeltable.functions.document import document_splitterfrom pixeltable.functions.huggingface import sentence_transformerTableModel = pxt.model_base()text_embed = sentence_transformer.using(model_id='all-MiniLM-L6-v2')class Docs(TableModel, name='docs'):title: pxt.Stringdocument: pxt.Documentclass Chunks(TableModel,name='chunks',base=Docs,iterator=document_splitter(document=Docs.document, separators='sentence,token_limit', limit=300),):__indexes__ = [pxt.EmbeddingIndex(text, string_embed=text_embed)]
Questions
What is AI-ready data?
Do I need a data lake first?
How do I keep it fresh as files change?
How do I prepare video specifically?
What is the open-source option for preparing unstructured data for AI?
How do I prepare unstructured data for AI?
Next step
Copy the commands into an agent, or run them locally with pip install pixeltable.