网页
综合
更新时间 2026-11-14 10:05:26
GptOssCausalLM model
自动蜘蛛
keras.io
正文约 2135 字
An end-to-end GptOss model for causal language modeling.
A causal language model (LM) predicts the next token based on previous tokens. This task setup can be used to train the model unsupervised on plain text input, or to autoregressively generate plain text similar to the data used for training. This task can be used for pre-training or fine-tuning a GptOss model, simply by calling fit().
This model has a generate() method, which generates text based on a prompt. The generation strategy used is controlled by an additional sampler argument on compile(). You can recompile the model with different keras_hub.samplers objects to control the generation. By default, "top_k" sampling will be used.
Instantiate a keras_hub.models.Task from a model preset.
A preset is a directory of configs, weights and other file assets used to save and load a pre-trained model. The preset can be passed as one of:
For any Task subclass, you can run cls.presets.keys() to list all built-in presets available on the class.
This constructor can be called in one of two ways. Either from a task specific base class like keras_hub.models.CausalLM.from_preset(), or from a model class like keras_hub.models.BertTextClassifier.from_preset(). If calling from the a base class, the subclass of the returning object will be inferred from the config in the preset directory.
Generate text given prompt inputs.
This method generates text based on given inputs. The sampling method used for generation can be set via the compile() method.
If inputs are a tf.data.Dataset, outputs will be generated "batch-by-batch" and concatenated. Otherwise, all inputs will be handled as a single batch.
If a preprocessor is attached to the model, inputs will be preprocessed inside the generate() function and should match the structure expected by the preprocessor layer (usually raw strings). If a preprocessor is not attached, inputs should match the structure expected by the backbone. See the example usage above for a demonstration of each.
A keras_hub.models.Backbone model with the core architecture.
A keras_hub.models.Preprocessor layer used to preprocess input.
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。