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
Make Phi4MMForCausalLM.forward's num_logits_to_keep actually optional
#20
by phh - opened
- modeling_phi4mm.py +4 -1
modeling_phi4mm.py
CHANGED
|
@@ -2134,7 +2134,10 @@ class Phi4MMForCausalLM(Phi4MMPreTrainedModel, GenerationMixin):
|
|
| 2134 |
|
| 2135 |
hidden_states = outputs[0]
|
| 2136 |
# Only compute necessary logits, and do not upcast them to float if we are not computing the loss
|
| 2137 |
-
|
|
|
|
|
|
|
|
|
|
| 2138 |
|
| 2139 |
loss = None
|
| 2140 |
if labels is not None:
|
|
|
|
| 2134 |
|
| 2135 |
hidden_states = outputs[0]
|
| 2136 |
# Only compute necessary logits, and do not upcast them to float if we are not computing the loss
|
| 2137 |
+
if num_logits_to_keep:
|
| 2138 |
+
logits = self.lm_head(hidden_states[:, -num_logits_to_keep:, :])
|
| 2139 |
+
else:
|
| 2140 |
+
logits = self.lm_head(hidden_states)
|
| 2141 |
|
| 2142 |
loss = None
|
| 2143 |
if labels is not None:
|