yujiepan / glm-4-tiny-random

huggingface.co
Total runs: 396
24-hour runs: 0
7-day runs: -100
30-day runs: -12
Model's Last Updated: April 27 2025
text-generation

Introduction of glm-4-tiny-random

Model Details of glm-4-tiny-random

This model is randomly initialized, using the config from THUDM/glm-4-9b-chat but with smaller size.

Codes:

import transformers
import torch
import os
from huggingface_hub import create_repo, upload_folder
import accelerate

source_model_id = 'THUDM/glm-4-9b-chat'
save_path = '/tmp/yujiepan/glm-4-tiny-random'
repo_id = 'yujiepan/glm-4-tiny-random'

os.system(f'rm -rf {save_path}')

config = transformers.AutoConfig.from_pretrained(
    source_model_id,
    trust_remote_code=True,
)
config._name_or_path = source_model_id
config.hidden_size = 8
config.ffn_hidden_size = 16
config.kv_channels = 2
config.num_attention_heads = 4
config.multi_query_group_num = 2
config.num_hidden_layers = 2
config.num_layers = 2

model = transformers.AutoModelForCausalLM.from_config(
    config,
    trust_remote_code=True,
)
model.generation_config = transformers.GenerationConfig.from_pretrained(source_model_id)
model = model.to(torch.bfloat16)

with torch.no_grad():
    for p in model.parameters():
        torch.nn.init.normal_(p)

model.save_pretrained(save_path)

tokenizer = transformers.AutoTokenizer.from_pretrained(
    source_model_id,
    trust_remote_code=True,
)
tokenizer.save_pretrained(save_path)

output = model.float().generate(torch.tensor([[1, 2, 3]]).long(), max_length=16, do_sample=True)

os.system(f'ls -alh {save_path}')
# os.system(f'rm -rf {save_path}/model.safetensors')
create_repo(repo_id, exist_ok=True)
upload_folder(repo_id=repo_id, folder_path=save_path)

Runs of yujiepan glm-4-tiny-random on huggingface.co

396
Total runs
0
24-hour runs
-9
3-day runs
-100
7-day runs
-12
30-day runs

More Information About glm-4-tiny-random huggingface.co Model

glm-4-tiny-random huggingface.co

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

glm-4-tiny-random huggingface.co Url

https://huggingface.co/yujiepan/glm-4-tiny-random

yujiepan glm-4-tiny-random online free

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

yujiepan glm-4-tiny-random online free url in huggingface.co:

https://huggingface.co/yujiepan/glm-4-tiny-random

glm-4-tiny-random install

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

glm-4-tiny-random install url in huggingface.co:

https://huggingface.co/yujiepan/glm-4-tiny-random

Url of glm-4-tiny-random

glm-4-tiny-random huggingface.co Url

Provider of glm-4-tiny-random huggingface.co

yujiepan
ORGANIZATIONS

Other API from yujiepan