keras / opt_125m_en

huggingface.co
Total runs: 6
24-hour runs: 0
7-day runs: -1
30-day runs: 3
Model's Last Updated: March 25 2025
text-generation

Introduction of opt_125m_en

Model Details of opt_125m_en

Model Overview

An OPT decoder network.

This class implements a Transformer-based decoder model as described in "OPT: Open Pre-trained Transformer Language Models" . The default constructor gives a fully customizable, randomly initialized OPT model with any number of layers, heads, and embedding dimensions. To load preset architectures and weights, use the from_preset() constructor.

Disclaimer: Pre-trained models are provided on an "as is" basis, without warranties or conditions of any kind. The underlying model is provided by a third party and subject to a separate license, available here .

Arguments

  • vocabulary_size : int. The size of the token vocabulary.
  • num_layers : int. The number of transformer decoder layers.
  • num_heads : int. The number of attention heads for each transformer. The hidden size must be divisible by the number of attention heads.
  • hidden_dim : int. The hidden size of the transformer decoder layers.
  • intermediate_dim : int. The output dimension of the first Dense layer in a two-layer feedforward network for each transformer decoder layer.
  • dropout : float. Dropout probability for the Transformer decoder.
  • max_sequence_length : int. The maximum sequence length that this decoder can consume. If None , max_sequence_length uses the value from sequence length. This determines the variable shape for positional embeddings.
Example Usage
import keras
import keras_hub
import numpy as np

Use generate() to do text generation.

opt_lm = keras_hub.models.OPTCausalLM.from_preset("opt_125m_en")
opt_lm.generate("I want to say", max_length=30)

# Generate with batched prompts.
opt_lm.generate(["This is a", "Where are you"], max_length=30)

Compile the generate() function with a custom sampler.

opt_lm = keras_hub.models.OPTCausalLM.from_preset("opt_125m_en")
opt_lm.compile(sampler="greedy")
opt_lm.generate("I want to say", max_length=30)

opt_lm.compile(sampler=keras_hub.samplers.BeamSampler(num_beams=2))
opt_lm.generate("I want to say", max_length=30)

Use generate() without preprocessing.

# Prompt the model with `5338, 318` (the token ids for `"Who is"`).
# Use `"padding_mask"` to indicate values that should not be overridden.
prompt = {
    "token_ids": np.array([[5338, 318, 0, 0, 0]] * 2),
    "padding_mask": np.array([[1, 1, 0, 0, 0]] * 2),
}

opt_lm = keras_hub.models.OPTCausalLM.from_preset(
    "opt_125m_en",
    preprocessor=None,
)
opt_lm.generate(prompt)

Call fit() on a single batch.

features = ["The quick brown fox jumped.", "I forgot my homework."]
opt_lm = keras_hub.models.OPTCausalLM.from_preset("opt_125m_en")
opt_lm.fit(x=features, batch_size=2)

Call fit() without preprocessing.

x = {
    "token_ids": np.array([[1, 2, 3, 4, 5]] * 2),
    "padding_mask": np.array([[1, 1, 1, 1, 1]] * 2),
}
y = np.array([[2, 3, 4, 5, 0]] * 2)
sw = np.array([[1, 1, 1, 1, 1]] * 2)

opt_lm = keras_hub.models.OPTCausalLM.from_preset(
    "opt_125m_en",
    preprocessor=None,
)
opt_lm.fit(x=x, y=y, sample_weight=sw, batch_size=2)
Example Usage with Hugging Face URI
import keras
import keras_hub
import numpy as np

Use generate() to do text generation.

opt_lm = keras_hub.models.OPTCausalLM.from_preset("hf://keras/opt_125m_en")
opt_lm.generate("I want to say", max_length=30)

# Generate with batched prompts.
opt_lm.generate(["This is a", "Where are you"], max_length=30)

Compile the generate() function with a custom sampler.

opt_lm = keras_hub.models.OPTCausalLM.from_preset("hf://keras/opt_125m_en")
opt_lm.compile(sampler="greedy")
opt_lm.generate("I want to say", max_length=30)

opt_lm.compile(sampler=keras_hub.samplers.BeamSampler(num_beams=2))
opt_lm.generate("I want to say", max_length=30)

Use generate() without preprocessing.

# Prompt the model with `5338, 318` (the token ids for `"Who is"`).
# Use `"padding_mask"` to indicate values that should not be overridden.
prompt = {
    "token_ids": np.array([[5338, 318, 0, 0, 0]] * 2),
    "padding_mask": np.array([[1, 1, 0, 0, 0]] * 2),
}

opt_lm = keras_hub.models.OPTCausalLM.from_preset(
    "hf://keras/opt_125m_en",
    preprocessor=None,
)
opt_lm.generate(prompt)

Call fit() on a single batch.

features = ["The quick brown fox jumped.", "I forgot my homework."]
opt_lm = keras_hub.models.OPTCausalLM.from_preset("hf://keras/opt_125m_en")
opt_lm.fit(x=features, batch_size=2)

Call fit() without preprocessing.

x = {
    "token_ids": np.array([[1, 2, 3, 4, 5]] * 2),
    "padding_mask": np.array([[1, 1, 1, 1, 1]] * 2),
}
y = np.array([[2, 3, 4, 5, 0]] * 2)
sw = np.array([[1, 1, 1, 1, 1]] * 2)

opt_lm = keras_hub.models.OPTCausalLM.from_preset(
    "hf://keras/opt_125m_en",
    preprocessor=None,
)
opt_lm.fit(x=x, y=y, sample_weight=sw, batch_size=2)

Runs of keras opt_125m_en on huggingface.co

6
Total runs
0
24-hour runs
-1
3-day runs
-1
7-day runs
3
30-day runs

More Information About opt_125m_en huggingface.co Model

More opt_125m_en license Visit here:

https://choosealicense.com/licenses/apache-2.0

opt_125m_en huggingface.co

opt_125m_en huggingface.co is an AI model on huggingface.co that provides opt_125m_en's model effect (), which can be used instantly with this keras opt_125m_en model. huggingface.co supports a free trial of the opt_125m_en model, and also provides paid use of the opt_125m_en. Support call opt_125m_en model through api, including Node.js, Python, http.

opt_125m_en huggingface.co Url

https://huggingface.co/keras/opt_125m_en

keras opt_125m_en online free

opt_125m_en huggingface.co is an online trial and call api platform, which integrates opt_125m_en's modeling effects, including api services, and provides a free online trial of opt_125m_en, you can try opt_125m_en online for free by clicking the link below.

keras opt_125m_en online free url in huggingface.co:

https://huggingface.co/keras/opt_125m_en

opt_125m_en install

opt_125m_en is an open source model from GitHub that offers a free installation service, and any user can find opt_125m_en on GitHub to install. At the same time, huggingface.co provides the effect of opt_125m_en install, users can directly use opt_125m_en installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

opt_125m_en install url in huggingface.co:

https://huggingface.co/keras/opt_125m_en

Url of opt_125m_en

opt_125m_en huggingface.co Url

Provider of opt_125m_en huggingface.co

keras
ORGANIZATIONS

Other API from keras

huggingface.co

Total runs: 22
Run Growth: 19
Growth Rate: 86.36%
Updated:February 27 2026
huggingface.co

Total runs: 18
Run Growth: -130
Growth Rate: -866.67%
Updated:July 17 2026
huggingface.co

Total runs: 13
Run Growth: -28
Growth Rate: -215.38%
Updated:June 17 2025
huggingface.co

Total runs: 13
Run Growth: 6
Growth Rate: 46.15%
Updated:February 27 2026
huggingface.co

Total runs: 13
Run Growth: 10
Growth Rate: 76.92%
Updated:March 25 2025
huggingface.co

Total runs: 13
Run Growth: -23
Growth Rate: -176.92%
Updated:June 17 2025
huggingface.co

Total runs: 12
Run Growth: -130
Growth Rate: -1181.82%
Updated:July 17 2026
huggingface.co

Total runs: 11
Run Growth: 8
Growth Rate: 72.73%
Updated:February 27 2026
huggingface.co

Total runs: 10
Run Growth: 0
Growth Rate: 0.00%
Updated:March 25 2025
huggingface.co

Total runs: 9
Run Growth: 3
Growth Rate: 33.33%
Updated:March 25 2025
huggingface.co

Total runs: 8
Run Growth: 1
Growth Rate: 12.50%
Updated:March 25 2025
huggingface.co

Total runs: 7
Run Growth: -12
Growth Rate: -171.43%
Updated:May 15 2026
huggingface.co

Total runs: 7
Run Growth: -27
Growth Rate: -385.71%
Updated:June 17 2025
huggingface.co

Total runs: 7
Run Growth: 4
Growth Rate: 57.14%
Updated:February 27 2026
huggingface.co

Total runs: 7
Run Growth: 4
Growth Rate: 57.14%
Updated:February 27 2026
huggingface.co

Total runs: 6
Run Growth: 3
Growth Rate: 50.00%
Updated:June 17 2025
huggingface.co

Total runs: 6
Run Growth: 6
Growth Rate: 100.00%
Updated:June 17 2025