Skip to content

Commit

Permalink
Standardize docstring (keras-team#1516)
Browse files Browse the repository at this point in the history
  • Loading branch information
sachinprasadhs authored and abuelnasr0 committed Apr 2, 2024
1 parent 898329f commit 5944635
Show file tree
Hide file tree
Showing 28 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion STYLE_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class PositionEmbedding(keras.layers.Layer):
Args:
sequence_length: The maximum length of the dynamic sequence.
Examples:
Example:
Direct call.
>>> layer = keras_nlp.layers.PositionEmbedding(sequence_length=10)
Expand Down
2 changes: 1 addition & 1 deletion keras_nlp/layers/modeling/alibi_bias.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class AlibiBias(keras.layers.Layer):
multi-head attention layer of the transformer to add alibi bias to
it. With shape `(batch_size, num_heads, query_length, key_length)`.
Examples:
Example:
```python
query_length = 10
key_length = 10
Expand Down
2 changes: 1 addition & 1 deletion keras_nlp/layers/modeling/f_net_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class FNetEncoder(keras.layers.Layer):
**kwargs: other keyword arguments passed to `keras.layers.Layer`,
including `name`, `trainable`, `dtype` etc.
Examples:
Example:
```python
# Create a single FNet encoder layer.
Expand Down
2 changes: 1 addition & 1 deletion keras_nlp/layers/modeling/masked_lm_head.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class MaskedLMHead(keras.layers.Layer):
**kwargs: other keyword arguments passed to `keras.layers.Layer`,
including `name`, `trainable`, `dtype` etc.
Examples:
Example:
```python
batch_size = 16
Expand Down
2 changes: 1 addition & 1 deletion keras_nlp/layers/modeling/position_embedding.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class PositionEmbedding(keras.layers.Layer):
compute the position embedding from. This is useful during cached
decoding, where each position is predicted separately in a loop.
Examples:
Example:
Called directly on input.
>>> layer = keras_nlp.layers.PositionEmbedding(sequence_length=10)
Expand Down
2 changes: 1 addition & 1 deletion keras_nlp/layers/modeling/reversible_embedding.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class ReversibleEmbedding(keras.layers.Embedding):
from `output_dim` to `input_dim`, instead of a normal embedding
call. Default to `False`.
Examples:
Example:
```python
batch_size = 16
vocab_size = 100
Expand Down
2 changes: 1 addition & 1 deletion keras_nlp/layers/modeling/sine_position_encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class SinePositionEncoding(keras.layers.Layer):
compute the encoding from. This is useful during cached decoding,
where each position is predicted separately in a loop.
Examples:
Example:
```python
# create a simple embedding layer with sinusoidal positional encoding
seq_len = 100
Expand Down
2 changes: 1 addition & 1 deletion keras_nlp/layers/modeling/token_and_position_embedding.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class TokenAndPositionEmbedding(keras.layers.Layer):
**kwargs: other keyword arguments passed to `keras.layers.Layer`,
including `name`, `trainable`, `dtype` etc.
Examples:
Example:
```python
inputs = np.ones(shape=(1, 50), dtype="int32")
embedding_layer = keras_nlp.layers.TokenAndPositionEmbedding(
Expand Down
2 changes: 1 addition & 1 deletion keras_nlp/layers/modeling/transformer_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class TransformerDecoder(keras.layers.Layer):
**kwargs: other keyword arguments passed to `keras.layers.Layer`,
including `name`, `trainable`, `dtype` etc.
Examples:
Example:
```python
# Create a single transformer decoder layer.
decoder = keras_nlp.layers.TransformerDecoder(
Expand Down
2 changes: 1 addition & 1 deletion keras_nlp/layers/modeling/transformer_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class TransformerEncoder(keras.layers.Layer):
**kwargs: other keyword arguments passed to `keras.layers.Layer`,
including `name`, `trainable`, `dtype` etc.
Examples:
Example:
```python
# Create a single transformer encoder layer.
Expand Down
2 changes: 1 addition & 1 deletion keras_nlp/models/albert/albert_backbone.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class AlbertBackbone(Backbone):
such as softmax and layer normalization, will always be done at
float32 precision regardless of dtype.
Examples:
Example:
```python
input_data = {
"token_ids": np.ones(shape=(1, 12), dtype="int32"),
Expand Down
2 changes: 1 addition & 1 deletion keras_nlp/models/albert/albert_masked_lm.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class AlbertMaskedLM(Task):
`None`. If `None`, this model will not apply preprocessing, and
inputs should be preprocessed before calling the model.
Example usage:
Examples:
Raw string data.
```python
Expand Down
2 changes: 1 addition & 1 deletion keras_nlp/models/bert/bert_masked_lm.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class BertMaskedLM(Task):
`None`. If `None`, this model will not apply preprocessing, and
inputs should be preprocessed before calling the model.
Example usage:
Examples:
Raw string data.
```python
Expand Down
2 changes: 1 addition & 1 deletion keras_nlp/models/bloom/bloom_backbone.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class BloomBackbone(Backbone):
such as softmax and layer normalization, will always be done at
float32 precision regardless of dtype.
Examples:
Example:
```python
input_data = {
"token_ids": np.ones(shape=(1, 12), dtype="int32"),
Expand Down
2 changes: 1 addition & 1 deletion keras_nlp/models/deberta_v3/deberta_v3_masked_lm.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class DebertaV3MaskedLM(Task):
`None`. If `None`, this model will not apply preprocessing, and
inputs should be preprocessed before calling the model.
Example usage:
Examples:
Raw string data.
```python
Expand Down
2 changes: 1 addition & 1 deletion keras_nlp/models/distil_bert/distil_bert_masked_lm.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class DistilBertMaskedLM(Task):
`None`. If `None`, this model will not apply preprocessing, and
inputs should be preprocessed before calling the model.
Example usage:
Examples:
Raw string data.
```python
Expand Down
2 changes: 1 addition & 1 deletion keras_nlp/models/electra/electra_backbone.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class ElectraBackbone(Backbone):
such as softmax and layer normalization, will always be done at
float32 precision regardless of dtype.
Examples:
Example:
```python
input_data = {
"token_ids": np.ones(shape=(1, 12), dtype="int32"),
Expand Down
2 changes: 1 addition & 1 deletion keras_nlp/models/f_net/f_net_masked_lm.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class FNetMaskedLM(Task):
`None`. If `None`, this model will not apply preprocessing, and
inputs should be preprocessed before calling the model.
Example usage:
Examples:
Raw string data.
```python
Expand Down
4 changes: 2 additions & 2 deletions keras_nlp/models/gemma/gemma_backbone.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class GemmaBackbone(Backbone):
computations, such as softmax and layer normalization will always
be done a float32 precision regardless of dtype.
Example usage:
Example:
```python
input_data = {
"token_ids": np.ones(shape=(1, 12), dtype="int32"),
Expand Down Expand Up @@ -205,7 +205,7 @@ def get_layout_map(
backbone weights, so that you can use it to distribute weights across
the accelerators.
Sample usage:
Example:
```
# Feel free to change the mesh shape to balance data and model parallel
mesh = keras.distribution.DeviceMesh(
Expand Down
2 changes: 1 addition & 1 deletion keras_nlp/models/gemma/gemma_causal_lm.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def score(
<float>[batch_size, num_tokens, vocab_size] in "logits" mode, or
<float>[batch_size, num_tokens] in "loss" mode.
Examples:
Example:
Compute gradients between embeddings and loss scores with TensorFlow:
```python
Expand Down
2 changes: 1 addition & 1 deletion keras_nlp/models/preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def from_preset(
Args:
preset: string. Must be one of "{{preset_names}}".
Examples:
Example:
```python
# Load a preprocessor layer from a preset.
preprocessor = keras_nlp.models.{{preprocessor_name}}.from_preset(
Expand Down
2 changes: 1 addition & 1 deletion keras_nlp/models/xlm_roberta/xlm_roberta_masked_lm.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class XLMRobertaMaskedLM(Task):
`None`. If `None`, this model will not apply preprocessing, and
inputs should be preprocessed before calling the model.
Example usage:
Examples:
Raw string inputs and pretrained backbone.
```python
Expand Down
2 changes: 1 addition & 1 deletion keras_nlp/models/xlnet/xlnet_backbone.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class XLNetBackbone(Backbone):
padding_mask: Mask to avoid performing attention on padding token indices
of shape `[batch_size, sequence_length]`.
Examples:
Example:
```python
import numpy as np
from keras_nlp.models import XLNetBackbone
Expand Down
2 changes: 1 addition & 1 deletion keras_nlp/samplers/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Sampler:
computes the next token based on a probability distribution over all
possible vocab entries.
Examples:
Example:
```python
causal_lm = keras_nlp.models.GPT2CausalLM.from_preset("gpt2_base_en")
Expand Down
4 changes: 2 additions & 2 deletions keras_nlp/tokenizers/byte_pair_tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class BytePairTokenizerCache(tf.Module):
The cache key is string tensor or python strings, and the value is split
tokens joined by whitespace. For example, "dragonfly" => "dragon fly"
Examples:
Example:
```
cache = BytePairTokenizerCache()
cache.insert(["butterfly", "dragonfly"], ["but ter fly", "dragon fly"])
Expand Down Expand Up @@ -665,7 +665,7 @@ def from_preset(
Args:
preset: string. Must be one of "{{preset_names}}".
Examples:
Example:
```python
# Load a preset tokenizer.
tokenizer = {{model_name}}.from_preset("{{example_preset_name}}")
Expand Down
2 changes: 1 addition & 1 deletion keras_nlp/tokenizers/sentence_piece_tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def from_preset(
Args:
preset: string. Must be one of "{{preset_names}}".
Examples:
Example:
```python
# Load a preset tokenizer.
tokenizer = {{model_name}}.from_preset("{{example_preset_name}}")
Expand Down
2 changes: 1 addition & 1 deletion keras_nlp/tokenizers/tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Tokenizer(PreprocessingLayer):
"vocab free" tokenizers, such as a whitespace splitter show below, these
methods do not apply and can be skipped.
Examples:
Example:
```python
class WhitespaceSplitterTokenizer(keras_nlp.tokenizers.Tokenizer):
Expand Down
2 changes: 1 addition & 1 deletion keras_nlp/tokenizers/word_piece_tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ def from_preset(
Args:
preset: string. Must be one of "{{preset_names}}".
Examples:
Example:
```python
# Load a preset tokenizer.
tokenizer = {{model_name}}.from_preset("{{example_preset_name}}")
Expand Down

0 comments on commit 5944635

Please sign in to comment.