Sign in

    majikxu/laya/model does not have a README file

    AgentConfig

    pub struct AgentConfig {
    head_layers : Int
    max_len : Int
    head_max_len : Int
    temperature : Array[Double]
    temperature_by_options : Map[String, Double]
    } derive(
    Debug
    )

    Calibration and prompt budgets, read from rl_agent_config.json.

    AgentConfig::parse

    Parse rl_agent_config.json.

    Attention

    pub(all) enum Attention {
    Global
    Sliding
    } derive(Eq,
    Debug
    )

    Which attention pattern a ModernBERT layer uses.

    EncoderConfig

    pub struct EncoderConfig {
    vocab_size : Int
    hidden_size : Int
    intermediate_size : Int
    num_hidden_layers : Int
    num_attention_heads : Int
    head_dim : Int
    norm_eps : Float
    local_attention : Int
    max_position_embeddings : Int
    layer_types : Array[Attention]
    layer_rope_base : Array[Double]
    } derive(
    Debug
    )

    The encoder half of a Laya checkpoint, read from encoder/config.json.

    Both published checkpoints are ModernBERT-shaped — laya wraps ModernBERT-large and laya-multilingual wraps mmBERT-base — so one config type covers both; they differ only in width, depth and RoPE bases.

    EncoderConfig::parse

    Parse encoder/config.json.

    Model

    type Model

    A loaded Laya checkpoint, ready to run.

    Model::action_outputs

    fn Model::action_outputs(self : Model) -> Int

    Number of action logits the checkpoint's action head emits.

    Model::agent_config

    fn Model::agent_config(self : Model) -> AgentConfig

    The calibration and prompt-budget configuration.

    Model::encoder_config

    fn Model::encoder_config(self : Model) -> EncoderConfig

    The encoder configuration this model was built from.

    Model::forward

    fn Model::forward(self : Model, ids : Array[Int], markers : Array[Int], qtype : Int, trace? : Map[String, Array[Double]]) -> Outputs raise
    LayaError

    Run one question through the encoder, the decision head, the scorer and the action head.

    markers holds the position of each option's [MASK] token in ids, and qtype selects the learned type embedding (0 choice, 1 score, 2 noul).

    Passing trace records each stage's activations under a descriptive key; it exists for the parity tests and costs a copy per stage when supplied.

    Model::load

    fn Model::load(weights_path : String, encoder : EncoderConfig, agent : AgentConfig) -> Model raise
    LayaError

    Load a checkpoint from an already-parsed pair of configs plus its weights.

    Model::on_metal

    fn Model::on_metal(self : Model) -> Bool

    Whether passes currently run on the GPU.

    Model::use_cpu

    fn Model::use_cpu(self : Model) -> Unit

    Fall back to the CPU backend, releasing the GPU buffers.

    Model::use_metal

    Attach a Metal context, moving subsequent passes onto the GPU.

    The weight arena is exposed to the GPU without being copied, so this is cheap: it compiles the kernels and wraps memory that already exists.

    Outputs

    pub struct Outputs {
    logits : Array[Double]
    options : Int
    action : Array[Double]
    } derive(
    Debug
    )

    What one forward pass produces for one question.