yujiepan / QwQ-preview-tiny-random

huggingface.co
Total runs: 401
24-hour runs: 0
7-day runs: 255
30-day runs: 250
Model's Last Updated: December 02 2024
text-generation

Introduction of QwQ-preview-tiny-random

Model Details of QwQ-preview-tiny-random

This model is for debugging. It is randomly initialized with the config from Qwen/QwQ-32B-Preview but is of smaller size.

Codes:

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

model_id = 'Qwen/QwQ-32B-Preview'
save_path = '/tmp/yujiepan/QwQ-preview-tiny-random'
repo_id = 'yujiepan/QwQ-preview-tiny-random'

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

config = transformers.AutoConfig.from_pretrained(
    model_id,
    trust_remote_code=True,
)
config._name_or_path = model_id
config.hidden_size = 8
config.intermediate_size = 16
config.num_key_value_heads = 1
config.num_attention_heads = 2
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(
    model_id)
model = model.to(torch.bfloat16)

transformers.set_seed(42)
num_params = 0
with torch.no_grad():
    for name, p in sorted(model.named_parameters()):
        print(name, p.shape)
        torch.nn.init.uniform_(p, -0.5, 0.5)
        num_params += p.numel()
print("Total number of parameters:", num_params)
model.save_pretrained(save_path)

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

os.system(f'ls -alh {save_path}')
create_repo(repo_id, exist_ok=True)
upload_folder(repo_id=repo_id, folder_path=save_path)


def try_example(model, tokenizer):
    prompt = "How many r in strawberry."
    messages = [
        {"role": "system", "content": "You are a helpful and harmless assistant. You should think step-by-step."},
        {"role": "user", "content": prompt}
    ]
    text = tokenizer.apply_chat_template(
        messages,
        tokenize=False,
        add_generation_prompt=True
    )
    model_inputs = tokenizer([text], return_tensors="pt").to(model.device)

    generated_ids = model.generate(
        **model_inputs,
        max_new_tokens=32
    )
    generated_ids = [
        output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
    ]

    response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
    print(response)

try_example(model, tokenizer)

Runs of yujiepan QwQ-preview-tiny-random on huggingface.co

401
Total runs
0
24-hour runs
0
3-day runs
255
7-day runs
250
30-day runs

More Information About QwQ-preview-tiny-random huggingface.co Model

QwQ-preview-tiny-random huggingface.co

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

QwQ-preview-tiny-random huggingface.co Url

https://huggingface.co/yujiepan/QwQ-preview-tiny-random

yujiepan QwQ-preview-tiny-random online free

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

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

https://huggingface.co/yujiepan/QwQ-preview-tiny-random

QwQ-preview-tiny-random install

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

QwQ-preview-tiny-random install url in huggingface.co:

https://huggingface.co/yujiepan/QwQ-preview-tiny-random

Url of QwQ-preview-tiny-random

QwQ-preview-tiny-random huggingface.co Url

Provider of QwQ-preview-tiny-random huggingface.co

yujiepan
ORGANIZATIONS

Other API from yujiepan