Image-Text-to-Text
Transformers
Safetensors
English
Chinese
hy_v4_vl
nvfp4
fp4
vllm
llm-compressor
compressed-tensors
hunyuan
hy4
Mixture of Experts
conversational
8-bit precision
Run this model with HF Jobs
Run RedHatAI/Hy4-NVFP4 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/RedHatAI/Hy4-NVFP4. 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/RedHatAI/Hy4-NVFP4 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/RedHatAI/Hy4-NVFP4. 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.
Instructions to use RedHatAI/Hy4-NVFP4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use RedHatAI/Hy4-NVFP4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="RedHatAI/Hy4-NVFP4") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("RedHatAI/Hy4-NVFP4") model = AutoModelForMultimodalLM.from_pretrained("RedHatAI/Hy4-NVFP4", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use RedHatAI/Hy4-NVFP4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "RedHatAI/Hy4-NVFP4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "RedHatAI/Hy4-NVFP4", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/RedHatAI/Hy4-NVFP4
- SGLang
How to use RedHatAI/Hy4-NVFP4 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "RedHatAI/Hy4-NVFP4" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "RedHatAI/Hy4-NVFP4", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "RedHatAI/Hy4-NVFP4" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "RedHatAI/Hy4-NVFP4", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use RedHatAI/Hy4-NVFP4 with Docker Model Runner:
docker model run hf.co/RedHatAI/Hy4-NVFP4
Update model card: size, DFly2 support, creation script, evaluation details
Browse files41 unmodified lines4243444546474817 unmodified lines666768697071727313 unmodified lines8788899091923 unmodified lines9697989910010110210323 unmodified lines12712812913013113237 unmodified lines17017117217317441 unmodified linesLayers outside of routed experts are left unquantized in BF16: attention and the DSA indexer, thedense first layer, shared experts, routers, the vision encoder and adapter, `lm_head`, and theDFly2 speculative-decoding drafter. This reduces the checkpoint from about 1.55 TB to about447 GB.The checkpoint uses [LLM Compressor](https://github.com/vllm-project/llm-compressor)'scompressed-tensors NVFP4 format and keeps the tensor names and config of the original checkpoint.17 unmodified linesRecommended sampling parameters are `temperature=0.9`, `top_p=1.0`. Reasoning effort accepts`"no_think"` and `"high"` (default) through `chat_template_kwargs`.The BF16 DFly2 drafter weights are included in the checkpoint. vLLM currently enables`--speculative-config '{"method":"dfly",...}'` only for FP8 and MXFP4 Hy4 checkpoints.## Creation13 unmodified lines<summary>Creation script</summary>```pythonimport torchfrom transformers import AutoProcessor, HYV4VLForConditionalGeneration3 unmodified linesMODEL_ID = "tencent/Hy4"# launched with torchrun --nproc-per-node=4; the default process group is initialized# with a long timeout because rank 0 loads the full checkpoint before sharing itwith load_context(HYV4VLForConditionalGeneration):model = HYV4VLForConditionalGeneration.from_pretrained(MODEL_ID,23 unmodified lines)model.save_pretrained("Hy4-NVFP4-raw", save_compressed=True, save_original_format=False)```</details>37 unmodified lines</table>Standard errors are about 0.5 points for GSM8K Platinum and 2.1 points for GPQA Diamond (198questions, one seed), so the GPQA difference is within run-to-run noise. Most GSM8K Platinum missesfor both models are answers that omit the requested `ANSWER:` line while stating the correct value.41 unmodified lines4243444546474817 unmodified lines66676869707172737413 unmodified lines8889909192939495963 unmodified lines10010110210310410510610710810911011111223 unmodified lines13613713813914014114237 unmodified lines18018118218318418518618718818941 unmodified linesLayers outside of routed experts are left unquantized in BF16: attention and the DSA indexer, thedense first layer, shared experts, routers, the vision encoder and adapter, `lm_head`, and theDFly2 speculative-decoding drafter. This reduces the checkpoint from about 1.55 TB to about479 GB (447 GiB).The checkpoint uses [LLM Compressor](https://github.com/vllm-project/llm-compressor)'scompressed-tensors NVFP4 format and keeps the tensor names and config of the original checkpoint.17 unmodified linesRecommended sampling parameters are `temperature=0.9`, `top_p=1.0`. Reasoning effort accepts`"no_think"` and `"high"` (default) through `chat_template_kwargs`.The BF16 DFly2 drafter weights are included in the checkpoint. Using them with`--speculative-config '{"method":"dfly","num_speculative_tokens":5}'` requires[vllm-project/vllm#69274](https://github.com/vllm-project/vllm/pull/69274), which is not merged yet.## Creation13 unmodified lines<summary>Creation script</summary>```pythonimport osfrom datetime import timedeltaimport torchfrom transformers import AutoProcessor, HYV4VLForConditionalGeneration3 unmodified linesMODEL_ID = "tencent/Hy4"# torchrun --nproc-per-node=4 <script># The long timeout covers rank 0 loading the full checkpoint before sharing it.rank = int(os.environ["LOCAL_RANK"])torch.accelerator.set_device_index(rank)torch.distributed.init_process_group(backend="nccl", device_id=torch.device(f"cuda:{rank}"), timeout=timedelta(hours=4))with load_context(HYV4VLForConditionalGeneration):model = HYV4VLForConditionalGeneration.from_pretrained(MODEL_ID,23 unmodified lines)model.save_pretrained("Hy4-NVFP4-raw", save_compressed=True, save_original_format=False)# The output still needs the name and config conversion described above.```</details>37 unmodified lines</table>Standard errors are about 0.5 points for GSM8K Platinum and 2.1 points for GPQA Diamond (198questions, one seed), so the GPQA difference is within run-to-run noise. The GSM8K prompt does not requestan answer format, and some misses are answer-extraction failures: by a looser check of the finalstated number, 28 of the 45 NVFP4 misses and 24 of the 39 FP8 misses match the reference.The server ran with `--max-model-len 65536`, which was the effective limit on reasoning plus answerfor both tasks. Responses with empty content were retried once. After that, 7 of the 198 GPQAanswers for each model were still empty because reasoning exhausted the limit, and count as wrong.
README.md+22-7