library_name: transformers
tags:
- colpali
license: apache-2.0
datasets:
- vidore/colpali_train_set
language:
- en
base_model:
- vidore/colqwen2-base
pipeline_tag: visual-document-retrieval
[!警告]
实验性模型:请等待 https://github.com/huggingface/transformers/pull/35778 合并后再使用!
[!重要]
本版ColQwen2需使用transformers 🤗
版本加载,而非colpali-engine
。
该模型通过convert_colqwen2_weights_to_hf.py
脚本转换自
vidore/colqwen2-v1.0-merged
检查点。
ColQwen2:基于Qwen2-VL-2B-Instruct与ColBERT策略的视觉检索模型
ColQwen2是基于视觉语言模型(VLMs)的新型架构与训练策略的文档视觉特征索引模型。作为Qwen2-VL-2B的扩展版本,它能生成文本与图像的ColBERT式多向量表征。该模型由论文ColPali:基于视觉语言模型的高效文档检索首次提出,并发布于此代码库

HuggingFace transformers
🤗 实现由Tony Wu (@tonywu71)和Yoni Gozlan (@yonigozlan)贡献。
模型说明
阅读transformers
🤗模型卡片:https://huggingface.co/docs/transformers/en/model_doc/colqwen2.
模型训练
数据集
我们训练的127,460组查询-页面对包含:公开学术数据集训练集(63%) + 网络爬取PDF文档经VLM(Claude-3 Sonnet)生成伪问题增强的合成数据集(37%)。训练集为全英文设计,可研究非英语语言的零样本泛化能力。我们确保ViDoRe与训练集无多页PDF重复以防止评估污染。验证集取2%样本用于超参调优。
使用示例
import torch
from PIL import Image
from transformers import ColQwen2ForRetrieval, ColQwen2Processor
from transformers.utils.import_utils import is_flash_attn_2_available
model_name = "vidore/colqwen2-v1.0-hf"
model = ColQwen2ForRetrieval.from_pretrained(
model_name,
torch_dtype=torch.bfloat16,
device_map="cuda:0",
attn_implementation="flash_attention_2" if is_flash_attn_2_available() else None,
).eval()
processor = ColQwen2Processor.from_pretrained(model_name)
images = [
Image.new("RGB", (128, 128), color="white"),
Image.new("RGB", (64, 32), color="black"),
]
queries = [
"我们研发部门的组织架构是怎样的?",
"能否提供去年财务表现的细分数据?",
]
batch_images = processor(images=images).to(model.device)
batch_queries = processor(text=queries).to(model.device)
with torch.no_grad():
image_embeddings = model(**batch_images).embeddings
query_embeddings = model(**batch_queries).embeddings
scores = processor.score_retrieval(query_embeddings, image_embeddings)
局限性
- 适用范围:主要针对PDF类文档和高资源语言,对其他文档类型或低资源语言的泛化能力有限。
- 支持框架:依赖ColBERT延迟交互机制衍生的多向量检索,需工程适配缺乏原生多向量支持的通用向量检索框架。
许可协议
ColQwen2的视觉语言骨干模型(Qwen2-VL)采用apache-2.0
许可。ColQwen2继承该apache-2.0
许可。
联系方式
- Manuel Faysse: manuel.faysse@illuin.tech
- Hugues Sibille: hugues.sibille@illuin.tech
- Tony Wu: tony.wu@illuin.tech
引用
若在研究中使用了本组织的任何数据集或模型,请按以下格式引用原始论文:
@misc{faysse2024colpaliefficientdocumentretrieval,
title={ColPali:基于视觉语言模型的高效文档检索},
author={Manuel Faysse and Hugues Sibille and Tony Wu and Bilel Omrani and Gautier Viaud and Céline Hudelot and Pierre Colombo},
year={2024},
eprint={2407.01449},
archivePrefix={arXiv},
primaryClass={cs.IR},
url={https://arxiv.org/abs/2407.01449},
}