Run this model with HF Jobs

Run yujiepan/hymba-tiny-random on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs and TRL to fine-tune https://huggingface.co/yujiepan/hymba-tiny-random. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/yujiepan/hymba-tiny-random on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.

Evaluate on a benchmark

Use HF Jobs to evaluate https://huggingface.co/yujiepan/hymba-tiny-random. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.

Quantize for lower memory use

Use HF Jobs to create a 4-bit version of https://huggingface.co/yujiepan/hymba-tiny-random. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.

This model is for debugging. It is randomly initialized with the config from nvidia/Hymba-1.5B-Instruct but is of smaller size.

Codes:

from huggingface_hub import create_repo, upload_folder
import os

import torch
import transformers
from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, GenerationConfig, pipeline, set_seed

model_id = "nvidia/Hymba-1.5B-Instruct"
repo_id = "yujiepan/hymba-tiny-random"
save_path = f"/tmp/{repo_id}"

config = AutoConfig.from_pretrained(model_id, trust_remote_code=True)
config.conv_dim = {str(i): 32 for i in range(3)}
config.hidden_size = 16
config.intermediate_size = 32
config.num_attention_heads = 2
config.num_key_value_heads = 1
config.v_head_dim = 8
config.num_hidden_layers = 3

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

model = AutoModelForCausalLM.from_config(
    config, torch_dtype=torch.bfloat16, trust_remote_code=True,
)
model.generation_config = GenerationConfig.from_pretrained(
    model_id, trust_remote_code=True)

set_seed(42)
with torch.no_grad():
    for _, p in sorted(model.named_parameters()):
        torch.nn.init.uniform_(p, -0.2, 0.2)

model.save_pretrained(save_path)

prompt = 'Hello!'
messages = [
    {"role": "system", "content": "You are a helpful assistant."}
]
messages.append({"role": "user", "content": prompt})
tokenized_chat = tokenizer.apply_chat_template(
    messages, tokenize=True, add_generation_prompt=True, return_tensors="pt").to('cuda')
outputs = model.cuda().generate(
    tokenized_chat,
    max_new_tokens=16,
    do_sample=False,
    temperature=0.7,
    use_cache=True,
)
input_length = tokenized_chat.shape[1]
response = tokenizer.decode(
    outputs[0][input_length:], skip_special_tokens=True)
print(f"Model response: {response}")

os.system(f"ls -alh {save_path}")
create_repo(repo_id, exist_ok=True)
upload_folder(repo_id=repo_id, folder_path=save_path)
Downloads last month
110
Safetensors
Model size
550k params
Tensor type
F32
·
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Collection including yujiepan/hymba-tiny-random