C.W.K.
Stream
Lesson 01 of 07 · published

What is KerasNLP/KerasHub?

~8 min · keras-nlp

Level 0Keras Apprentice
0 XP0/97 lessons0/20 achievements
0/120 XP to next level120 XP to go0% complete

Same idea on the text side. KerasHub has BERT, GPT-2, Llama, Gemma, Mistral with task heads (classification, generation) and tokenizers tied to the model. LoRA fine-tuning is one parameter. This track is how you go from 'I want to fine-tune Gemma on my data' to a saved model in a half-day.

One name change, one mental model

KerasNLP was the modular NLP library for Keras — pretrained transformers, matched tokenizers, and task-specific heads, all in one package. In September 2024 it was renamed to KerasHub, and the rename wasn't cosmetic: the team folded the old vision library (KerasCV) into the same hub, so text, vision, and audio models now load through one consistent from_preset() door. Learn the pattern once here and it transfers to every other modality.

The keras_nlp import still works for backwards compatibility, so old tutorials don't break — but new code should reach for keras_hub. If you see a 2023-era snippet importing keras_nlp, it's not wrong, just older; swap the import and the rest of the API is identical.

What a "hub" actually gives you

The point of a hub is that a model is never just weights. Each preset bundles the architecture, the pretrained weights, and the exact tokenizer that model was trained with — so the three pieces can never drift apart. That single guarantee is what makes the rest of this track fast: every lesson ahead (pretrained models, tokenizers, classification, generation, LoRA) is really just a different verb applied to the same from_preset() object.

External links

Exercise

Install keras-hub. List 5 NLP presets. Pick BertClassifier and load via from_preset with num_classes=2. Confirm the bundled tokenizer is also accessible (model.preprocessor.tokenizer) — this proves the model+tokenizer pairing the lesson described.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.