Instructions to use keras/bloom_1.7b_multi with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- KerasHub
How to use keras/bloom_1.7b_multi with KerasHub:
import keras_hub # Load CausalLM model (optional: use half precision for inference) causal_lm = keras_hub.models.CausalLM.from_preset("hf://keras/bloom_1.7b_multi", dtype="bfloat16") causal_lm.compile(sampler="greedy") # (optional) specify a sampler # Generate text causal_lm.generate("Keras: deep learning for", max_length=64)import keras_hub # Create a Backbone model unspecialized for any task backbone = keras_hub.models.Backbone.from_preset("hf://keras/bloom_1.7b_multi") - Keras
How to use keras/bloom_1.7b_multi with Keras:
# Available backend options are: "jax", "torch", "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" import keras model = keras.saving.load_model("hf://keras/bloom_1.7b_multi") - Notebooks
- Google Colab
- Kaggle
Model Overview
BLOOM as described in as descriped in BLOOM: A 176B-Parameter Open-Access Multilingual Language Model, is a large language model published by BigScience. BLOOM is able to output coherent text in 46 languages and 13 programming languages. BLOOM models range in size from 0.5 billion to 3 billion parameters. See the model card below for benchmarks, data sources, and intended use cases.
Weights are released under the RAIL License. Keras model code is released under the Apache 2 License.
Links
- BLOOM Quickstart Notebook
- BLOOM API Documentation
- BLOOM Model Card
- KerasHub Beginner Guide
- KerasHub Model Publishing Guide
Installation
Keras and KerasHub can be installed with:
pip install -U -q keras-hub
pip install -U -q keras>=3
Jax, TensorFlow, and Torch come preinstalled in Kaggle Notebooks. For instructions on installing them in another environment see the Keras Getting Started page.
Presets
The following model checkpoints are provided by the Keras team. Full code examples for each are available below.
| Preset name | Parameters | Description |
|---|---|---|
bloom_560m_multi |
559M | 560M base model |
bloom_1.1b_multi |
1.06B | 1B base model |
bloom_1.7b_multi |
1.72B | 1.7B base model |
bloom_3b_multi |
3B | 3B base model |
bloomz_560m_multi |
559M | 560m instruction-tuned model |
bloomz_1.1b_multi |
1.06B | 1B instruction-tuned model |
bloomz_1.7b_multi |
1.72B | 1.7B instruction-tuned model |
bloomz_3b_multi |
3B | 3B instruction-tuned model |
Prompts
The performance may vary depending on the prompt. For BLOOMZ models, we recommend making it very clear when the input stops to avoid the model trying to continue it. For example, the prompt "Translate to English: Je t'aime" without the full stop (.) at the end, may result in the model trying to continue the French sentence. Better prompts are e.g. "Translate to English: Je t'aime.", "Translate to English: Je t'aime. Translation:" "What is "Je t'aime." in English?", where it is clear for the model when it should answer. Further, we recommend providing the model as much context as possible. For example, if you want it to answer in Telugu, then tell the model, e.g. "Explain in a sentence in Telugu what is backpropagation in neural networks.".
Example Usage
import os
os.environ["KERAS_BACKEND"] = "jax"
import keras
import keras_hub
# When running only inference, bfloat16 saves memory usage significantly.
keras.config.set_floatx("bfloat16")
bloom_lm = keras_hub.models.BloomCausalLM.from_preset(
"bloom_1.7b_multi"
)
bloom_lm.summary()
outputs = bloom_lm.generate([
"What is Keras?",
], max_length=512)
for output in outputs:
print(output)
Example Usage with Hugging Face URI
import os
os.environ["KERAS_BACKEND"] = "jax"
import keras
import keras_hub
# When running only inference, bfloat16 saves memory usage significantly.
keras.config.set_floatx("bfloat16")
bloom_lm = keras_hub.models.BloomCausalLM.from_preset(
"hf://keras/bloom_1.7b_multi"
)
bloom_lm.summary()
outputs = bloom_lm.generate([
"What is Keras?",
], max_length=512)
for output in outputs:
print(output)
- Downloads last month
- 5