yujiepan / qvq-preview-tiny-random

huggingface.co
Total runs: 258
24-hour runs: 0
7-day runs: 256
30-day runs: 250
Model's Last Updated: December 30 2024
image-text-to-text

Introduction of qvq-preview-tiny-random

Model Details of qvq-preview-tiny-random

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

Codes:

import os
from typing import Dict

import requests
import torch
import transformers
from PIL import Image
from torchvision import io
from transformers import (AutoConfig, AutoModelForCausalLM, AutoProcessor,
                          AutoTokenizer, GenerationConfig,
                          enable_full_determinism, pipeline, set_seed)
from transformers.models.qwen2_vl import Qwen2VLForConditionalGeneration

model_id = "Qwen/QVQ-72B-Preview"
repo_id = "yujiepan/qvq-preview-tiny-random"
save_path = f"/tmp/{repo_id}"

config = AutoConfig.from_pretrained(model_id, trust_remote_code=True)
config.hidden_size = 16
config.intermediate_size = 32
config.num_attention_heads = 2
config.num_hidden_layers = 2
config.num_key_value_heads = 1
config.vision_config.embed_dim = 16
config.vision_config.num_heads = 2
config.vision_config.hidden_size = 16
config.vision_config.depth = 2
config.rope_scaling['mrope_section'] = [1, 1, 2]  # sum needs to be 4 here

enable_full_determinism(42)
model = Qwen2VLForConditionalGeneration(config=config)
model = model.to(torch.bfloat16).cuda().eval()
model.generation_config = GenerationConfig.from_pretrained(
    model_id, trust_remote_code=True,
)

processor = AutoProcessor.from_pretrained(model_id)
model.save_pretrained(save_path)
processor.save_pretrained(save_path)
os.system(f"ls -alh {save_path}")


def try_inference(model_id):
    torch.use_deterministic_algorithms(False)
    from qwen_vl_utils import process_vision_info
    from transformers import (AutoProcessor, AutoTokenizer,
                              Qwen2VLForConditionalGeneration)

    model = Qwen2VLForConditionalGeneration.from_pretrained(
        model_id, device_map="cuda"
    )
    processor = AutoProcessor.from_pretrained(model_id)
    messages = [
        {
            "role": "system",
            "content": [
                {"type": "text", "text": "You are a helpful and harmless assistant. You are Qwen developed by Alibaba. You should think step-by-step."}
            ],
        },
        {
            "role": "user",
            "content": [
                {
                    "type": "image",
                    "image": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/QVQ/demo.png",
                },
                {"type": "text", "text": "What value should be filled in the blank space?"},
            ],
        }
    ]
    text = processor.apply_chat_template(
        messages, tokenize=False, add_generation_prompt=True
    )
    image_inputs, video_inputs = process_vision_info(messages)
    inputs = processor(
        text=[text],
        images=image_inputs,
        videos=video_inputs,
        padding=True,
        return_tensors="pt",
    )
    inputs = inputs.to("cuda")
    generated_ids = model.generate(**inputs, max_new_tokens=32)
    output_text = processor.batch_decode(
        generated_ids, skip_special_tokens=False, clean_up_tokenization_spaces=False
    )
    print(output_text)


try_inference(save_path)

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

258
Total runs
0
24-hour runs
0
3-day runs
256
7-day runs
250
30-day runs

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

qvq-preview-tiny-random huggingface.co

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

qvq-preview-tiny-random huggingface.co Url

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

yujiepan qvq-preview-tiny-random online free

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

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

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

qvq-preview-tiny-random install

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

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

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

Url of qvq-preview-tiny-random

qvq-preview-tiny-random huggingface.co Url

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

yujiepan
ORGANIZATIONS

Other API from yujiepan