Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions keras_nlp/models/electra/electra_backbone.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from keras_nlp.api_export import keras_nlp_export
from keras_nlp.backend import keras
from keras_nlp.layers.modeling.position_embedding import PositionEmbedding
from keras_nlp.layers.modeling.reversible_embedding import ReversibleEmbedding
Expand All @@ -25,7 +24,7 @@ def electra_kernel_initializer(stddev=0.02):
return keras.initializers.TruncatedNormal(stddev=stddev)


@keras_nlp_export("keras_nlp.models.ElectraBackbone")
@keras.saving.register_keras_serializable(package="keras_nlp")
class ElectraBackbone(Backbone):
"""A Electra encoder network.

Expand Down
4 changes: 2 additions & 2 deletions keras_nlp/models/electra/electra_tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from keras_nlp.api_export import keras_nlp_export
from keras_nlp.backend import keras
from keras_nlp.tokenizers import WordPieceTokenizer


@keras_nlp_export("keras_nlp.models.ElectraTokenizer")
@keras.saving.register_keras_serializable(package="keras_nlp")
class ElectraTokenizer(WordPieceTokenizer):
"""A ELECTRA tokenizer using WordPiece subword segmentation.

Expand Down
3 changes: 1 addition & 2 deletions keras_nlp/models/gpt_neo_x/gpt_neo_x_backbone.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from keras_nlp.api_export import keras_nlp_export
from keras_nlp.backend import keras
from keras_nlp.layers.modeling.reversible_embedding import ReversibleEmbedding
from keras_nlp.models.backbone import Backbone
Expand All @@ -24,7 +23,7 @@ def _gpt_neo_x_kernel_initializer(stddev=0.02):
return keras.initializers.RandomNormal(stddev=stddev)


@keras_nlp_export("keras_nlp.models.GPTNeoXBackbone")
@keras.saving.register_keras_serializable(package="keras_nlp")
class GPTNeoXBackbone(Backbone):
"""GPT-NeoX core network with hyperparameters.

Expand Down
3 changes: 1 addition & 2 deletions keras_nlp/models/gpt_neo_x/gpt_neo_x_causal_lm.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from keras_nlp.api_export import keras_nlp_export
from keras_nlp.backend import keras
from keras_nlp.backend import ops
from keras_nlp.models.generative_task import GenerativeTask
Expand All @@ -23,7 +22,7 @@
from keras_nlp.utils.python_utils import classproperty


@keras_nlp_export("keras_nlp.models.GPTNeoXCausalLM")
@keras.saving.register_keras_serializable(package="keras_nlp")
class GPTNeoXCausalLM(GenerativeTask):
"""An end-to-end GPTNeoX model for causal language modeling.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import tensorflow as tf
from absl import logging

from keras_nlp.api_export import keras_nlp_export
from keras_nlp.backend import keras
from keras_nlp.backend import ops
from keras_nlp.models.gpt_neo_x.gpt_neo_x_preprocessor import (
GPTNeoXPreprocessor,
Expand All @@ -26,7 +26,7 @@
from keras_nlp.utils.keras_utils import pack_x_y_sample_weight


@keras_nlp_export("keras_nlp.models.GPTNeoXCausalLMPreprocessor")
@keras.saving.register_keras_serializable(package="keras_nlp")
class GPTNeoXCausalLMPreprocessor(GPTNeoXPreprocessor):
"""GPT-NeoX Causal LM preprocessor.

Expand Down
4 changes: 2 additions & 2 deletions keras_nlp/models/gpt_neo_x/gpt_neo_x_preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from keras_nlp.api_export import keras_nlp_export
from keras_nlp.backend import keras
from keras_nlp.layers.preprocessing.start_end_packer import StartEndPacker
from keras_nlp.models.gpt_neo_x.gpt_neo_x_tokenizer import GPTNeoXTokenizer
from keras_nlp.models.preprocessor import Preprocessor
Expand All @@ -23,7 +23,7 @@
from keras_nlp.utils.python_utils import classproperty


@keras_nlp_export("keras_nlp.models.GPTNeoXPreprocessor")
@keras.saving.register_keras_serializable(package="keras_nlp")
class GPTNeoXPreprocessor(Preprocessor):
"""GPTNeoX preprocessing layer which tokenizes and packs inputs.

Expand Down
4 changes: 2 additions & 2 deletions keras_nlp/models/gpt_neo_x/gpt_neo_x_tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from keras_nlp.api_export import keras_nlp_export
from keras_nlp.backend import keras
from keras_nlp.tokenizers.byte_pair_tokenizer import BytePairTokenizer


@keras_nlp_export("keras_nlp.models.GPTNeoXTokenizer")
@keras.saving.register_keras_serializable(package="keras_nlp")
class GPTNeoXTokenizer(BytePairTokenizer):
"""A GPTNeoX tokenizer using Byte-Pair Encoding subword segmentation.

Expand Down
3 changes: 1 addition & 2 deletions keras_nlp/models/llama/llama_backbone.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from keras_nlp.api_export import keras_nlp_export
from keras_nlp.backend import keras
from keras_nlp.backend import ops
from keras_nlp.layers.modeling.reversible_embedding import ReversibleEmbedding
Expand All @@ -24,7 +23,7 @@ def _llama_kernel_initializer(stddev=0.02):
return keras.initializers.RandomNormal(stddev=stddev)


@keras_nlp_export("keras_nlp.models.LlamaBackbone")
@keras.saving.register_keras_serializable(package="keras_nlp")
class LlamaBackbone(Backbone):
"""
LLaMA core network with hyperparameters.
Expand Down
3 changes: 1 addition & 2 deletions keras_nlp/models/mistral/mistral_backbone.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from keras_nlp.api_export import keras_nlp_export
from keras_nlp.backend import keras
from keras_nlp.backend import ops
from keras_nlp.layers.modeling.reversible_embedding import ReversibleEmbedding
Expand All @@ -28,7 +27,7 @@ def _mistral_kernel_initializer(stddev=0.02):
return keras.initializers.RandomNormal(stddev=stddev)


@keras_nlp_export("keras_nlp.models.MistralBackbone")
@keras.saving.register_keras_serializable(package="keras_nlp")
class MistralBackbone(Backbone):
"""
The Mistral Transformer core architecture with hyperparameters.
Expand Down
4 changes: 2 additions & 2 deletions keras_nlp/models/mistral/mistral_tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from keras_nlp.api_export import keras_nlp_export
from keras_nlp.backend import keras
from keras_nlp.tokenizers.sentence_piece_tokenizer import SentencePieceTokenizer


@keras_nlp_export("keras_nlp.models.MistralTokenizer")
@keras.saving.register_keras_serializable(package="keras_nlp")
class MistralTokenizer(SentencePieceTokenizer):
"""Mistral tokenizer layer based on SentencePiece.

Expand Down
3 changes: 1 addition & 2 deletions keras_nlp/models/t5/t5_backbone.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.
import copy

from keras_nlp.api_export import keras_nlp_export
from keras_nlp.backend import keras
from keras_nlp.layers.modeling.reversible_embedding import ReversibleEmbedding
from keras_nlp.models.backbone import Backbone
Expand All @@ -23,7 +22,7 @@
from keras_nlp.utils.python_utils import classproperty


@keras_nlp_export("keras_nlp.models.T5Backbone")
@keras.saving.register_keras_serializable(package="keras_nlp")
class T5Backbone(Backbone):
"""T5 encoder-decoder backbone model.

Expand Down
4 changes: 2 additions & 2 deletions keras_nlp/models/t5/t5_tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
# limitations under the License.
import copy

from keras_nlp.api_export import keras_nlp_export
from keras_nlp.backend import keras
from keras_nlp.models.t5.t5_presets import backbone_presets
from keras_nlp.tokenizers.sentence_piece_tokenizer import SentencePieceTokenizer
from keras_nlp.utils.python_utils import classproperty


@keras_nlp_export("keras_nlp.models.T5Tokenizer")
@keras.saving.register_keras_serializable(package="keras_nlp")
class T5Tokenizer(SentencePieceTokenizer):
"""T5 tokenizer layer based on SentencePiece.

Expand Down
4 changes: 2 additions & 2 deletions keras_nlp/models/whisper/whisper_audio_feature_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import numpy as np
import tensorflow as tf

from keras_nlp.api_export import keras_nlp_export
from keras_nlp.backend import keras
from keras_nlp.layers.preprocessing.preprocessing_layer import (
PreprocessingLayer,
)
Expand All @@ -26,7 +26,7 @@
from keras_nlp.utils.python_utils import format_docstring


@keras_nlp_export("keras_nlp.models.WhisperAudioFeatureExtractor")
@keras.saving.register_keras_serializable(package="keras_nlp")
class WhisperAudioFeatureExtractor(PreprocessingLayer):
"""
Whisper audio feature extractor layer.
Expand Down
3 changes: 1 addition & 2 deletions keras_nlp/models/whisper/whisper_backbone.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import copy

from keras_nlp.api_export import keras_nlp_export
from keras_nlp.backend import keras
from keras_nlp.backend import ops
from keras_nlp.layers.modeling.position_embedding import PositionEmbedding
Expand All @@ -38,7 +37,7 @@ def call(self, x):
return ops.pad(x, [[0, 0], [1, 1], [0, 0]])


@keras_nlp_export("keras_nlp.models.WhisperBackbone")
@keras.saving.register_keras_serializable(package="keras_nlp")
class WhisperBackbone(Backbone):
"""A Whisper encoder-decoder network for speech.

Expand Down
3 changes: 1 addition & 2 deletions keras_nlp/models/whisper/whisper_preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

from absl import logging

from keras_nlp.api_export import keras_nlp_export
from keras_nlp.backend import keras
from keras_nlp.layers.preprocessing.start_end_packer import StartEndPacker
from keras_nlp.models.preprocessor import Preprocessor
Expand All @@ -32,7 +31,7 @@
from keras_nlp.utils.python_utils import classproperty


@keras_nlp_export("keras_nlp.models.WhisperPreprocessor")
@keras.saving.register_keras_serializable(package="keras_nlp")
class WhisperPreprocessor(Preprocessor):
"""A Whisper preprocessing layer which handles audio and text input.

Expand Down
4 changes: 2 additions & 2 deletions keras_nlp/models/whisper/whisper_tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import copy
import json

from keras_nlp.api_export import keras_nlp_export
from keras_nlp.backend import keras
from keras_nlp.models.whisper.whisper_presets import backbone_presets
from keras_nlp.tokenizers.byte_pair_tokenizer import BytePairTokenizer
from keras_nlp.utils.python_utils import classproperty
Expand All @@ -28,7 +28,7 @@ def _load_dict(dict_or_path):
return dict_or_path


@keras_nlp_export("keras_nlp.models.WhisperTokenizer")
@keras.saving.register_keras_serializable(package="keras_nlp")
class WhisperTokenizer(BytePairTokenizer):
"""Whisper text tokenizer using Byte-Pair Encoding subword segmentation.

Expand Down
3 changes: 1 addition & 2 deletions keras_nlp/models/xlnet/xlnet_backbone.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from keras_nlp.api_export import keras_nlp_export
from keras_nlp.backend import keras
from keras_nlp.models.backbone import Backbone
from keras_nlp.models.xlnet.xlnet_content_and_query_embedding import (
Expand All @@ -23,7 +22,7 @@
from keras_nlp.models.xlnet.xlnet_encoder import XLNetSegmentMatrixLayer


@keras_nlp_export("keras_nlp.models.XLNetBackbone")
@keras.saving.register_keras_serializable(package="keras_nlp")
class XLNetBackbone(Backbone):
"""XLNet encoder network.

Expand Down