Automatic Speech Recognition
Transformers
Safetensors
phi4mm
text-generation
nlp
code
audio
speech-summarization
speech-translation
visual-question-answering
phi-4-multimodal
phi
phi-4-mini
custom_code
Eval Results
Instructions to use microsoft/Phi-4-multimodal-instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use microsoft/Phi-4-multimodal-instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("automatic-speech-recognition", model="microsoft/Phi-4-multimodal-instruct", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("microsoft/Phi-4-multimodal-instruct", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
Bug in the speech fine-tuning script
#33
by h9LtLSb - opened
Thanks for sharing the fine-tuning script! I found a bug here. The .rstrip(ANSWER_SUFFIX) can remove extra characters at the end. I suggest to replace it with .replace(ANSWER_SUFFIX, "").
Example:
ipdb> processor.decode(inputs["labels"][1]).rstrip(ANSWER_SUFFIX)
'!!!!!!!!!!quite the opposi'
ipdb> processor.decode(inputs["labels"][1])
'!!!!!!!!!!quite the opposite<|end|><|endoftext|>'
ipdb> processor.decode(inputs["labels"][1]).replace(ANSWER_SUFFIX, "")
'!!!!!!!!!!quite the opposite'
Also, just a comment: for anyone wanting to use the Whisper normalizer for the predicted / reference text, here's one way to do it (data_utils from here)
generated_text = [
data_utils.normalizer(processor.decode(_pred_ids[inputs["input_ids"].shape[1] : _stop_tokens_idx],
skip_special_tokens=True,
clean_up_tokenization_spaces=False)) # add whisper normalizer
for _pred_ids, _stop_tokens_idx in zip(generated_ids, stop_tokens_idx)
]
all_generated_texts.extend(generated_text)
labels = [data_utils.normalizer(processor.decode(_label_ids[_label_ids != 0]).replace(ANSWER_SUFFIX, "")) for _label_ids in inputs["labels"]]
@h9LtLSb Thank you for sharing! We've made a PR to fix the bug. https://huggingface.co/microsoft/Phi-4-multimodal-instruct/discussions/34
nguyenbh changed discussion status to closed