How keras-team/keras-hub works
KerasHub is a multi-backend pretrained-model library for text, image, audio, and multimodal tasks. The principal workflow is: a user calls the public Keras API, task models select preprocessing and tokenization, backbones execute shared modeling layers, and predictions or generated text are returned. Presets provide pretrained weights, while PipelineModel integrates preprocessing with Keras training/evaluation. The tree also documents metrics and an optional vLLM TPU serving path. Some subsystem links are inferred from documented APIs and filenames because most implementations were not sampled.
Main entry points: task.py Task Models · causal_lm.py Text Tasks · preprocessing Media Preprocessing · __init__.py KerasHub API
Components 20
Public API
- KerasHub API
keras_hub/api/__init__.py
Input Processing
- Text Preprocessing
keras_hub/src/models/preprocessor.py - Tokenizers
keras_hub/src/models - Media Preprocessing
keras_hub/src/layers/preprocessing
Model Runtime
- Task Models
keras_hub/src/models/task.py - Text Tasks
keras_hub/src/models/causal_lm.py - Vision Tasks
keras_hub/src/models/image_classifier.py - Audio Tasks
keras_hub/src/models/audio_to_text.py - Multimodal Tasks
keras_hub/src/models - Model Backbones
keras_hub/src/models/backbone.py - Transformer Layers
keras_hub/src/layers/modeling/transformer_decoder.py - Position Encoding
keras_hub/src/layers/modeling/rotary_embedding.py - Preset Configs
keras_hub/src/models/gemma/gemma_presets.py
Training Evaluation
- Pipeline Model
keras_hub/src/utils/pipeline_model.py - Task Metrics
keras_hub/src/metrics/__init__.py
Serving Integrations
- vLLM Wrapper
keras_hub/src/vllm/keras_hub_vllm_wrapper.py
Other components
- Application User
- Kaggle Models
- vLLM TPU
- Predictions Results
Connections 23
- Application User → KerasHub API: calls API
- KerasHub API → Task Models: dispatches tasks
- Task Models → Text Tasks: selects text
- Task Models → Vision Tasks: selects vision
- Task Models → Audio Tasks: selects audio
- Task Models → Multimodal Tasks: selects multimodal
- Text Tasks → Tokenizers: tokenizes text
- Text Tasks → Text Preprocessing: preprocesses text
- Vision Tasks → Media Preprocessing: preprocesses media
- Audio Tasks → Media Preprocessing: preprocesses media
- Multimodal Tasks → Media Preprocessing: preprocesses media
- Task Models → Pipeline Model: uses pipeline
- Pipeline Model → Text Preprocessing: applies preprocessing
- Task Models → Model Backbones: runs backbone
- Model Backbones → Transformer Layers: executes layers
- Transformer Layers → Position Encoding: applies positions
- Task Models → Preset Configs: loads presets
- Preset Configs → Kaggle Models: fetches weights
- Application User → Task Metrics: evaluates outputs
- vLLM Wrapper → Text Tasks: loads causal model
- vLLM TPU → vLLM Wrapper: invokes serving
- Task Models → Predictions Results: returns predictions
- Text Tasks → Predictions Results: generates text