Video-Text-to-Text
Transformers
Safetensors
qwen3_vl
image-text-to-text
video
temporal-grounding
qwen3-vl
Instructions to use MCG-NJU/TimeLens2-2B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MCG-NJU/TimeLens2-2B with Transformers:
# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("MCG-NJU/TimeLens2-2B") model = AutoModelForMultimodalLM.from_pretrained("MCG-NJU/TimeLens2-2B", device_map="auto") - Notebooks
- Google Colab
- Kaggle
| license: apache-2.0 | |
| library_name: transformers | |
| pipeline_tag: video-text-to-text | |
| base_model: Qwen/Qwen3-VL-2B-Instruct | |
| tags: | |
| - video | |
| - temporal-grounding | |
| - qwen3-vl | |
| # TimeLens2-2B | |
| TimeLens2-2B is a compact video multimodal large language model specialized for temporal grounding. Given a video and a text query, it returns all time intervals containing the relevant visual evidence. | |
| The model is built on [Qwen3-VL-2B-Instruct](https://huggingface.co/Qwen/Qwen3-VL-2B-Instruct) and achieves **44.5 average mIoU** across seven temporal grounding benchmarks. | |
| **TimeLens2-2B sets a new state of the art at the 2B scale**, outperforming all three size-matched baselines on every benchmark and even surpassing TimeLens-8B by 2.4 mIoU on average. | |
| ## Paper | |
| [TimeLens2: Generalist Video Temporal Grounding with Multimodal LLMs](https://arxiv.org/abs/2607.17423) | |
| ## Benchmark Results | |
|  | |
| ## Inference | |
| ```bash | |
| pip install -U torch torchvision "transformers>=4.57.0" accelerate "qwen-vl-utils[decord]>=0.0.14" | |
| pip install -U flash-attn --no-build-isolation | |
| ``` | |
| ```python | |
| from pathlib import Path | |
| from qwen_vl_utils import process_vision_info | |
| from transformers import AutoModelForImageTextToText, AutoProcessor | |
| model_id = "MCG-NJU/TimeLens2-2B" | |
| video_path = "/path/to/video.mp4" | |
| query = "A man opens the refrigerator." | |
| model = AutoModelForImageTextToText.from_pretrained( | |
| model_id, | |
| torch_dtype="auto", | |
| device_map="auto", | |
| attn_implementation="flash_attention_2", | |
| ) | |
| processor = AutoProcessor.from_pretrained(model_id) | |
| prompt = ( | |
| f'Given the query: "{query}", return ALL time spans (in seconds) where the query is relevant.\n' | |
| "Output format MUST be a JSON array of [start, end] pairs.\n" | |
| ) | |
| messages = [ | |
| { | |
| "role": "user", | |
| "content": [ | |
| { | |
| "type": "video", | |
| "video": Path(video_path).resolve().as_uri(), | |
| "fps": 2.0, | |
| "min_pixels": 32 * 32, | |
| "max_pixels": 480 * 480, | |
| "total_pixels": 128000 * 32 * 32, | |
| }, | |
| {"type": "text", "text": prompt}, | |
| ], | |
| } | |
| ] | |
| text = processor.apply_chat_template( | |
| messages, | |
| tokenize=False, | |
| add_generation_prompt=True, | |
| ) | |
| images, videos, video_kwargs = process_vision_info( | |
| messages, | |
| image_patch_size=16, | |
| return_video_kwargs=True, | |
| return_video_metadata=True, | |
| ) | |
| if videos is not None: | |
| videos, video_metadatas = zip(*videos) | |
| videos, video_metadatas = list(videos), list(video_metadatas) | |
| else: | |
| video_metadatas = None | |
| inputs = processor( | |
| text=text, | |
| images=images, | |
| videos=videos, | |
| video_metadata=video_metadatas, | |
| do_resize=False, | |
| return_tensors="pt", | |
| **video_kwargs, | |
| ).to(model.device) | |
| output_ids = model.generate( | |
| **inputs, | |
| max_new_tokens=4096, | |
| temperature=0.01, | |
| top_p=0.001, | |
| top_k=1, | |
| repetition_penalty=1.0, | |
| ) | |
| output_ids = [ | |
| output[len(input_ids) :] | |
| for input_ids, output in zip(inputs.input_ids, output_ids) | |
| ] | |
| response = processor.batch_decode( | |
| output_ids, | |
| skip_special_tokens=True, | |
| clean_up_tokenization_spaces=False, | |
| ) | |
| print(response[0]) | |
| ``` | |
| ## Citation | |
| ```bibtex | |
| @misc{zhu2026timelens2, | |
| title={TimeLens2: Generalist Video Temporal Grounding with Multimodal LLMs}, | |
| author={Yuhan Zhu and Changlian Ma and Xiangyu Zeng and Xinhao Li and Zhiqiu Zhang and Songze Li and Jun Zhang and Tianxiang Jiang and Yuandong Yang and Ziang Yan and Zikang Wang and Xinyu Chen and Haoran Chen and Shaowei Zhang and Limin Wang}, | |
| year={2026}, | |
| eprint={2607.17423}, | |
| archivePrefix={arXiv}, | |
| primaryClass={cs.CV}, | |
| url={https://arxiv.org/abs/2607.17423}, | |
| } | |
| ``` | |