Instructions to use TIGER-Lab/VLM2Vec-LoRA with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use TIGER-Lab/VLM2Vec-LoRA with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="TIGER-Lab/VLM2Vec-LoRA", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("TIGER-Lab/VLM2Vec-LoRA", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use TIGER-Lab/VLM2Vec-LoRA with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "TIGER-Lab/VLM2Vec-LoRA" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "TIGER-Lab/VLM2Vec-LoRA", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/TIGER-Lab/VLM2Vec-LoRA
- SGLang
How to use TIGER-Lab/VLM2Vec-LoRA with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "TIGER-Lab/VLM2Vec-LoRA" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "TIGER-Lab/VLM2Vec-LoRA", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "TIGER-Lab/VLM2Vec-LoRA" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "TIGER-Lab/VLM2Vec-LoRA", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use TIGER-Lab/VLM2Vec-LoRA with Docker Model Runner:
docker model run hf.co/TIGER-Lab/VLM2Vec-LoRA
Update README.md
Browse files
README.md
CHANGED
|
@@ -53,11 +53,9 @@ from PIL import Image
|
|
| 53 |
import numpy as np
|
| 54 |
|
| 55 |
model_args = ModelArguments(
|
| 56 |
-
model_name='
|
| 57 |
pooling='last',
|
| 58 |
-
normalize=True
|
| 59 |
-
lora=True,
|
| 60 |
-
checkpoint_path='TIGER-Lab/VLM2Vec-LoRA')
|
| 61 |
|
| 62 |
model = MMEBModel.load(model_args)
|
| 63 |
model.eval()
|
|
@@ -99,6 +97,17 @@ inputs = {key: value.to('cuda') for key, value in inputs.items()}
|
|
| 99 |
tgt_output = model(tgt=inputs)["tgt_reps"]
|
| 100 |
print(string, '=', model.compute_similarity(qry_output, tgt_output))
|
| 101 |
## <|image_1|> Represent the given image. = tensor([[0.3105]], device='cuda:0', dtype=torch.bfloat16)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
```
|
| 103 |
|
| 104 |
## Citation
|
|
|
|
| 53 |
import numpy as np
|
| 54 |
|
| 55 |
model_args = ModelArguments(
|
| 56 |
+
model_name='TIGER-Lab/VLM2Vec-Full',
|
| 57 |
pooling='last',
|
| 58 |
+
normalize=True)
|
|
|
|
|
|
|
| 59 |
|
| 60 |
model = MMEBModel.load(model_args)
|
| 61 |
model.eval()
|
|
|
|
| 97 |
tgt_output = model(tgt=inputs)["tgt_reps"]
|
| 98 |
print(string, '=', model.compute_similarity(qry_output, tgt_output))
|
| 99 |
## <|image_1|> Represent the given image. = tensor([[0.3105]], device='cuda:0', dtype=torch.bfloat16)
|
| 100 |
+
|
| 101 |
+
inputs = processor('Find me an everyday image that matches the given caption: A cat and a tiger.',)
|
| 102 |
+
inputs = {key: value.to('cuda') for key, value in inputs.items()}
|
| 103 |
+
qry_output = model(qry=inputs)["qry_reps"]
|
| 104 |
+
|
| 105 |
+
string = '<|image_1|> Represent the given image.'
|
| 106 |
+
inputs = processor(string, [Image.open('figures/example.jpg')])
|
| 107 |
+
inputs = {key: value.to('cuda') for key, value in inputs.items()}
|
| 108 |
+
tgt_output = model(tgt=inputs)["tgt_reps"]
|
| 109 |
+
print(string, '=', model.compute_similarity(qry_output, tgt_output))
|
| 110 |
+
## <|image_1|> Represent the given image. = tensor([[0.2158]], device='cuda:0', dtype=torch.bfloat16)
|
| 111 |
```
|
| 112 |
|
| 113 |
## Citation
|