AI Pulse by Inblix

Llama 3.2 Has Been Quietly Working in Keras Since Day 1

Hugging Face Blog · Oct 21, 2024 · 2 min read · Read original article →

Curated by the Inblix editorial team


Featured image for article: Llama 3.2 Has Been Quietly Working in Keras Since Day 1

If you’ve been waiting to use Meta’s new Llama 3.2 models in Keras, you can stop. Martin Görner from Google confirmed the models have worked since launch day, with zero conversion headaches. You can load any standard safetensors checkpoint from Hugging Face directly, and any necessary conversion happens on the fly.

The process is absurdly simple. A single keras_hub import and one line of code is all it takes to load the instruction-tuned 1B model: Llama3CausalLM.from_preset("hf://meta-llama/Llama-3.2-1B-Instruct", dtype="bfloat16"). Görner’s demo Colab shows the generate() method working directly on strings, with the tokenizer bundled in by default. This “batteries included” approach means you can even fine-tune on a raw list of strings with a straightforward model.fit(strings) call.

Under the hood, the Keras multi-backend setup lets you run the same model on JAX, PyTorch, or TensorFlow just by setting the KERAS_BACKEND environment variable. This is a quiet but significant advantage for developers who want XLA compilation speed on JAX without abandoning a familiar workflow. The newly renamed keras-hub library (formerly KerasNLP and KerasCV) houses the canonical implementations, and the preprocessor handles all the messy details like adding start/end tokens, padding, and generating shifted training targets.

For those who want to peek under the hood, the tokenizer and backbone model are exposed directly. A helper ChatState class handles the verbose conversation tagging format required by instruction-tuned variants, making turn-by-turn chat a matter of string concatenation. I’m not surprised by the seamless compatibility—Keras has been aggressively positioning itself as a backend-agnostic modeling front-end—but the speed at which a newly released model like Llama 3.2 just works is a solid signal that the Hugging Face integration is now genuinely frictionless. Once you’re done fine-tuning, you can push the model straight back to the Hub with keras_hub.upload_preset(), which closes the loop neatly for sharing or deployment.

💡 Key Takeaways

  1. Meta's Llama 3.2 checkpoints load natively in Keras without manual conversion, a process that works on the fly.
  2. The Keras multi-backend architecture lets you run the same Llama 3.2 model code on JAX, PyTorch, or TensorFlow by setting one environment variable.
  3. Keras offers a 'batteries included' experience where the tokenizer is bundled with the model, allowing generation and training directly on raw text strings.

Keep reading: See related articles below for more coverage on this topic.

Get smarter about AI

The sharpest AI news, curated daily. Delivered free to your inbox.

Learn more

Glossary terms

← Back to all articles