Instructions to use INCModel4/Phi-4-multimodal-instruct-W4A16-AutoRound with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use INCModel4/Phi-4-multimodal-instruct-W4A16-AutoRound with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("automatic-speech-recognition", model="INCModel4/Phi-4-multimodal-instruct-W4A16-AutoRound", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("INCModel4/Phi-4-multimodal-instruct-W4A16-AutoRound", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Model Details
This model is an int4 (W4A16, group_size 128, symmetric) model of microsoft/Phi-4-multimodal-instruct generated by intel/auto-round with 200 tuning iterations. Please follow the license of the original model.
- Quantized (W4A16): text decoder linear projections
- Kept in BF16: LoRA adapters, token embeddings, lm_head, vision and audio components, normalization layers
How to Use
Environment
uv pip install vllm==0.33.0
uv pip install transformers==5.20.2
vLLM Usage
vllm serve INCModel4/Phi-4-multimodal-instruct-W4A16-AutoRound \
--kv-cache-dtype auto \
--dtype bfloat16 \
--trust-remote-code
Evaluation
| Benchmark | BF16 | W4A16 | Recovery |
|---|---|---|---|
| PIQA | 77.58 | 77.20 | 99.51% |
| HellaSwag | 51.73 | 50.64 | 97.88% |
| MMLU | 64.76 | 63.48 | 98.02% |
| GSM8K | 63.61 | 64.97 | 102.15% |
| Average | 64.42 | 64.07 | 99.46% |
lm_eval
lm_eval --model local-completions \
--model_args model=INCModel4/Phi-4-multimodal-instruct-W4A16-AutoRound,tokenizer=microsoft/Phi-4-multimodal-instruct,tokenizer_backend=huggingface,base_url=http://127.0.0.1:8000/v1/completions,tokenized_requests=True,num_concurrent=32,max_retries=50,timeout=1800,max_length=131073,max_gen_toks=2048,trust_remote_code=True,add_bos_token=False \
--tasks gsm8k --batch_size 32 --output_path results/gsm8k --log_samples --seed 42 \
--num_fewshot 5 --apply_chat_template --fewshot_as_multiturn --gen_kwargs max_gen_toks=2048
lm_eval --model local-completions \
--model_args model=INCModel4/Phi-4-multimodal-instruct-W4A16-AutoRound,tokenizer=microsoft/Phi-4-multimodal-instruct,tokenizer_backend=huggingface,base_url=http://127.0.0.1:8000/v1/completions,tokenized_requests=True,num_concurrent=32,max_retries=50,timeout=1800,max_length=131073,max_gen_toks=2048,trust_remote_code=True,add_bos_token=False \
--tasks piqa,mmlu,hellaswag --batch_size 32 --output_path results/piqa_mmlu_hellaswag --log_samples --seed 42
Generate the Model
curl -fsSL https://huggingface.co/INCModel4/Phi-4-multimodal-instruct-W4A16-AutoRound/resolve/main/auto-round-block-list-fallback.patch \
| patch -p1 -d "$(python -c 'import auto_round; from pathlib import Path; print(Path(auto_round.__file__).resolve().parent.parent)')"
auto-round \
--model_name microsoft/Phi-4-multimodal-instruct \
--scheme W4A16 \
--iters 200 \
--nsamples 128 \
--ignore_layers lora_A,lora_B,embed_tokens_extend,lm_head \
--format auto_round \
--output_dir Phi-4-multimodal-instruct-W4A16-AutoRound \
--seqlen 2048 \
--group_size 128 \
--to_quant_block_names model.layers
Ethical Considerations and Limitations
The model can produce factually incorrect output, and should not be relied on to produce factually accurate information. Because of the limitations of the pretrained model and the finetuning datasets, it is possible that this model could generate lewd, biased or otherwise offensive outputs. Therefore, before deploying any applications of the model, developers should perform safety testing.
Caveats and Recommendations
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. Here are a couple of useful links to learn more about Intel's AI software:
Disclaimer
The license on this model does not constitute legal advice. We are not responsible for the actions of third parties who use this model. Please consult an attorney before using this model for commercial purposes.
Cite
@article{cheng2023optimize,
title={Optimize weight rounding via signed gradient descent for the quantization of llms},
author={Cheng, Wenhua and Zhang, Weiwei and Shen, Haihao and Cai, Yiyang and He, Xin and Lv, Kaokao and Liu, Yi},
journal={arXiv preprint arXiv:2309.05516},
year={2023}
}
Signed-off-by: Sun, Xuehao xuehao.sun@intel.com
- Downloads last month
- 52
Model tree for INCModel4/Phi-4-multimodal-instruct-W4A16-AutoRound
Base model
microsoft/Phi-4-multimodal-instruct