🚀 ColQwen2.5:基於Qwen2.5-VL-3B-Instruct和ColBERT策略的視覺檢索器
ColQwen是一個基於視覺語言模型(VLM)的新型模型架構和訓練策略的模型,可根據文檔的視覺特徵對其進行高效索引。它是Qwen2.5-VL-3B的擴展,能夠生成文本和圖像的ColBERT風格多向量表示。該模型在論文ColPali: Efficient Document Retrieval with Vision Language Models中被提出,並首次在此倉庫中發佈。

✨ 主要特性
- 該模型接受動態圖像分辨率作為輸入,且不會像ColPali那樣改變圖像的縱橫比進行調整。最大分辨率設置為最多創建768個圖像塊。實驗表明,增加圖像塊數量可顯著提升性能,但會增加內存需求。
- 此版本使用
colpali-engine==0.3.7
進行訓練。
- 訓練數據與論文中描述的ColPali數據相同。
📦 安裝指南
確保從源代碼安裝colpali-engine
,或者使用版本高於0.3.1的colpali-engine
。同時,transformers
版本必須大於4.45.0。
pip install git+https://github.com/illuin-tech/colpali
💻 使用示例
基礎用法
import torch
from PIL import Image
from transformers.utils.import_utils import is_flash_attn_2_available
from colpali_engine.models import ColQwen2_5, ColQwen2_5_Processor
model = ColQwen2_5.from_pretrained(
"vidore/colqwen2.5-v0.1",
torch_dtype=torch.bfloat16,
device_map="cuda:0",
attn_implementation="flash_attention_2" if is_flash_attn_2_available() else None,
).eval()
processor = ColQwen2_5_Processor.from_pretrained("vidore/colqwen2.5-v0.1")
images = [
Image.new("RGB", (32, 32), color="white"),
Image.new("RGB", (16, 16), color="black"),
]
queries = [
"Is attention really all you need?",
"What is the amount of bananas farmed in Salvador?",
]
batch_images = processor.process_images(images).to(model.device)
batch_queries = processor.process_queries(queries).to(model.device)
with torch.no_grad():
image_embeddings = model(**batch_images)
query_embeddings = model(**batch_queries)
scores = processor.score_multi_vector(query_embeddings, image_embeddings)
📚 詳細文檔
數據集
我們的訓練數據集包含127,460個查詢 - 頁面配對,由公開可用的學術數據集的訓練集(63%)和一個合成數據集組成。合成數據集由網絡爬取的PDF文檔頁面構成,並使用VLM生成(Claude-3 Sonnet)的偽問題進行擴充(37%)。我們的訓練集設計為全英文,以便研究對非英語語言的零樣本泛化能力。我們明確驗證了沒有多頁PDF文檔同時用於ViDoRe和訓練集,以防止評估汙染。我們使用2%的樣本創建了一個驗證集來調整超參數。
注意:多語言數據存在於語言模型的預訓練語料庫中,並且很可能存在於多模態訓練中。
參數
所有模型在訓練集上訓練1個epoch。除非另有說明,我們以bfloat16
格式訓練模型,在語言模型的Transformer層以及最終隨機初始化的投影層上使用低秩適配器(LoRA),其中alpha=32
且r=32
,並使用paged_adamw_8bit
優化器。我們在8個GPU上使用數據並行進行訓練,學習率為5e-5,採用線性衰減,熱身步驟為2.5%,批量大小為32。
🔧 技術細節
- 聚焦範圍:該模型主要聚焦於PDF類型的文檔和資源豐富的語言,這可能限制其對其他文檔類型或資源較少語言的泛化能力。
- 支持情況:該模型依賴於從ColBERT後期交互機制派生的多向量檢索,可能需要進行工程化工作才能適應缺乏原生多向量支持的廣泛使用的向量檢索框架。
📄 許可證
ColQwen2.5的視覺語言主幹模型(Qwen2.5-VL)遵循Qwen RESEARCH LICENSE AGREEMENT
許可協議。附加到模型上的適配器遵循MIT許可協議。
📞 聯繫方式
- Manuel Faysse: manuel.faysse@illuin.tech
- Hugues Sibille: hugues.sibille@illuin.tech
- Tony Wu: tony.wu@illuin.tech
📖 引用
如果您在研究中使用了本組織的任何數據集或模型,請按以下方式引用原始數據集:
@misc{faysse2024colpaliefficientdocumentretrieval,
title={ColPali: Efficient Document Retrieval with Vision Language Models},
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},
}