optimum-intel-internal-testing / tiny-random-glm4-moe

huggingface.co
Total runs: 3
24-hour runs: 0
7-day runs: 1
30-day runs: -1
Model's Last Updated: February 18 2026

Introduction of tiny-random-glm4-moe

Model Details of tiny-random-glm4-moe

"""Create a tiny random Glm4Moe model for testing optimum-intel export."""

import torch
from transformers import AutoTokenizer
from transformers.models.glm4_moe.modeling_glm4_moe import Glm4MoeForCausalLM, Glm4MoeConfig


def create_tiny_glm4_moe():
    config = Glm4MoeConfig(
        vocab_size=1000,
        hidden_size=64,
        intermediate_size=128,
        num_hidden_layers=2,
        num_attention_heads=4,
        num_key_value_heads=4,
        hidden_act="silu",
        max_position_embeddings=256,
        rms_norm_eps=1e-5,
        n_routed_experts=4,
        n_shared_experts=1,
        num_experts_per_tok=2,
        moe_intermediate_size=32,
        first_k_dense_replace=1,
        n_group=1,
        topk_group=1,
        norm_topk_prob=True,
        routed_scaling_factor=1.8,
        topk_method="noaux_tc",
        rope_theta=10000,
        tie_word_embeddings=False,
    )

    model = Glm4MoeForCausalLM(config)
    model.eval()

    # Verify model works
    input_ids = torch.randint(0, 1000, (1, 10))
    with torch.no_grad():
        outputs = model(input_ids)
    print(f"Model output shape: {outputs.logits.shape}")
    print(f"Num parameters: {sum(p.numel() for p in model.parameters()):,}")

    # Save model
    output_dir = "tiny-random-glm4-moe"
    model.save_pretrained(output_dir)

    # Create and save a simple tokenizer
    from transformers import PreTrainedTokenizerFast
    from tokenizers import Tokenizer, models, pre_tokenizers

    tokenizer_model = models.WordPiece(
        vocab={f"token_{i}": i for i in range(1000)},
        unk_token="token_0",
    )
    base_tokenizer = Tokenizer(tokenizer_model)
    base_tokenizer.pre_tokenizer = pre_tokenizers.Whitespace()

    tokenizer = PreTrainedTokenizerFast(
        tokenizer_object=base_tokenizer,
        unk_token="token_0",
        pad_token="token_0",
        eos_token="token_1",
        bos_token="token_2",
    )
    tokenizer.save_pretrained(output_dir)

    print(f"Model saved to {output_dir}")
    return model, config


if __name__ == "__main__":
    create_tiny_glm4_moe()

Runs of optimum-intel-internal-testing tiny-random-glm4-moe on huggingface.co

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

More Information About tiny-random-glm4-moe huggingface.co Model

More tiny-random-glm4-moe license Visit here:

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

tiny-random-glm4-moe huggingface.co

tiny-random-glm4-moe huggingface.co is an AI model on huggingface.co that provides tiny-random-glm4-moe's model effect (), which can be used instantly with this optimum-intel-internal-testing tiny-random-glm4-moe model. huggingface.co supports a free trial of the tiny-random-glm4-moe model, and also provides paid use of the tiny-random-glm4-moe. Support call tiny-random-glm4-moe model through api, including Node.js, Python, http.

optimum-intel-internal-testing tiny-random-glm4-moe online free

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

optimum-intel-internal-testing tiny-random-glm4-moe online free url in huggingface.co:

https://huggingface.co/optimum-intel-internal-testing/tiny-random-glm4-moe

tiny-random-glm4-moe install

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

tiny-random-glm4-moe install url in huggingface.co:

https://huggingface.co/optimum-intel-internal-testing/tiny-random-glm4-moe

Url of tiny-random-glm4-moe

Provider of tiny-random-glm4-moe huggingface.co

optimum-intel-internal-testing
ORGANIZATIONS

Other API from optimum-intel-internal-testing