This documentation page is also available as an interactive notebook. You can launch the notebook in
Kaggle or Colab, or download it for use with an IDE or local Jupyter installation, by clicking one of the
above links.
Pixeltable provides seamless integration with Hugging Face datasets and
models. This tutorial covers:
- Importing datasets directly into Pixeltable tables
- Working with dataset splits (train/test/validation)
- Streaming large datasets with
IterableDataset
- Type mappings from Hugging Face to Pixeltable
- Using Hugging Face models for embeddings
Setup
Import a Hugging Face Dataset
Use pxt.create_table() with the source= parameter to import a
Hugging Face dataset directly. Pixeltable automatically maps Hugging
Face feature types to Pixeltable column types.
Connected to Pixeltable database at: postgresql+psycopg://postgres:@/pixeltable?host=/Users/pjlb/.pixeltable/pgdata
Created directory ‘hf_demo’.
Created table ‘images’.
Inserting rows into `images`: 100 rows [00:00, 310.24 rows/s]
Inserting rows into `images`: 100 rows [00:00, 353.22 rows/s]
Inserting rows into `images`: 100 rows [00:00, 368.40 rows/s]
Inserting rows into `images`: 82 rows [00:00, 567.89 rows/s]
Inserted 382 rows with 0 errors.
Working with Dataset Splits
When importing a DatasetDict (which contains multiple splits like
train/test), use extra_args={'column_name_for_split': 'split'} to
preserve split information in a column.
Using schema_overrides for Embeddings
When importing datasets with pre-computed embeddings (common in RAG),
use schema_overrides to specify the exact array shape:
Streaming Large Datasets
For very large datasets, use streaming=True to filter and sample
before importing:
Importing Audio Datasets
Audio datasets work seamlessly - Pixeltable stores audio files locally:
Created table ‘audio_samples’.
Inserting rows into `audio_samples`: 73 rows [00:00, 3960.27 rows/s]
Inserted 73 rows with 0 errors.
Inserting More Data
Use table.insert() to add more data from a HuggingFace dataset to an
existing table:
Inserting rows into `audio_samples`: 5 rows [00:00, 3186.68 rows/s]
Inserted 5 rows with 0 errors.
78
Type Mappings Reference
Using Hugging Face Models
Pixeltable integrates with Hugging Face models for embeddings and
inference, running locally without API keys.
Image Embeddings with CLIP
Text Embeddings with Sentence Transformers
Created table ‘sample_reviews’.
Inserting rows into `sample_reviews`: 100 rows [00:00, 21625.70 rows/s]
Inserted 100 rows with 0 errors.
More Hugging Face Models
Pixeltable supports many more HuggingFace models including:
- ASR:
automatic_speech_recognition() - transcribe audio
- Translation:
translation() - translate between languages
- Text Generation:
text_generation() - generate text completions
- Image Classification:
vit_for_image_classification() - classify
images
- Object Detection:
detr_for_object_detection() - detect objects
in images
See the SDK reference below for the complete list.
See Also