openbmb / VisRAG-Ret

huggingface.co
Total runs: 4.8K
24-hour runs: 0
7-day runs: -592
30-day runs: 2.7K
Model's Last Updated: November 04 2024
feature-extraction

Introduction of VisRAG-Ret

Model Details of VisRAG-Ret

VisRAG: Vision-based Retrieval-augmented Generation on Multi-modality Documents

VisRAG is a novel vision-language model (VLM)-based RAG pipeline. In this pipeline, instead of first parsing the document to obtain text, the document is directly embedded using a VLM as an image and then retrieved to enhance the generation of a VLM.Compared to traditional text-based RAG, VisRAG maximizes the retention and utilization of the data information in the original documents, eliminating the information loss introduced during the parsing process.

VisRAG Pipeline
VisRAG-Ret

VisRAG-Ret is a document embedding model built on MiniCPM-V 2.0 , a vision-language model that integrates SigLIP as the vision encoder and MiniCPM-2B as the language model.

VisRAG-Gen

In the paper, We use MiniCPM-V 2.0, MiniCPM-V 2.6 and GPT-4o as the generators. Actually you can use any VLMs you like!

Training
VisRAG-Ret

Our training dataset of 362,110 Query-Document (Q-D) Pairs for VisRAG-Ret is comprised of train sets of openly available academic datasets (34%) and a synthetic dataset made up of pages from web-crawled PDF documents and augmented with VLM-generated (GPT-4o) pseudo-queries (66%).

VisRAG-Gen

The generation part does not use any fine-tuning; we directly use off-the-shelf LLMs/VLMs for generation.

Requirements
torch==2.1.2
torchvision==0.16.2
transformers==4.40.2
sentencepiece==0.1.99
decord==0.6.0
Pillow==10.1.0
accelerate==0.27.0
deepspeed==0.13.2
protobuf==4.25.0
pytrec_eval==0.5
Usage
VisRAG-Ret
from transformers import AutoModel, AutoTokenizer
import torch
import torch.nn.functional as F
from PIL import Image
import os

def weighted_mean_pooling(hidden, attention_mask):
    attention_mask_ = attention_mask * attention_mask.cumsum(dim=1)
    s = torch.sum(hidden * attention_mask_.unsqueeze(-1).float(), dim=1)
    d = attention_mask_.sum(dim=1, keepdim=True).float()
    reps = s / d
    return reps

@torch.no_grad()
def encode(text_or_image_list):
    
    if (isinstance(text_or_image_list[0], str)):
        inputs = {
            "text": text_or_image_list,
            'image': [None] * len(text_or_image_list),
            'tokenizer': tokenizer
        }
    else:
        inputs = {
            "text": [''] * len(text_or_image_list),
            'image': text_or_image_list,
            'tokenizer': tokenizer
        }
    outputs = model(**inputs)
    attention_mask = outputs.attention_mask
    hidden = outputs.last_hidden_state

    reps = weighted_mean_pooling(hidden, attention_mask)   
    embeddings = F.normalize(reps, p=2, dim=1).detach().cpu().numpy()
    return embeddings

tokenizer = AutoTokenizer.from_pretrained("openbmb/VisRAG-Ret", trust_remote_code=True)
model = AutoModel.from_pretrained("openbmb/VisRAG-Ret", torch_dtype=torch.bfloat16, trust_remote_code=True)
model.eval()

script_dir = os.path.dirname(os.path.realpath(__file__))
queries = ["What does a dog look like?"]
passages = [
    Image.open(os.path.join(script_dir, 'test_image/cat.jpeg')).convert('RGB'),
    Image.open(os.path.join(script_dir, 'test_image/dog.jpg')).convert('RGB'),
]

INSTRUCTION = "Represent this query for retrieving relevant documents: "
queries = [INSTRUCTION + query for query in queries]

embeddings_query = encode(queries)
embeddings_doc = encode(passages)

scores = (embeddings_query @ embeddings_doc.T)
print(scores.tolist())
License
  • The code in this repo is released under the Apache-2.0 License.
  • The usage of VisRAG-Ret model weights must strictly follow MiniCPM Model License.md .
  • The models and weights of VisRAG-Ret are completely free for academic research. After filling out a "questionnaire" for registration, VisRAG-Ret weights are also available for free commercial use.
Contact

Runs of openbmb VisRAG-Ret on huggingface.co

4.8K
Total runs
0
24-hour runs
0
3-day runs
-592
7-day runs
2.7K
30-day runs

More Information About VisRAG-Ret huggingface.co Model

More VisRAG-Ret license Visit here:

https://choosealicense.com/licenses/apache-2.0

VisRAG-Ret huggingface.co

VisRAG-Ret huggingface.co is an AI model on huggingface.co that provides VisRAG-Ret's model effect (), which can be used instantly with this openbmb VisRAG-Ret model. huggingface.co supports a free trial of the VisRAG-Ret model, and also provides paid use of the VisRAG-Ret. Support call VisRAG-Ret model through api, including Node.js, Python, http.

VisRAG-Ret huggingface.co Url

https://huggingface.co/openbmb/VisRAG-Ret

openbmb VisRAG-Ret online free

VisRAG-Ret huggingface.co is an online trial and call api platform, which integrates VisRAG-Ret's modeling effects, including api services, and provides a free online trial of VisRAG-Ret, you can try VisRAG-Ret online for free by clicking the link below.

openbmb VisRAG-Ret online free url in huggingface.co:

https://huggingface.co/openbmb/VisRAG-Ret

VisRAG-Ret install

VisRAG-Ret is an open source model from GitHub that offers a free installation service, and any user can find VisRAG-Ret on GitHub to install. At the same time, huggingface.co provides the effect of VisRAG-Ret install, users can directly use VisRAG-Ret installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

VisRAG-Ret install url in huggingface.co:

https://huggingface.co/openbmb/VisRAG-Ret

Url of VisRAG-Ret

VisRAG-Ret huggingface.co Url

Provider of VisRAG-Ret huggingface.co

openbmb
ORGANIZATIONS

Other API from openbmb

huggingface.co

Total runs: 200.2K
Run Growth: 91.4K
Growth Rate: 45.63%
Updated:October 05 2025
huggingface.co

Total runs: 134.8K
Run Growth: -3.0K
Growth Rate: -2.19%
Updated:March 10 2026
huggingface.co

Total runs: 117.8K
Run Growth: 4.9K
Growth Rate: 4.17%
Updated:September 15 2025
huggingface.co

Total runs: 112.2K
Run Growth: 89.6K
Growth Rate: 79.87%
Updated:May 10 2026
huggingface.co

Total runs: 106.9K
Run Growth: -45.2K
Growth Rate: -42.32%
Updated:June 13 2025
huggingface.co

Total runs: 25.5K
Run Growth: 411
Growth Rate: 1.61%
Updated:October 24 2025
huggingface.co

Total runs: 20.0K
Run Growth: 1.8K
Growth Rate: 8.78%
Updated:October 24 2025
huggingface.co

Total runs: 19.9K
Run Growth: 406
Growth Rate: 2.04%
Updated:January 15 2025
huggingface.co

Total runs: 13.1K
Run Growth: 8.4K
Growth Rate: 64.02%
Updated:June 02 2023
huggingface.co

Total runs: 11.5K
Run Growth: 10.4K
Growth Rate: 90.57%
Updated:May 07 2026
huggingface.co

Total runs: 7.7K
Run Growth: -4.1K
Growth Rate: -52.99%
Updated:February 27 2025
huggingface.co

Total runs: 6.5K
Run Growth: 523
Growth Rate: 8.06%
Updated:January 14 2026
huggingface.co

Total runs: 5.4K
Run Growth: 5.4K
Growth Rate: 99.14%
Updated:June 10 2025
huggingface.co

Total runs: 5.2K
Run Growth: 3.7K
Growth Rate: 70.38%
Updated:October 20 2025
huggingface.co

Total runs: 1.7K
Run Growth: 1.7K
Growth Rate: 96.08%
Updated:August 12 2023
huggingface.co

Total runs: 1.4K
Run Growth: 79
Growth Rate: 5.80%
Updated:January 15 2025
huggingface.co

Total runs: 1.0K
Run Growth: 153
Growth Rate: 14.93%
Updated:September 19 2025
huggingface.co

Total runs: 891
Run Growth: 76
Growth Rate: 8.53%
Updated:June 27 2023
huggingface.co

Total runs: 847
Run Growth: 48
Growth Rate: 5.67%
Updated:August 24 2023
huggingface.co

Total runs: 436
Run Growth: 372
Growth Rate: 85.32%
Updated:February 12 2026
huggingface.co

Total runs: 416
Run Growth: -75
Growth Rate: -18.03%
Updated:October 14 2023
huggingface.co

Total runs: 373
Run Growth: 203
Growth Rate: 55.92%
Updated:June 14 2025
huggingface.co

Total runs: 351
Run Growth: -108
Growth Rate: -32.93%
Updated:May 14 2024
huggingface.co

Total runs: 187
Run Growth: 104
Growth Rate: 55.61%
Updated:February 21 2024
huggingface.co

Total runs: 179
Run Growth: 112
Growth Rate: 62.57%
Updated:October 14 2025
huggingface.co

Total runs: 169
Run Growth: -1.4K
Growth Rate: -847.59%
Updated:April 08 2024
huggingface.co

Total runs: 154
Run Growth: 24
Growth Rate: 15.58%
Updated:February 21 2024
huggingface.co

Total runs: 148
Run Growth: 19
Growth Rate: 12.84%
Updated:April 16 2024
huggingface.co

Total runs: 139
Run Growth: 72
Growth Rate: 51.80%
Updated:February 21 2024
huggingface.co

Total runs: 134
Run Growth: 91
Growth Rate: 67.91%
Updated:June 11 2025
huggingface.co

Total runs: 133
Run Growth: 62
Growth Rate: 46.62%
Updated:February 21 2024