Image-Text-to-Text
Transformers
Safetensors
qwen2_vl
llama-factory
full
Generated from Trainer
long-context
reasoning
multi-modal
conversational
text-generation-inference
Instructions to use Allen8/TVC-7B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Allen8/TVC-7B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="Allen8/TVC-7B") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForImageTextToText processor = AutoProcessor.from_pretrained("Allen8/TVC-7B") model = AutoModelForImageTextToText.from_pretrained("Allen8/TVC-7B") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Allen8/TVC-7B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Allen8/TVC-7B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Allen8/TVC-7B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/Allen8/TVC-7B
- SGLang
How to use Allen8/TVC-7B 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 "Allen8/TVC-7B" \ --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": "Allen8/TVC-7B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'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 "Allen8/TVC-7B" \ --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": "Allen8/TVC-7B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use Allen8/TVC-7B with Docker Model Runner:
docker model run hf.co/Allen8/TVC-7B
Update pipeline tag, add project page link, quick start and other tags
#1
by nielsr HF Staff - opened
README.md
CHANGED
|
@@ -1,14 +1,18 @@
|
|
| 1 |
---
|
|
|
|
| 2 |
library_name: transformers
|
| 3 |
license: apache-2.0
|
| 4 |
-
base_model: Qwen/Qwen2-VL-7B-Instruct
|
| 5 |
tags:
|
| 6 |
- llama-factory
|
| 7 |
- full
|
| 8 |
- generated_from_trainer
|
|
|
|
|
|
|
|
|
|
| 9 |
model-index:
|
| 10 |
- name: TVC-7B
|
| 11 |
results: []
|
|
|
|
| 12 |
---
|
| 13 |
|
| 14 |
## Model Summary
|
|
@@ -16,10 +20,10 @@ model-index:
|
|
| 16 |
The TVC models are 7B parameter models based on Qwen2-VL-7B-Instruct model with a context window of 8K tokens.
|
| 17 |
|
| 18 |
- **Repository:** https://github.com/sun-hailong/TVC
|
|
|
|
| 19 |
- **Languages:** English, Chinese
|
| 20 |
- **Paper:** https://arxiv.org/abs/2503.13360
|
| 21 |
|
| 22 |
-
|
| 23 |
### Model Architecture
|
| 24 |
|
| 25 |
- **Architecture:** Qwen2-VL-7B-Instruct
|
|
@@ -39,6 +43,54 @@ The TVC models are 7B parameter models based on Qwen2-VL-7B-Instruct model with
|
|
| 39 |
- Datasets 3.1.0
|
| 40 |
- Tokenizers 0.20.3
|
| 41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
## Citation
|
| 43 |
|
| 44 |
```
|
|
|
|
| 1 |
---
|
| 2 |
+
base_model: Qwen/Qwen2-VL-7B-Instruct
|
| 3 |
library_name: transformers
|
| 4 |
license: apache-2.0
|
|
|
|
| 5 |
tags:
|
| 6 |
- llama-factory
|
| 7 |
- full
|
| 8 |
- generated_from_trainer
|
| 9 |
+
- long-context
|
| 10 |
+
- reasoning
|
| 11 |
+
- multi-modal
|
| 12 |
model-index:
|
| 13 |
- name: TVC-7B
|
| 14 |
results: []
|
| 15 |
+
pipeline_tag: image-text-to-text
|
| 16 |
---
|
| 17 |
|
| 18 |
## Model Summary
|
|
|
|
| 20 |
The TVC models are 7B parameter models based on Qwen2-VL-7B-Instruct model with a context window of 8K tokens.
|
| 21 |
|
| 22 |
- **Repository:** https://github.com/sun-hailong/TVC
|
| 23 |
+
- **Project Page:** https://sun-hailong.github.io/projects/TVC/
|
| 24 |
- **Languages:** English, Chinese
|
| 25 |
- **Paper:** https://arxiv.org/abs/2503.13360
|
| 26 |
|
|
|
|
| 27 |
### Model Architecture
|
| 28 |
|
| 29 |
- **Architecture:** Qwen2-VL-7B-Instruct
|
|
|
|
| 43 |
- Datasets 3.1.0
|
| 44 |
- Tokenizers 0.20.3
|
| 45 |
|
| 46 |
+
## Quick Start
|
| 47 |
+
|
| 48 |
+
```python
|
| 49 |
+
from vllm import LLM, SamplingParams
|
| 50 |
+
from PIL import Image
|
| 51 |
+
|
| 52 |
+
model_name = "Allen8/TVC-72B"
|
| 53 |
+
llm = LLM(
|
| 54 |
+
model=model_name,
|
| 55 |
+
trust_remote_code=True,
|
| 56 |
+
tensor_parallel_size=8,
|
| 57 |
+
)
|
| 58 |
+
|
| 59 |
+
question = "Hint: Please answer the question requiring an integer answer and provide the final value, e.g., 1, 2, 3, at the end.
|
| 60 |
+
Question: Subtract all red things. Subtract all tiny matte balls. How many objects are left?
|
| 61 |
+
Please answer the question using a long-chain reasoning style and think step by step."
|
| 62 |
+
placeholder = "<|image_pad|>"
|
| 63 |
+
prompt = ("<|im_start|>system
|
| 64 |
+
You are a helpful assistant.<|im_end|>
|
| 65 |
+
"
|
| 66 |
+
f"<|im_start|>user
|
| 67 |
+
<|vision_start|>{placeholder}<|vision_end|>"
|
| 68 |
+
f"{question}<|im_end|>
|
| 69 |
+
"
|
| 70 |
+
"<|im_start|>assistant
|
| 71 |
+
")
|
| 72 |
+
|
| 73 |
+
sampling_params = SamplingParams(
|
| 74 |
+
temperature=0.0,
|
| 75 |
+
top_k=1,
|
| 76 |
+
top_p=1.0,
|
| 77 |
+
stop_token_ids=[],
|
| 78 |
+
repetition_penalty=1.05,
|
| 79 |
+
max_tokens=8192
|
| 80 |
+
)
|
| 81 |
+
|
| 82 |
+
image = Image.open("images/case1.png")
|
| 83 |
+
inputs = {
|
| 84 |
+
"prompt": prompt,
|
| 85 |
+
"multi_modal_data": {
|
| 86 |
+
"image": image
|
| 87 |
+
},
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
outputs = llm.generate([inputs], sampling_params=sampling_params)
|
| 91 |
+
print(outputs[0].outputs[0].text)
|
| 92 |
+
```
|
| 93 |
+
|
| 94 |
## Citation
|
| 95 |
|
| 96 |
```
|