Skip to content

v0.15.0

Compare
Choose a tag to compare
@mattdangerw mattdangerw released this 13 Sep 19:26
· 5 commits to r0.15 since this release
99df05b

Summary

πŸ“’ KerasNLP is becoming KerasHub πŸ“’, read more about it here.

This release contains a number of feature improvements:

  • Added int8 quantization support.
    • Use the quantize() method to quantize any model.
    • Llama 2 and Llama 3 pre-quantized presets are available.
  • PaliGemmaCausalLM will automatically resize input images during preprocessing.
  • Added more converters for hugginface/transformers checkpoints.
    • Gemma 2, PaliGemma, GPT2, Bert, Albert, DistilBert, Bart.
  • Class detection for huggingface/transformers checkpoints.
    • Call from_preset() on a base class, and we will find the correct subclass to create.
  • Added Vicuna presets.
  • Alias Classifier as TextClassifier, BertClassifier as BertTextClassifier.
  • Added tokenizer.special_tokens and tokenizer.special_token_ids as convenient properties to view all special tokens on a pretrained tokenizer.
# Quantize an unquantized model.
lm = keras_nlp.models.CausalLM.from_preset(
    "gemma2_instruct_2b_en",
    dtype="bfloat16",
)
lm.quantize("int8")
# Load a pre-quantized model.
lm = keras_nlp.models.CausalLM.from_preset(
    "llama3_instruct_8b_en_int8",
    dtype="bfloat16",
)
# Convert a bert model in the huggingface/transformers format.
classifier = keras_nlp.models.TextClassifier.from_preset(
    "hf://google-bert/bert-base-uncased",
    num_classes=2,
)
# View all special tokens.
print(classifier.preprocessor.tokenizer.special_tokens)
print(classifier.preprocessor.tokenizer.special_token_ids)

Breaking changes

  • On all backends, all strings and ragged output will be returned as python strings or python lists respectively.
    • This include preprocessing methods like tokenize() and detokenize().
    • This may break code that depended on tf.Tensor output on the tensorflow backend, but will lead to consistent output on all backends, which we believe will be an overall improvement.
    • Preprocessing layers can still always be included in a tf.data preprocessing pipeline, on any backend.

What's Changed

New Contributors

Full Changelog: v0.14.4...v0.15.0