Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
b681ea3
Add VGG16 backbone (#1737)
divyashreepathihalli Aug 8, 2024
33854c6
Add `ResNetBackbone` and `ResNetImageClassifier` (#1765)
james77777778 Aug 12, 2024
dd8df26
Add CSP DarkNet backbone and classifier (#1774)
sachinprasadhs Aug 15, 2024
7381b6d
Add `FeaturePyramidBackbone` and port weights from `timm` for `ResNet…
james77777778 Aug 15, 2024
b76317e
Add DenseNet (#1775)
sachinprasadhs Aug 16, 2024
c822f3a
Add ViTDetBackbone (#1776)
divyashreepathihalli Aug 20, 2024
bc69acd
Add Mix transformer (#1780)
sachinprasadhs Aug 20, 2024
7e180c2
update input_image_shape -> image_shape (#1785)
divyashreepathihalli Aug 21, 2024
12a4ccc
Create __init__.py (#1788)
sachinprasadhs Aug 22, 2024
3e9aaba
Hack package build script to rename to keras-hub (#1793)
mattdangerw Aug 26, 2024
741f98d
Add CLIP and T5XXL for StableDiffusionV3 (#1790)
james77777778 Aug 26, 2024
352e0b7
Add Bounding Box Utils (#1791)
sineeli Aug 28, 2024
1a81234
mobilenet_v3 added in keras-nlp (#1782)
ushareng Aug 28, 2024
894226d
Pkgoogle/efficient net migration (#1778)
pkgoogle Aug 28, 2024
6104520
Add the ResNet_vd backbone (#1766)
gowthamkpr Aug 28, 2024
faffd86
Add `VAEImageDecoder` for StableDiffusionV3 (#1796)
james77777778 Aug 28, 2024
bdf0d7f
Replace `Backbone` with `keras.Model` in `CLIPTextEncoder` and `T5XXL…
james77777778 Aug 28, 2024
85daf81
Add pyramid output for densenet, cspDarknet (#1801)
sachinprasadhs Sep 3, 2024
321b757
Add `MMDiT` for StableDiffusionV3 (#1806)
james77777778 Sep 4, 2024
dfb7123
Add remaining bbox utils (#1804)
sineeli Sep 4, 2024
753047d
Fix timm conversion for rersnet (#1814)
sachinprasadhs Sep 5, 2024
e9d3f66
Add anchor generator
sineeli Sep 13, 2024
c586321
Add VGG16 backbone (#1737)
divyashreepathihalli Aug 8, 2024
2857d6f
Add `ResNetBackbone` and `ResNetImageClassifier` (#1765)
james77777778 Aug 12, 2024
36ce00e
Add `FeaturePyramidBackbone` and port weights from `timm` for `ResNet…
james77777778 Aug 15, 2024
2731db5
Add Mix transformer (#1780)
sachinprasadhs Aug 20, 2024
50c2838
Pkgoogle/efficient net migration (#1778)
pkgoogle Aug 28, 2024
0f1328c
Add anchor generator
sineeli Sep 13, 2024
d84e340
Merge branch 'sineeli/add-anchor-generator' of https://github.com/sin…
sineeli Sep 16, 2024
f030945
- Resolve confilict
sineeli Sep 16, 2024
d2c0b3c
Add docstring and nit
sineeli Sep 16, 2024
6bef473
nit
sineeli Sep 16, 2024
60c70cf
Add box_matcher and non_max_supression
sineeli Sep 16, 2024
8ba1f87
nit
sineeli Sep 16, 2024
ed732a1
Fix post_attention_norm name. (#1834)
SamanehSaadat Sep 16, 2024
32678b2
remove backend switching in non max supression and nit
sineeli Sep 16, 2024
91a057e
Add VGG16 backbone (#1737)
divyashreepathihalli Aug 8, 2024
d180498
Add `ResNetBackbone` and `ResNetImageClassifier` (#1765)
james77777778 Aug 12, 2024
e8bef25
Add CSP DarkNet backbone and classifier (#1774)
sachinprasadhs Aug 15, 2024
2861676
Add `FeaturePyramidBackbone` and port weights from `timm` for `ResNet…
james77777778 Aug 15, 2024
daf8a1f
Add DenseNet (#1775)
sachinprasadhs Aug 16, 2024
cbb4a64
Add ViTDetBackbone (#1776)
divyashreepathihalli Aug 20, 2024
4088820
Add Mix transformer (#1780)
sachinprasadhs Aug 20, 2024
a1b38ef
update input_image_shape -> image_shape (#1785)
divyashreepathihalli Aug 21, 2024
166d58c
Create __init__.py (#1788)
sachinprasadhs Aug 22, 2024
e4b133d
Hack package build script to rename to keras-hub (#1793)
mattdangerw Aug 26, 2024
0cb627b
Add CLIP and T5XXL for StableDiffusionV3 (#1790)
james77777778 Aug 26, 2024
f13454c
Add Bounding Box Utils (#1791)
sineeli Aug 28, 2024
0c49d73
mobilenet_v3 added in keras-nlp (#1782)
ushareng Aug 28, 2024
bf199ac
Pkgoogle/efficient net migration (#1778)
pkgoogle Aug 28, 2024
5dab50a
Add the ResNet_vd backbone (#1766)
gowthamkpr Aug 28, 2024
c4627d1
Add `VAEImageDecoder` for StableDiffusionV3 (#1796)
james77777778 Aug 28, 2024
b9bc61e
Replace `Backbone` with `keras.Model` in `CLIPTextEncoder` and `T5XXL…
james77777778 Aug 28, 2024
8606edf
Add pyramid output for densenet, cspDarknet (#1801)
sachinprasadhs Sep 3, 2024
72cce7a
Add `MMDiT` for StableDiffusionV3 (#1806)
james77777778 Sep 4, 2024
23bf05a
Add remaining bbox utils (#1804)
sineeli Sep 4, 2024
31a6785
Fix timm conversion for rersnet (#1814)
sachinprasadhs Sep 5, 2024
5434704
Finish up resnet (#1822)
mattdangerw Sep 17, 2024
c61dad3
Update README.md (#1837)
mattdangerw Sep 17, 2024
29fe129
Fix saved classifier models from before 0.14 (#1839)
mattdangerw Sep 18, 2024
5d2e5f4
Fix device scope issues (#1841)
mattdangerw Sep 18, 2024
fb3dc3b
Preprocessing decorator fixes (#1843)
mattdangerw Sep 19, 2024
0e1444f
Keras hub rename (#1840)
mattdangerw Sep 19, 2024
7eeecbe
Add VGG16 backbone (#1737)
divyashreepathihalli Aug 8, 2024
adf6dc7
Update README.md (#1846)
mattdangerw Sep 19, 2024
1c9e6fb
Add `ResNetBackbone` and `ResNetImageClassifier` (#1765)
james77777778 Aug 12, 2024
3164585
Add `FeaturePyramidBackbone` and port weights from `timm` for `ResNet…
james77777778 Aug 15, 2024
d6a05fc
Add Mix transformer (#1780)
sachinprasadhs Aug 20, 2024
4071e8e
Pkgoogle/efficient net migration (#1778)
pkgoogle Aug 28, 2024
783f937
Add anchor generator
sineeli Sep 13, 2024
9d58a6e
Add VGG16 backbone (#1737)
divyashreepathihalli Aug 8, 2024
cc970ea
Add `ResNetBackbone` and `ResNetImageClassifier` (#1765)
james77777778 Aug 12, 2024
33afce5
Add `FeaturePyramidBackbone` and port weights from `timm` for `ResNet…
james77777778 Aug 15, 2024
34fbc1e
Add Mix transformer (#1780)
sachinprasadhs Aug 20, 2024
21f20f7
Pkgoogle/efficient net migration (#1778)
pkgoogle Aug 28, 2024
e24cd44
- Resolve confilict
sineeli Sep 16, 2024
8e0348f
Add docstring and nit
sineeli Sep 16, 2024
b4d6d17
nit
sineeli Sep 16, 2024
ecbe6d9
Add box_matcher and non_max_supression
sineeli Sep 16, 2024
acbd10a
nit
sineeli Sep 16, 2024
8719592
remove backend switching in non max supression and nit
sineeli Sep 16, 2024
a1ab96e
Merge branch 'sineeli/add-anchor-generator' of https://github.com/sin…
sineeli Sep 19, 2024
2b1b999
Merge branch 'keras-team:master' into sineeli/add-anchor-generator
sineeli Sep 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
pip install keras-nightly --progress-bar off
- name: Test with pytest
run: |
pytest keras_nlp/
pytest keras_hub/
- name: Run integration tests
run: |
python pip_build.py --install
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ __pycache__/
*.swp
*.swo

keras_nlp.egg-info/
keras_hub.egg-info/
dist/

.coverage
Expand Down
8 changes: 4 additions & 4 deletions .kokoro/github/ubuntu/gpu/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ pip install huggingface_hub
# Run Extra Large Tests for Continuous builds
if [ "${RUN_XLARGE:-0}" == "1" ]
then
pytest keras_nlp --check_gpu --run_large --run_extra_large \
--cov=keras-nlp
pytest keras_hub --check_gpu --run_large --run_extra_large \
--cov=keras-hub
else
pytest keras_nlp --check_gpu --run_large \
--cov=keras-nlp
pytest keras_hub --check_gpu --run_large \
--cov=keras-hub
fi
12 changes: 6 additions & 6 deletions API_DESIGN_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Before reading this document, please read the
[Keras API design guidelines](https://github.com/keras-team/governance/blob/master/keras_api_design_guidelines.md).

Below are some design considerations specific to KerasNLP.
Below are some design considerations specific to KerasHub.

## Philosophy

Expand All @@ -18,16 +18,16 @@ Below are some design considerations specific to KerasNLP.
arbitrarily advanced use cases should be possible. There should always be a
"we need to go deeper" path available to our most expert users.

- **Grow as a platform and as a community.** KerasNLP development should be
- **Grow as a platform and as a community.** KerasHub development should be
driven by the community, with feature and release planning happening in
the open on GitHub.

## Avoid new dependencies

The core dependencies of KerasNLP are Keras, NumPy, TensorFlow, and
The core dependencies of KerasHub are Keras, NumPy, TensorFlow, and
[Tensorflow Text](https://www.tensorflow.org/text).

We strive to keep KerasNLP as self-contained as possible, and avoid adding
We strive to keep KerasHub as self-contained as possible, and avoid adding
dependencies to projects (for example NLTK or spaCy) for text preprocessing.

In rare cases, particularly with tokenizers and metrics, we may need to add
Expand Down Expand Up @@ -65,7 +65,7 @@ calling a layer, metric or loss with `@tf.function` without running into issues.
[tf.text](https://www.tensorflow.org/text/api_docs/python/text) provides a large
surface on TensorFlow operations that manipulate strings. If an low-level (c++)
operation we need is missing, we should add it in collaboration with core
TensorFlow or TensorFlow Text. KerasNLP is a python-only library.
TensorFlow or TensorFlow Text. KerasHub is a python-only library.

We should also strive to keep computation XLA compilable wherever possible (e.g.
`tf.function(jit_compile=True)`). For trainable modeling components this is
Expand All @@ -84,7 +84,7 @@ both batched and unbatched data as input to preprocessing layers.

## Prioritize multi-lingual support

We strive to keep KerasNLP a friendly and useful library for speakers of all
We strive to keep KerasHub a friendly and useful library for speakers of all
languages. In general, prefer designing workflows that are language agnostic,
and do not involve logic (e.g. stemming) that need to be rewritten
per-language.
Expand Down
38 changes: 19 additions & 19 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Contribution guide

KerasNLP is an actively growing project and community! We would love for you
to get involved. Below are instructions for how to plug into KerasNLP
KerasHub is an actively growing project and community! We would love for you
to get involved. Below are instructions for how to plug into KerasHub
development.

## Background reading
Expand Down Expand Up @@ -83,21 +83,21 @@ Once the pull request is approved, a team member will take care of merging.

Python 3.9 or later is required.

Setting up your KerasNLP development environment requires you to fork the
KerasNLP repository and clone it locally. With the
Setting up your KerasHub development environment requires you to fork the
KerasHub repository and clone it locally. With the
[GitHub CLI](https://github.com/cli/cli) installed, you can do this as follows:

```shell
gh repo fork keras-team/keras-nlp --clone --remote
cd keras-nlp
cd keras-hub
```

Next we must setup a python environment with the correct dependencies. We
recommend using `conda` to set up a base environment, and `pip` to install
python packages from PyPI. The exact method will depend on your OS.

**Note**: Be careful not to use mix pre-packaged tensorflow and jax libraries in
`conda` with PyPI packages from `pip`. We recommend pulling *all* KerasNLP
`conda` with PyPI packages from `pip`. We recommend pulling *all* KerasHub
dependencies via `pip` as described below.

### Linux (recommended)
Expand All @@ -108,29 +108,29 @@ want accelerator support. The easiest way to get GPU support across all of our
backends is to set up a few different python environements and pull in all cuda
dependencies via `pip`.

The shell snippet below will install four conda environments: `keras-nlp-cpu`,
`keras-nlp-jax`, `keras-nlp-torch`, and `keras-nlp-tensorflow`. The cpu
The shell snippet below will install four conda environments: `keras-hub-cpu`,
`keras-hub-jax`, `keras-hub-torch`, and `keras-hub-tensorflow`. The cpu
environement supports all backends without cuda, and each backend environement
has cuda support.

```shell
conda create -y -n keras-nlp-cpu python=3.10
conda activate keras-nlp-cpu
conda create -y -n keras-hub-cpu python=3.10
conda activate keras-hub-cpu
pip install -r requirements.txt # install deps
pip install -e . # install keras-nlp
pip install -e . # install keras-hub

for backend in "jax" "torch" "tensorflow"; do
conda create -y -n keras-nlp-${backend} python=3.10
conda activate keras-nlp-${backend}
conda create -y -n keras-hub-${backend} python=3.10
conda activate keras-hub-${backend}
pip install -r requirements-${backend}-cuda.txt # install deps
pip install -e . # install keras-nlp
pip install -e . # install keras-hub
done
```

To activate the jax environment and set keras to use jax, run:

```shell
conda activate keras-nlp-jax && export KERAS_BACKEND=jax
conda activate keras-hub-jax && export KERAS_BACKEND=jax
```

### MacOS
Expand Down Expand Up @@ -160,16 +160,16 @@ repository.

## Update Public API

Run API generation script when creating PRs that update `keras_nlp_export`
public APIs. Add the files changed in `keras_nlp/api` to the same PR.
Run API generation script when creating PRs that update `keras_hub_export`
public APIs. Add the files changed in `keras_hub/api` to the same PR.

```
./shell/api_gen.sh
```

## Testing changes

KerasNLP is tested using [PyTest](https://docs.pytest.org/en/6.2.x/).
KerasHub is tested using [PyTest](https://docs.pytest.org/en/6.2.x/).

### Run a test file

Expand All @@ -184,7 +184,7 @@ can use the following command to run all the tests in `import_test.py`
whose names contain `import`:

```shell
pytest keras_nlp/keras_nlp/integration_tests/import_test.py -k="import"
pytest keras_hub/integration_tests/import_test.py -k="import"
```

### Run the full test suite
Expand Down
50 changes: 25 additions & 25 deletions CONTRIBUTING_MODELS.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Model Contribution Guide

KerasNLP has a plethora of pre-trained large language models
KerasHub has a plethora of pre-trained large language models
ranging from BERT to OPT. We are always looking for more models and are always
open to contributions!

In this guide, we will walk you through the steps one needs to take in order to
contribute a new pre-trained model to KerasNLP. For illustration purposes, let's
contribute a new pre-trained model to KerasHub. For illustration purposes, let's
assume that you want to contribute the DistilBERT model. Before we dive in, we encourage you to go through
[our getting started guide](https://keras.io/guides/keras_nlp/getting_started/)
for an introduction to the library, and our
Expand All @@ -22,29 +22,29 @@ Keep this checklist handy!

### Step 2: PR #1 - Add XXBackbone

- [ ] An `xx/xx_backbone.py` file which has the model graph \[[Example](https://github.com/keras-team/keras-nlp/blob/master/keras_nlp/models/distil_bert/distil_bert_backbone.py)\].
- [ ] An `xx/xx_backbone_test.py` file which has unit tests for the backbone \[[Example](https://github.com/keras-team/keras-nlp/blob/master/keras_nlp/models/distil_bert/distil_bert_backbone_test.py)\].
- [ ] An `xx/xx_backbone.py` file which has the model graph \[[Example](https://github.com/keras-team/keras-nlp/blob/master/keras_hub/src/models/distil_bert/distil_bert_backbone.py)\].
- [ ] An `xx/xx_backbone_test.py` file which has unit tests for the backbone \[[Example](https://github.com/keras-team/keras-nlp/blob/master/keras_hub/src/models/distil_bert/distil_bert_backbone_test.py)\].
- [ ] A Colab notebook link in the PR description which matches the outputs of the implemented backbone model with the original source \[[Example](https://colab.research.google.com/drive/1SeZWJorKWmwWJax8ORSdxKrxE25BfhHa?usp=sharing)\].

### Step 3: PR #2 - Add XXTokenizer

- [ ] An `xx/xx_tokenizer.py` file which has the tokenizer for the model \[[Example](https://github.com/keras-team/keras-nlp/blob/master/keras_nlp/models/distil_bert/distil_bert_tokenizer.py)\].
- [ ] An `xx/xx_tokenizer_test.py` file which has unit tests for the model tokenizer \[[Example](https://github.com/keras-team/keras-nlp/blob/master/keras_nlp/models/distil_bert/distil_bert_tokenizer_test.py)\].
- [ ] An `xx/xx_tokenizer.py` file which has the tokenizer for the model \[[Example](https://github.com/keras-team/keras-nlp/blob/master/keras_hub/src/models/distil_bert/distil_bert_tokenizer.py)\].
- [ ] An `xx/xx_tokenizer_test.py` file which has unit tests for the model tokenizer \[[Example](https://github.com/keras-team/keras-nlp/blob/master/keras_hub/src/models/distil_bert/distil_bert_tokenizer_test.py)\].
- [ ] A Colab notebook link in the PR description, demonstrating that the output of the tokenizer matches the original tokenizer \[[Example](https://colab.research.google.com/drive/1MH_rpuFB1Nz_NkKIAvVtVae2HFLjXZDA?usp=sharing)].

### Step 4: PR #3 - Add XX Presets

- [ ] An `xx/xx_presets.py` file with links to weights uploaded to a personal GCP bucket/Google Drive \[[Example](https://github.com/keras-team/keras-nlp/blob/master/keras_nlp/models/distil_bert/distil_bert_presets.py)\].
- [ ] An `xx/xx_presets.py` file with links to weights uploaded to a personal GCP bucket/Google Drive \[[Example](https://github.com/keras-team/keras-nlp/blob/master/keras_hub/src/models/distil_bert/distil_bert_presets.py)\].
- [ ] A `tools/checkpoint_conversion/convert_xx_checkpoints.py` which is reusable script for converting checkpoints \[[Example](https://github.com/keras-team/keras-nlp/blob/master/tools/checkpoint_conversion/convert_distilbert_checkpoints.py)\].
- [ ] A Colab notebook link in the PR description, showing an end-to-end task such as text classification, etc. The task model can be built using the backbone model, with the task head on top \[[Example](https://gist.github.com/mattdangerw/bf0ca07fb66b6738150c8b56ee5bab4e)\].

### Step 5: PR #4 and Beyond - Add XX Tasks and Preprocessors

This PR is optional.

- [ ] An `xx/xx_<task>.py` file for adding a task model like classifier, masked LM, etc. \[[Example](https://github.com/keras-team/keras-nlp/blob/master/keras_nlp/models/distil_bert/distil_bert_classifier.py)\]
- [ ] An `xx/xx_<task>_preprocessor.py` file which has the preprocessor and can be used to get inputs suitable for the task model \[[Example](https://github.com/keras-team/keras-nlp/blob/master/keras_nlp/models/distil_bert/distil_bert_preprocessor.py)\].
- [ ] `xx/xx_<task>_test.py` file and `xx/xx_<task>_preprocessor_test.py` files which have unit tests for the above two modules \[[Example 1](https://github.com/keras-team/keras-nlp/blob/master/keras_nlp/models/distil_bert/distil_bert_classifier_test.py) and [Example 2](https://github.com/keras-team/keras-nlp/blob/master/keras_nlp/models/distil_bert/distil_bert_preprocessor_test.py)\].
- [ ] An `xx/xx_<task>.py` file for adding a task model like classifier, masked LM, etc. \[[Example](https://github.com/keras-team/keras-nlp/blob/master/keras_hub/src/models/distil_bert/distil_bert_classifier.py)\]
- [ ] An `xx/xx_<task>_preprocessor.py` file which has the preprocessor and can be used to get inputs suitable for the task model \[[Example](https://github.com/keras-team/keras-nlp/blob/master/keras_hub/src/models/distil_bert/distil_bert_preprocessor.py)\].
- [ ] `xx/xx_<task>_test.py` file and `xx/xx_<task>_preprocessor_test.py` files which have unit tests for the above two modules \[[Example 1](https://github.com/keras-team/keras-nlp/blob/master/keras_hub/src/models/distil_bert/distil_bert_classifier_test.py) and [Example 2](https://github.com/keras-team/keras-nlp/blob/master/keras_hub/src/models/distil_bert/distil_bert_preprocessor_test.py)\].
- [ ] A Colab notebook link in the PR description, demonstrating that the output of the preprocessor matches the output of the original preprocessor \[[Example](https://colab.research.google.com/drive/1GFFC7Y1I_2PtYlWDToqKvzYhHWv1b3nC?usp=sharing)].

## Detailed Instructions
Expand Down Expand Up @@ -81,7 +81,7 @@ around by a class to implement our models.

A model is typically split into three/four sections. We would recommend you to
compare this side-by-side with the
[`keras_nlp.layers.DistilBertBackbone` source code](https://github.com/keras-team/keras-nlp/blob/master/keras_nlp/models/distil_bert/distil_bert_backbone.py)!
[`keras_hub.layers.DistilBertBackbone` source code](https://github.com/keras-team/keras-nlp/blob/master/keras_hub/src/models/distil_bert/distil_bert_backbone.py)!

**Inputs to the model**

Expand All @@ -92,32 +92,32 @@ Generally, the standard inputs to any text model are:
**Embedding layer(s)**

Standard layers used: `keras.layers.Embedding`,
`keras_nlp.layers.PositionEmbedding`, `keras_nlp.layers.TokenAndPositionEmbedding`.
`keras_hub.layers.PositionEmbedding`, `keras_hub.layers.TokenAndPositionEmbedding`.

**Encoder layers**

Standard layers used: `keras_nlp.layers.TransformerEncoder`, `keras_nlp.layers.FNetEncoder`.
Standard layers used: `keras_hub.layers.TransformerEncoder`, `keras_hub.layers.FNetEncoder`.

**Decoder layers (possibly)**

Standard layers used: `keras_nlp.layers.TransformerDecoder`.
Standard layers used: `keras_hub.layers.TransformerDecoder`.

**Other layers which might be used**

`keras.layers.LayerNorm`, `keras.layers.Dropout`, `keras.layers.Conv1D`, etc.

<br/>

The standard layers provided in Keras and KerasNLP are generally enough for
The standard layers provided in Keras and KerasHub are generally enough for
most of the usecases and it is recommended to do a thorough search
[here](https://keras.io/api/layers/) and [here](https://keras.io/api/keras_nlp/layers/).
However, sometimes, models have small tweaks/paradigm changes in their architecture.
This is when things might slightly get complicated.

If the model introduces a paradigm shift, such as using relative attention instead
of vanilla attention, the contributor will have to implement complete custom layers. A case
in point is `keras_nlp.models.DebertaV3Backbone` where we had to [implement layers
from scratch](https://github.com/keras-team/keras-nlp/tree/master/keras_nlp/models/deberta_v3).
in point is `keras_hub.models.DebertaV3Backbone` where we had to [implement layers
from scratch](https://github.com/keras-team/keras-nlp/tree/master/keras_hub/models/deberta_v3).

On the other hand, if the model has a small tweak, something simpler can be done.
For instance, in the Whisper model, the self-attention and cross-attention mechanism
Expand Down Expand Up @@ -154,22 +154,22 @@ and loaded correctly, etc.
#### Tokenizer

Most text models nowadays use subword tokenizers such as WordPiece, SentencePiece
and BPE Tokenizer. Since KerasNLP has implementations of most of the popular
and BPE Tokenizer. Since KerasHub has implementations of most of the popular
subword tokenizers, the model tokenizer layer typically inherits from a base
tokenizer class.

For example, DistilBERT uses the WordPiece tokenizer. So, we can introduce a new
class, `DistilBertTokenizer`, which inherits from `keras_nlp.tokenizers.WordPieceTokenizer`.
class, `DistilBertTokenizer`, which inherits from `keras_hub.tokenizers.WordPieceTokenizer`.
All the underlying actual tokenization will be taken care of by the superclass.

The important thing here is adding "special tokens". Most models have
special tokens such as beginning-of-sequence token, end-of-sequence token,
mask token, pad token, etc. These have to be
[added as member attributes](https://github.com/keras-team/keras-nlp/blob/master/keras_nlp/models/distil_bert/distil_bert_tokenizer.py#L91-L105)
[added as member attributes](https://github.com/keras-team/keras-nlp/blob/master/keras_hub/src/models/distil_bert/distil_bert_tokenizer.py#L91-L105)
to the tokenizer class. These member attributes are then accessed by the
preprocessor layers.

For a full list of the tokenizers KerasNLP offers, please visit
For a full list of the tokenizers KerasHub offers, please visit
[this link](https://keras.io/api/keras_nlp/tokenizers/) and make use of the
tokenizer your model uses!

Expand All @@ -193,7 +193,7 @@ files. These files will then be uploaded to GCP by us!
After wrapping up the preset configuration file, you need to
add the `from_preset` function to all three classes, i.e., `DistilBertBackbone`,
and `DistilBertTokenizer`. Here is an
[example](https://github.com/keras-team/keras-nlp/blob/master/keras_nlp/models/distil_bert/distil_bert_backbone.py#L187-L189).
[example](https://github.com/keras-team/keras-nlp/blob/master/keras_hub/src/models/distil_bert/distil_bert_backbone.py#L187-L189).

The testing for presets is divided into two: "large" and "extra large".
For "large" tests, we pick the smallest preset (in terms of number of parameters)
Expand Down Expand Up @@ -228,12 +228,12 @@ and return the dictionary in the form expected by the model.

The preprocessor class might have a few intricacies depending on the model. For example,
the DeBERTaV3 tokenizer does not have the `[MASK]` in the provided sentencepiece
proto file, and we had to make some modifications [here](https://github.com/keras-team/keras-nlp/blob/master/keras_nlp/models/deberta_v3/deberta_v3_preprocessor.py). Secondly, we have
proto file, and we had to make some modifications [here](https://github.com/keras-team/keras-nlp/blob/master/keras_hub/models/deberta_v3/deberta_v3_preprocessor.py). Secondly, we have
a separate preprocessor class for every task. This is because different tasks
might require different input formats. For instance, we have a [separate preprocessor](https://github.com/keras-team/keras-nlp/blob/master/keras_nlp/models/distil_bert/distil_bert_masked_lm_preprocessor.py)
might require different input formats. For instance, we have a [separate preprocessor](https://github.com/keras-team/keras-nlp/blob/master/keras_hub/src/models/distil_bert/distil_bert_masked_lm_preprocessor.py)
for masked language modeling (MLM) for DistilBERT.

## Conclusion

Once all three PRs (and optionally, the fourth PR) have been merged, you have
successfully contributed a model to KerasNLP. Congratulations! 🔥
successfully contributed a model to KerasHub. Congratulations! 🔥
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2024, KerasNLP authors. All rights reserved.
Copyright 2024, KerasHub authors. All rights reserved.

Apache License
Version 2.0, January 2004
Expand Down Expand Up @@ -188,7 +188,7 @@ Copyright 2024, KerasNLP authors. All rights reserved.
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2024, KerasNLP authors.
Copyright 2024, KerasHub authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Loading