Update README.md
Browse files
README.md
CHANGED
@@ -3,20 +3,22 @@ language:
|
|
3 |
- en
|
4 |
license: mit
|
5 |
library_name: Tevatron
|
|
|
|
|
6 |
datasets:
|
7 |
- Tevatron/docmatix-ir
|
8 |
- HuggingFaceM4/Docmatix
|
9 |
- Tevatron/msmarco-passage-aug
|
10 |
---
|
11 |
|
12 |
-
# DSE-Phi3-Docmatix-
|
13 |
|
14 |
-
DSE-Phi3-Docmatix-
|
15 |
|
16 |
-
The model, `Tevatron/dse-phi3-docmatix-
|
17 |
|
18 |
DSE has strong zero-shot effectiveness for document retrieval both with visual input and text input.
|
19 |
-
For example, DSE-Phi3-Docmatix-
|
20 |
|
21 |
|
22 |
## How to Use the Model
|
@@ -27,8 +29,8 @@ For example, DSE-Phi3-Docmatix-V1 achieves 74.1 nDCG@5 on [ViDoRE](https://huggi
|
|
27 |
import torch
|
28 |
from transformers import AutoProcessor, AutoModelForCausalLM
|
29 |
|
30 |
-
processor = AutoProcessor.from_pretrained('Tevatron/dse-phi3-docmatix-
|
31 |
-
model = AutoModelForCausalLM.from_pretrained('Tevatron/dse-phi3-docmatix-
|
32 |
|
33 |
def get_embedding(last_hidden_state: torch.Tensor, attention_mask: torch.Tensor) -> torch.Tensor:
|
34 |
sequence_lengths = attention_mask.sum(dim=1) - 1
|
@@ -56,15 +58,15 @@ import requests
|
|
56 |
from io import BytesIO
|
57 |
|
58 |
# URLs of the images
|
59 |
-
url1 = "https://huggingface.co/Tevatron/dse-phi3-docmatix-
|
60 |
-
url2 = "https://huggingface.co/Tevatron/dse-phi3-docmatix-
|
61 |
|
62 |
# Download and open images
|
63 |
response1 = requests.get(url1)
|
64 |
response2 = requests.get(url2)
|
65 |
|
66 |
-
passage_image1 = Image.open(BytesIO(response1.content))
|
67 |
-
passage_image2 = Image.open(BytesIO(response2.content))
|
68 |
|
69 |
passage_images = [passage_image1, passage_image2]
|
70 |
passage_prompts = ["<|image_1|>\nWhat is shown in this image?</s>", "<|image_2|>\nWhat is shown in this image?</s>"]
|
|
|
3 |
- en
|
4 |
license: mit
|
5 |
library_name: Tevatron
|
6 |
+
tag:
|
7 |
+
- vidore
|
8 |
datasets:
|
9 |
- Tevatron/docmatix-ir
|
10 |
- HuggingFaceM4/Docmatix
|
11 |
- Tevatron/msmarco-passage-aug
|
12 |
---
|
13 |
|
14 |
+
# DSE-Phi3-Docmatix-V2
|
15 |
|
16 |
+
DSE-Phi3-Docmatix-V2 is a bi-encoder model designed to encode document screenshots into dense vectors for document retrieval. The Document Screenshot Embedding ([DSE](https://arxiv.org/abs/2406.11251)) approach captures documents in their original visual format, preserving all information such as text, images, and layout, thus avoiding tedious parsing and potential information loss.
|
17 |
|
18 |
+
The model, `Tevatron/dse-phi3-docmatix-v2`, is trained using 1/10 of the `Tevatron/docmatix-ir` dataset, a variant of `HuggingFaceM4/Docmatix` specifically adapted for training PDF retrievers with Vision Language Models in open-domain question answering scenarios. For more information on dataset filtering and hard negative mining, refer to the [docmatix-ir](https://huggingface.co/datasets/Tevatron/docmatix-ir/blob/main/README.md) dataset page.
|
19 |
|
20 |
DSE has strong zero-shot effectiveness for document retrieval both with visual input and text input.
|
21 |
+
For example, DSE-Phi3-Docmatix-V2 achieves 77.6 nDCG@5 on [ViDoRE](https://huggingface.co/spaces/vidore/vidore-leaderboard) leaderboard in **zero-shot setting** (without finetuning with ViDoRe training data).
|
22 |
|
23 |
|
24 |
## How to Use the Model
|
|
|
29 |
import torch
|
30 |
from transformers import AutoProcessor, AutoModelForCausalLM
|
31 |
|
32 |
+
processor = AutoProcessor.from_pretrained('Tevatron/dse-phi3-docmatix-v2', trust_remote_code=True)
|
33 |
+
model = AutoModelForCausalLM.from_pretrained('Tevatron/dse-phi3-docmatix-v2', trust_remote_code=True, attn_implementation="flash_attention_2", torch_dtype=torch.bfloat16, use_cache=False).to('cuda:0')
|
34 |
|
35 |
def get_embedding(last_hidden_state: torch.Tensor, attention_mask: torch.Tensor) -> torch.Tensor:
|
36 |
sequence_lengths = attention_mask.sum(dim=1) - 1
|
|
|
58 |
from io import BytesIO
|
59 |
|
60 |
# URLs of the images
|
61 |
+
url1 = "https://huggingface.co/Tevatron/dse-phi3-docmatix-v2/resolve/main/animal-llama.png"
|
62 |
+
url2 = "https://huggingface.co/Tevatron/dse-phi3-docmatix-v2/resolve/main/meta-llama.png"
|
63 |
|
64 |
# Download and open images
|
65 |
response1 = requests.get(url1)
|
66 |
response2 = requests.get(url2)
|
67 |
|
68 |
+
passage_image1 = Image.open(BytesIO(response1.content)).resize((1344, 1344))
|
69 |
+
passage_image2 = Image.open(BytesIO(response2.content)).resize((1344, 1344))
|
70 |
|
71 |
passage_images = [passage_image1, passage_image2]
|
72 |
passage_prompts = ["<|image_1|>\nWhat is shown in this image?</s>", "<|image_2|>\nWhat is shown in this image?</s>"]
|