yujiepan / qwen2-tiny-random

huggingface.co
Total runs: 5.3K
24-hour runs: 0
7-day runs: 0
30-day runs: 0
Model's Last Updated: June 09 2024
text-generation

Introduction of qwen2-tiny-random

Model Details of qwen2-tiny-random

This model is randomly initialized, using the config from Qwen/Qwen2-72B-Instruct but with smaller size.

Codes:

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

source_model_id = 'Qwen/Qwen2-72B-Instruct'
save_path = '/tmp/yujiepan/qwen2-tiny-random'
repo_id = 'yujiepan/qwen2-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.intermediate_size = 16
config.num_key_value_heads = 2
config.num_attention_heads = 4
config.num_hidden_layers = 2
config.max_window_layers = 1

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 qwen2-tiny-random on huggingface.co

5.3K
Total runs
0
24-hour runs
0
3-day runs
0
7-day runs
0
30-day runs

More Information About qwen2-tiny-random huggingface.co Model

qwen2-tiny-random huggingface.co

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

qwen2-tiny-random huggingface.co Url

https://huggingface.co/yujiepan/qwen2-tiny-random

yujiepan qwen2-tiny-random online free

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

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

https://huggingface.co/yujiepan/qwen2-tiny-random

qwen2-tiny-random install

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

qwen2-tiny-random install url in huggingface.co:

https://huggingface.co/yujiepan/qwen2-tiny-random

Url of qwen2-tiny-random

qwen2-tiny-random huggingface.co Url

Provider of qwen2-tiny-random huggingface.co

yujiepan
ORGANIZATIONS

Other API from yujiepan