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)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("microsoft/Phi-4-multimodal-instruct", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update modeling_phi4mm.py to avoid `TypeError: unsupported operand type(s) for *: 'int' and 'NoneType' `
Browse filesEnsure 'num_logits_to_keep' has always a valid numeric value before the slice is computed to avoid `TypeError: unsupported operand type(s) for *: 'int' and 'NoneType' `
- modeling_phi4mm.py +3 -0
modeling_phi4mm.py
CHANGED
|
@@ -2143,6 +2143,9 @@ class Phi4MMForCausalLM(Phi4MMPreTrainedModel, GenerationMixin):
|
|
| 2143 |
|
| 2144 |
hidden_states = outputs[0]
|
| 2145 |
# Only compute necessary logits, and do not upcast them to float if we are not computing the loss
|
|
|
|
|
|
|
|
|
|
| 2146 |
logits = self.lm_head(hidden_states[:, -num_logits_to_keep:, :])
|
| 2147 |
|
| 2148 |
loss = None
|
|
|
|
| 2143 |
|
| 2144 |
hidden_states = outputs[0]
|
| 2145 |
# Only compute necessary logits, and do not upcast them to float if we are not computing the loss
|
| 2146 |
+
if num_logits_to_keep is None:
|
| 2147 |
+
num_logits_to_keep = hidden_states.size(1)
|
| 2148 |
+
|
| 2149 |
logits = self.lm_head(hidden_states[:, -num_logits_to_keep:, :])
|
| 2150 |
|
| 2151 |
loss = None
|