🚀 ColSmolVLM-v0.1:基於SmolVLM-Instruct和ColBERT策略的視覺檢索器
ColSmolVLM是一種基於視覺語言模型(VLMs)的新型模型架構和訓練策略,可從文檔的視覺特徵中高效索引文檔。它是SmolVLM的擴展,能夠生成ColBERT風格的文本和圖像多向量表示。該模型在論文ColPali: Efficient Document Retrieval with Vision Language Models中被提出,並首次在此倉庫中發佈。此版本是未經過訓練的基礎版本,以確保投影層初始化的確定性。
模型信息
屬性 |
詳情 |
基礎模型 |
vidore/ColSmolVLM-base |
庫名稱 |
peft |
標籤 |
vidore-experimental、vidore |
任務類型 |
視覺文檔檢索 |
版本說明
此版本是使用batch_size
為128,訓練3個epoch得到的。它使用colpali-engine==0.3.5
(倉庫主分支)進行訓練,數據與論文中描述的ColPali數據相同。
🚀 快速開始
模型訓練
數據集
我們的訓練數據集包含127,460個查詢 - 頁面對,由公開可用的學術數據集的訓練集(63%)和一個合成數據集組成。合成數據集由網絡爬取的PDF文檔頁面構成,並使用VLM生成(Claude - 3 Sonnet)的偽問題進行增強(37%)。我們的訓練集設計為全英文,以便研究對非英語語言的零樣本泛化能力。我們明確驗證了沒有多頁PDF文檔同時用於ViDoRe和訓練集,以防止評估汙染。我們使用2%的樣本創建了一個驗證集來調整超參數。
注意:多語言數據存在於語言模型的預訓練語料庫中,並且很可能存在於多模態訓練中。
參數
除非另有說明,我們以bfloat16
格式訓練模型,在語言模型的Transformer層以及最終隨機初始化的投影層上使用低秩適配器(LoRA),其中alpha = 32
,r = 32
,並使用paged_adamw_8bit
優化器。我們在4個GPU上進行數據並行訓練,學習率為5e - 4,採用線性衰減,熱身步驟為2.5%,批量大小為32。
安裝指南
確保從源代碼安裝colpali-engine
或使用版本高於0.3.5(當前倉庫主分支)的版本,transformers
版本必須 > 4.46.2。
pip install git+https://github.com/illuin-tech/colpali
💻 使用示例
基礎用法
import torch
from PIL import Image
from colpali_engine.models import ColIdefics3, ColIdefics3Processor
model = ColIdefics3.from_pretrained(
"vidore/colsmolvlm-v0.1",
torch_dtype=torch.bfloat16,
device_map="cuda:0",
attn_implementation="flash_attention_2"
).eval()
processor = ColIdefics3Processor.from_pretrained("vidore/colsmolvlm-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)
侷限性
⚠️ 重要提示
- 專注領域:該模型主要專注於PDF類型的文檔和資源豐富的語言,可能限制其對其他文檔類型或代表性不足的語言的泛化能力。
- 支持情況:該模型依賴於從ColBERT後期交互機制派生的多向量檢索,可能需要工程努力才能適應缺乏原生多向量支持的廣泛使用的向量檢索框架。
許可證
ColQwen2的視覺語言主幹模型(Qwen2 - VL)遵循apache2.0
許可證。附加到模型的適配器遵循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},
}
