🚀 視覺文檔檢索模型ReT
ReT是一種用於多模態文檔檢索的創新方法,支持多模態查詢和文檔。它突破了現有方法僅利用視覺和語言主幹網絡最後一層特徵的侷限,採用基於Transformer的循環單元,充分利用視覺和文本主幹網絡不同層的多級表示。該模型受LSTM設計啟發,配備了Sigmoid門,可選擇性地控制層與模態之間的信息流。ReT獨立處理多模態查詢和文檔,生成用於細粒度後期交互相似度計算的潛在令牌集,能夠同時處理查詢和文檔中的圖像與文本。
🚀 快速開始
安裝環境
按照倉庫中的說明安裝所需環境。
使用示例
from src.models import RetrieverModel, RetModel
import torch
device = 'cuda' if torch.cuda.is_available() else 'cpu'
retriever = RetrieverModel.from_pretrained('aimagelab/ReT-CLIP-ViT-L-14', device_map=device)
ret: RetModel = retriever.get_query_model()
ret.init_tokenizer_and_image_processor()
q_txt = "Retrieve documents that provide an answer to the question alongside the image: What is the content of the image?"
q_img = 'assets/model.png'
ret_feats = ret.get_ret_features([[q_txt, q_img]])
print(ret_feats.shape)
ret: RetModel = retriever.get_passage_model()
ret.init_tokenizer_and_image_processor()
p_txt = """The image shows a diagram of what appears to be a neural network architecture using a fine-grained loss approach for multimodal learning.
The architecture has two parallel processing streams labeled "ReTQ" (left side, in purple) and "ReTD" (right side, in blue).
Each side has: ..."""
p_img = ''
ret_feats = ret.get_ret_features([[p_txt, p_img]])
print(ret_feats.shape)
✨ 主要特性
- 多模態支持:支持多模態查詢和文檔,能夠同時處理圖像和文本。
- 多級特徵利用:採用Transformer-based循環單元,利用視覺和文本主幹網絡不同層的多級表示。
- 信息流動控制:受LSTM設計啟發的Sigmoid門,可選擇性地控制層與模態之間的信息流。
- 細粒度交互:獨立處理多模態查詢和文檔,生成潛在令牌集用於細粒度後期交互相似度計算。
📚 詳細文檔
模型來源
訓練與評估
該模型在具有挑戰性的M2KR基準測試的自定義版本上進行了訓練和評估,具體修改如下:排除了不包含圖像的MSMARCO,併為OVEN、InfoSeek、E-VQA和OKVQA的文檔添加了圖像。
📄 許可證
本項目採用Apache-2.0許可證。
📝 引用
如果您在研究中使用了該模型,請使用以下BibTeX引用:
@inproceedings{caffagni2025recurrence,
title={{Recurrence-Enhanced Vision-and-Language Transformers for Robust Multimodal Document Retrieval}},
author={Caffagni, Davide and Sarto, Sara and Cornia, Marcella and Baraldi, Lorenzo and Cucchiara, Rita},
booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
year={2025}
}