forked from vllm-project/vllm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Model] VLM2Vec, the first multimodal embedding model in vLLM (vllm-p…
- Loading branch information
1 parent
7e7eae3
commit 7abba39
Showing
16 changed files
with
465 additions
and
261 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from vllm import LLM | ||
from vllm.assets.image import ImageAsset | ||
|
||
image = ImageAsset("cherry_blossom").pil_image.convert("RGB") | ||
prompt = "<|image_1|> Represent the given image with the following question: What is in the image" # noqa: E501 | ||
|
||
# Create an LLM. | ||
llm = LLM( | ||
model="TIGER-Lab/VLM2Vec-Full", | ||
trust_remote_code=True, | ||
max_model_len=4096, | ||
max_num_seqs=2, | ||
mm_processor_kwargs={"num_crops": 16}, | ||
) | ||
|
||
# Generate embedding. The output is a list of EmbeddingRequestOutputs. | ||
outputs = llm.encode({"prompt": prompt, "multi_modal_data": {"image": image}}) | ||
|
||
# Print the outputs. | ||
for output in outputs: | ||
print(output.outputs.embedding) # list of 3072 floats |
Oops, something went wrong.