keras-hub


Namekeras-hub JSON
Version 0.17.0 PyPI version JSON
download
home_pagehttps://github.com/keras-team/keras-hub
SummaryIndustry-strength Natural Language Processing extensions for Keras.
upload_time2024-10-22 02:11:18
maintainerNone
docs_urlNone
authorKeras team
requires_python>=3.9
licenseApache License 2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # KerasHub: Multi-framework Models
[![](https://github.com/keras-team/keras-hub/workflows/Tests/badge.svg?branch=master)](https://github.com/keras-team/keras-hub/actions?query=workflow%3ATests+branch%3Amaster)
![Python](https://img.shields.io/badge/python-v3.9.0+-success.svg)
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/keras-team/keras-hub/issues)

> [!IMPORTANT]
> 📢 KerasNLP is becoming KerasHub! 📢 Read
> [the announcement](https://github.com/keras-team/keras-hub/issues/1831).
>
> We have renamed the repo to KerasHub in preparation for the release, but have not yet
> released the new package. Follow the announcement for news.

KerasHub is a library that supports natural language processing, computer
vision, audio, and multimodal backbones and task models, working natively with
TensorFlow, JAX, or PyTorch. KerasHub provides a repository of pre-trained
models and a collection of lower-level building blocks for these tasks. Built
on Keras 3, models can be trained and serialized in any framework and re-used
in another without costly migrations.

This library is an extension of the core Keras API; all high-level modules are
Layers and Models that receive that same level of polish as core Keras.
If you are familiar with Keras, congratulations! You already understand most of
KerasHub.

All models support JAX, TensorFlow, and PyTorch from a single model
definition and can be fine-tuned on GPUs and TPUs out of the box. Models can
be trained on individual accelerators with built-in PEFT techniques, or
fine-tuned at scale with model and data parallel training. See our
[Getting Started guide](https://keras.io/guides/keras_nlp/getting_started)
to start learning our API. Browse our models on
[Kaggle](https://www.kaggle.com/organizations/keras/models).
We welcome contributions.

## Quick Links

### For everyone

- [Home Page](https://keras.io/keras_nlp)
- [Developer Guides](https://keras.io/guides/keras_nlp)
- [API Reference](https://keras.io/api/keras_nlp)
- [Pre-trained Models](https://www.kaggle.com/organizations/keras/models)

### For contributors

- [Contributing Guide](CONTRIBUTING.md)
- [Roadmap](ROADMAP.md)
- [Style Guide](STYLE_GUIDE.md)
- [API Design Guide](API_DESIGN_GUIDE.md)
- [Call for Contributions](https://github.com/keras-team/keras-hub/issues?q=is%3Aissue+is%3Aopen+label%3A%22contributions+welcome%22)

## Quickstart

Fine-tune a BERT classifier on IMDb movie reviews:

```python
import os
os.environ["KERAS_BACKEND"] = "jax"  # Or "tensorflow" or "torch"!

import keras_nlp
import tensorflow_datasets as tfds

imdb_train, imdb_test = tfds.load(
    "imdb_reviews",
    split=["train", "test"],
    as_supervised=True,
    batch_size=16,
)

# Load a BERT model.
classifier = keras_nlp.models.Classifier.from_preset(
    "bert_base_en",
    num_classes=2,
    activation="softmax",
)

# Fine-tune on IMDb movie reviews.
classifier.fit(imdb_train, validation_data=imdb_test)
# Predict two new examples.
classifier.predict(["What an amazing movie!", "A total waste of my time."])
```

Try it out [in a colab](https://colab.research.google.com/gist/mattdangerw/e457e42d5ea827110c8d5cb4eb9d9a07/kerasnlp-quickstart.ipynb).
For more in depth guides and examples, visit
[keras.io/keras_nlp](https://keras.io/keras_nlp/).

## Installation

KerasHub is currently in pre-release. Note that pre-release versions may
introduce breaking changes to the API in future versions. For a stable and
supported experience, we recommend installing `keras-nlp` version 0.15.1:

```bash
pip install keras-nlp==0.15.1
```

To try out the latest pre-release version of KerasHub, you can use
our nightly package:

```bash
pip install keras-hub-nightly
```

KerasHub currently requires TensorFlow to be installed for use of the
`tf.data` API for preprocessing. Even when pre-processing with `tf.data`,
training can still happen on any backend.

Read [Getting started with Keras](https://keras.io/getting_started/) for more
information on installing Keras 3 and compatibility with different frameworks.

> [!IMPORTANT]
> We recommend using KerasHub with TensorFlow 2.16 or later, as TF 2.16 packages
> Keras 3 by default.

## Configuring your backend

If you have Keras 3 installed in your environment (see installation above),
you can use KerasHub with any of JAX, TensorFlow and PyTorch. To do so, set the
`KERAS_BACKEND` environment variable. For example:

```shell
export KERAS_BACKEND=jax
```

Or in Colab, with:

```python
import os
os.environ["KERAS_BACKEND"] = "jax"

import keras_hub
```

> [!IMPORTANT]
> Make sure to set the `KERAS_BACKEND` **before** importing any Keras libraries;
> it will be used to set up Keras when it is first imported.

## Compatibility

We follow [Semantic Versioning](https://semver.org/), and plan to
provide backwards compatibility guarantees both for code and saved models built
with our components. While we continue with pre-release `0.y.z` development, we
may break compatibility at any time and APIs should not be considered stable.

## Disclaimer

KerasHub provides access to pre-trained models via the `keras_hub.models` API.
These pre-trained models are provided on an "as is" basis, without warranties
or conditions of any kind. The following underlying models are provided by third
parties, and subject to separate licenses:
BART, BLOOM, DeBERTa, DistilBERT, GPT-2, Llama, Mistral, OPT, RoBERTa, Whisper,
and XLM-RoBERTa.

## Citing KerasHub

If KerasHub helps your research, we appreciate your citations.
Here is the BibTeX entry:

```bibtex
@misc{kerashub2024,
  title={KerasHub},
  author={Watson, Matthew, and  Chollet, Fran\c{c}ois and Sreepathihalli,
  Divyashree, and Saadat, Samaneh and Sampath, Ramesh, and Rasskin, Gabriel and
  and Zhu, Scott and Singh, Varun and Wood, Luke and Tan, Zhenyu and Stenbit,
  Ian and Qian, Chen, and Bischof, Jonathan and others},
  year={2024},
  howpublished={\url{https://github.com/keras-team/keras-hub}},
}
```

## Acknowledgements

Thank you to all of our wonderful contributors!

<a href="https://github.com/keras-team/keras-hub/graphs/contributors">
  <img src="https://contrib.rocks/image?repo=keras-team/keras-hub" />
</a>

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/keras-team/keras-hub",
    "name": "keras-hub",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": "Keras team",
    "author_email": "keras-hub@google.com",
    "download_url": "https://files.pythonhosted.org/packages/ea/9c/f63d574bbbdcac9a29fb2e5241f68e0d60b384755f9928b58a45b7d6067a/keras_hub-0.17.0.tar.gz",
    "platform": null,
    "description": "# KerasHub: Multi-framework Models\n[![](https://github.com/keras-team/keras-hub/workflows/Tests/badge.svg?branch=master)](https://github.com/keras-team/keras-hub/actions?query=workflow%3ATests+branch%3Amaster)\n![Python](https://img.shields.io/badge/python-v3.9.0+-success.svg)\n[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/keras-team/keras-hub/issues)\n\n> [!IMPORTANT]\n> \ud83d\udce2 KerasNLP is becoming KerasHub! \ud83d\udce2 Read\n> [the announcement](https://github.com/keras-team/keras-hub/issues/1831).\n>\n> We have renamed the repo to KerasHub in preparation for the release, but have not yet\n> released the new package. Follow the announcement for news.\n\nKerasHub is a library that supports natural language processing, computer\nvision, audio, and multimodal backbones and task models, working natively with\nTensorFlow, JAX, or PyTorch. KerasHub provides a repository of pre-trained\nmodels and a collection of lower-level building blocks for these tasks. Built\non Keras 3, models can be trained and serialized in any framework and re-used\nin another without costly migrations.\n\nThis library is an extension of the core Keras API; all high-level modules are\nLayers and Models that receive that same level of polish as core Keras.\nIf you are familiar with Keras, congratulations! You already understand most of\nKerasHub.\n\nAll models support JAX, TensorFlow, and PyTorch from a single model\ndefinition and can be fine-tuned on GPUs and TPUs out of the box. Models can\nbe trained on individual accelerators with built-in PEFT techniques, or\nfine-tuned at scale with model and data parallel training. See our\n[Getting Started guide](https://keras.io/guides/keras_nlp/getting_started)\nto start learning our API. Browse our models on\n[Kaggle](https://www.kaggle.com/organizations/keras/models).\nWe welcome contributions.\n\n## Quick Links\n\n### For everyone\n\n- [Home Page](https://keras.io/keras_nlp)\n- [Developer Guides](https://keras.io/guides/keras_nlp)\n- [API Reference](https://keras.io/api/keras_nlp)\n- [Pre-trained Models](https://www.kaggle.com/organizations/keras/models)\n\n### For contributors\n\n- [Contributing Guide](CONTRIBUTING.md)\n- [Roadmap](ROADMAP.md)\n- [Style Guide](STYLE_GUIDE.md)\n- [API Design Guide](API_DESIGN_GUIDE.md)\n- [Call for Contributions](https://github.com/keras-team/keras-hub/issues?q=is%3Aissue+is%3Aopen+label%3A%22contributions+welcome%22)\n\n## Quickstart\n\nFine-tune a BERT classifier on IMDb movie reviews:\n\n```python\nimport os\nos.environ[\"KERAS_BACKEND\"] = \"jax\"  # Or \"tensorflow\" or \"torch\"!\n\nimport keras_nlp\nimport tensorflow_datasets as tfds\n\nimdb_train, imdb_test = tfds.load(\n    \"imdb_reviews\",\n    split=[\"train\", \"test\"],\n    as_supervised=True,\n    batch_size=16,\n)\n\n# Load a BERT model.\nclassifier = keras_nlp.models.Classifier.from_preset(\n    \"bert_base_en\",\n    num_classes=2,\n    activation=\"softmax\",\n)\n\n# Fine-tune on IMDb movie reviews.\nclassifier.fit(imdb_train, validation_data=imdb_test)\n# Predict two new examples.\nclassifier.predict([\"What an amazing movie!\", \"A total waste of my time.\"])\n```\n\nTry it out [in a colab](https://colab.research.google.com/gist/mattdangerw/e457e42d5ea827110c8d5cb4eb9d9a07/kerasnlp-quickstart.ipynb).\nFor more in depth guides and examples, visit\n[keras.io/keras_nlp](https://keras.io/keras_nlp/).\n\n## Installation\n\nKerasHub is currently in pre-release. Note that pre-release versions may\nintroduce breaking changes to the API in future versions. For a stable and\nsupported experience, we recommend installing `keras-nlp` version 0.15.1:\n\n```bash\npip install keras-nlp==0.15.1\n```\n\nTo try out the latest pre-release version of KerasHub, you can use\nour nightly package:\n\n```bash\npip install keras-hub-nightly\n```\n\nKerasHub currently requires TensorFlow to be installed for use of the\n`tf.data` API for preprocessing. Even when pre-processing with `tf.data`,\ntraining can still happen on any backend.\n\nRead [Getting started with Keras](https://keras.io/getting_started/) for more\ninformation on installing Keras 3 and compatibility with different frameworks.\n\n> [!IMPORTANT]\n> We recommend using KerasHub with TensorFlow 2.16 or later, as TF 2.16 packages\n> Keras 3 by default.\n\n## Configuring your backend\n\nIf you have Keras 3 installed in your environment (see installation above),\nyou can use KerasHub with any of JAX, TensorFlow and PyTorch. To do so, set the\n`KERAS_BACKEND` environment variable. For example:\n\n```shell\nexport KERAS_BACKEND=jax\n```\n\nOr in Colab, with:\n\n```python\nimport os\nos.environ[\"KERAS_BACKEND\"] = \"jax\"\n\nimport keras_hub\n```\n\n> [!IMPORTANT]\n> Make sure to set the `KERAS_BACKEND` **before** importing any Keras libraries;\n> it will be used to set up Keras when it is first imported.\n\n## Compatibility\n\nWe follow [Semantic Versioning](https://semver.org/), and plan to\nprovide backwards compatibility guarantees both for code and saved models built\nwith our components. While we continue with pre-release `0.y.z` development, we\nmay break compatibility at any time and APIs should not be considered stable.\n\n## Disclaimer\n\nKerasHub provides access to pre-trained models via the `keras_hub.models` API.\nThese pre-trained models are provided on an \"as is\" basis, without warranties\nor conditions of any kind. The following underlying models are provided by third\nparties, and subject to separate licenses:\nBART, BLOOM, DeBERTa, DistilBERT, GPT-2, Llama, Mistral, OPT, RoBERTa, Whisper,\nand XLM-RoBERTa.\n\n## Citing KerasHub\n\nIf KerasHub helps your research, we appreciate your citations.\nHere is the BibTeX entry:\n\n```bibtex\n@misc{kerashub2024,\n  title={KerasHub},\n  author={Watson, Matthew, and  Chollet, Fran\\c{c}ois and Sreepathihalli,\n  Divyashree, and Saadat, Samaneh and Sampath, Ramesh, and Rasskin, Gabriel and\n  and Zhu, Scott and Singh, Varun and Wood, Luke and Tan, Zhenyu and Stenbit,\n  Ian and Qian, Chen, and Bischof, Jonathan and others},\n  year={2024},\n  howpublished={\\url{https://github.com/keras-team/keras-hub}},\n}\n```\n\n## Acknowledgements\n\nThank you to all of our wonderful contributors!\n\n<a href=\"https://github.com/keras-team/keras-hub/graphs/contributors\">\n  <img src=\"https://contrib.rocks/image?repo=keras-team/keras-hub\" />\n</a>\n",
    "bugtrack_url": null,
    "license": "Apache License 2.0",
    "summary": "Industry-strength Natural Language Processing extensions for Keras.",
    "version": "0.17.0",
    "project_urls": {
        "Homepage": "https://github.com/keras-team/keras-hub"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5b960a30aee9e3e1cf09669b8b076ad61cb89ebc3693acdc824a7d6dd71268f5",
                "md5": "f9d0ae904b994873d1b748f6ff1ff3a4",
                "sha256": "d8316f0685d0934a51687207cbd36895bcf4fd4511d0d681497e6687299126fc"
            },
            "downloads": -1,
            "filename": "keras_hub-0.17.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f9d0ae904b994873d1b748f6ff1ff3a4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 644124,
            "upload_time": "2024-10-22T02:11:16",
            "upload_time_iso_8601": "2024-10-22T02:11:16.158356Z",
            "url": "https://files.pythonhosted.org/packages/5b/96/0a30aee9e3e1cf09669b8b076ad61cb89ebc3693acdc824a7d6dd71268f5/keras_hub-0.17.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ea9cf63d574bbbdcac9a29fb2e5241f68e0d60b384755f9928b58a45b7d6067a",
                "md5": "441f5d801c124460d8907b71e01fd05d",
                "sha256": "35d6ea6f350858fcb75ba34baf7b2412487bbd64056651e0470c4ad45beb6f40"
            },
            "downloads": -1,
            "filename": "keras_hub-0.17.0.tar.gz",
            "has_sig": false,
            "md5_digest": "441f5d801c124460d8907b71e01fd05d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 442335,
            "upload_time": "2024-10-22T02:11:18",
            "upload_time_iso_8601": "2024-10-22T02:11:18.301919Z",
            "url": "https://files.pythonhosted.org/packages/ea/9c/f63d574bbbdcac9a29fb2e5241f68e0d60b384755f9928b58a45b7d6067a/keras_hub-0.17.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-22 02:11:18",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "keras-team",
    "github_project": "keras-hub",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "keras-hub"
}
        
Elapsed time: 0.50055s