Zero-Shot Image Classification
Transformers
Safetensors
sentence-transformers
mllama
image-text-to-text
mmeb
text-generation-inference
Instructions to use intfloat/mmE5-mllama-11b-instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use intfloat/mmE5-mllama-11b-instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("zero-shot-image-classification", model="intfloat/mmE5-mllama-11b-instruct") pipe( "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png", candidate_labels=["animals", "humans", "landscape"], )# Load model directly from transformers import AutoProcessor, AutoModelForImageTextToText processor = AutoProcessor.from_pretrained("intfloat/mmE5-mllama-11b-instruct") model = AutoModelForImageTextToText.from_pretrained("intfloat/mmE5-mllama-11b-instruct") - sentence-transformers
How to use intfloat/mmE5-mllama-11b-instruct with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("intfloat/mmE5-mllama-11b-instruct") sentences = [ "The weather is lovely today.", "It's so sunny outside!", "He drove to the stadium." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [3, 3] - Notebooks
- Google Colab
- Kaggle
Set use_cache to false
Browse files- README.md +2 -10
- config.json +1 -1
README.md
CHANGED
|
@@ -44,7 +44,7 @@ pip install -r requirements.txt
|
|
| 44 |
|
| 45 |
Then you can enter the directory to run the following command.
|
| 46 |
```python
|
| 47 |
-
from transformers import MllamaForConditionalGeneration, AutoProcessor
|
| 48 |
import torch
|
| 49 |
from PIL import Image
|
| 50 |
|
|
@@ -64,17 +64,9 @@ model_name = "intfloat/mmE5-mllama-11b-instruct"
|
|
| 64 |
|
| 65 |
# Load Processor and Model
|
| 66 |
processor = AutoProcessor.from_pretrained(model_name)
|
| 67 |
-
processor.tokenizer.padding_side = "right"
|
| 68 |
-
|
| 69 |
-
config = AutoConfig.from_pretrained(model_name)
|
| 70 |
-
if hasattr(config, 'use_cache'):
|
| 71 |
-
config.use_cache = False
|
| 72 |
-
config.padding_side = "right"
|
| 73 |
model = MllamaForConditionalGeneration.from_pretrained(
|
| 74 |
-
model_name,
|
| 75 |
-
torch_dtype=torch.bfloat16
|
| 76 |
).to("cuda")
|
| 77 |
-
model.padding_side = "right"
|
| 78 |
model.eval()
|
| 79 |
|
| 80 |
# Image + Text -> Text
|
|
|
|
| 44 |
|
| 45 |
Then you can enter the directory to run the following command.
|
| 46 |
```python
|
| 47 |
+
from transformers import MllamaForConditionalGeneration, AutoProcessor
|
| 48 |
import torch
|
| 49 |
from PIL import Image
|
| 50 |
|
|
|
|
| 64 |
|
| 65 |
# Load Processor and Model
|
| 66 |
processor = AutoProcessor.from_pretrained(model_name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
model = MllamaForConditionalGeneration.from_pretrained(
|
| 68 |
+
model_name, torch_dtype=torch.bfloat16
|
|
|
|
| 69 |
).to("cuda")
|
|
|
|
| 70 |
model.eval()
|
| 71 |
|
| 72 |
# Image + Text -> Text
|
config.json
CHANGED
|
@@ -96,7 +96,7 @@
|
|
| 96 |
"torchscript": false,
|
| 97 |
"typical_p": 1.0,
|
| 98 |
"use_bfloat16": false,
|
| 99 |
-
"use_cache":
|
| 100 |
"vocab_size": 128256
|
| 101 |
},
|
| 102 |
"torch_dtype": "bfloat16",
|
|
|
|
| 96 |
"torchscript": false,
|
| 97 |
"typical_p": 1.0,
|
| 98 |
"use_bfloat16": false,
|
| 99 |
+
"use_cache": false,
|
| 100 |
"vocab_size": 128256
|
| 101 |
},
|
| 102 |
"torch_dtype": "bfloat16",
|