Safetensors
daviddongdong commited on
Commit
0a463e4
·
verified ·
1 Parent(s): 751560b

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +62 -0
README.md CHANGED
@@ -48,6 +48,68 @@ colbert-ai==0.2.21 # for colbert retriever
48
  flash-attn==2.7.4.post1 # for DSE retrievers to run with flash attention
49
  ```
50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
 
52
  ## 💾Citation
53
  If you use any datasets or models from this organization in your research, please cite our work as follows:
 
48
  flash-attn==2.7.4.post1 # for DSE retrievers to run with flash attention
49
  ```
50
 
51
+ ## How to use these checkpoints
52
+
53
+ We standardize codes for all retrievers in two python files
54
+
55
+ - **For text retrievers**: refer to [`text_wrapper.py`](https://huggingface.co/MMDocIR/MMDocIR_Retrievers/blob/main/text_wrapper.py)
56
+ - **For vision retrievers**: refer to [`vision_wrapper.py`](https://huggingface.co/MMDocIR/MMDocIR_Retrievers/blob/main/vision_wrapper.py)
57
+
58
+ If you want to encode [MMDocIR_Evaluation_Dataset](https://huggingface.co/datasets/MMDocIR/MMDocIR_Evaluation_Dataset) with these retrievers, you can refer to code [MMDocIR](https://github.com/MMDocRAG/MMDocIR/tree/main)/[encode.py](https://github.com/MMDocRAG/MMDocIR/blob/main/encode.py) and [inference command](https://github.com/MMDocRAG/MMDocIR?tab=readme-ov-file#3-inference-command).
59
+
60
+ If you want to encode your own queries/pages/layouts with these retrievers, some simple demo codes are:
61
+
62
+ - **For text retrievers**:
63
+
64
+ ```python
65
+ From text_wrapper import DPR, BGE, GTE, E5, ColBERTReranker, Contriever
66
+
67
+ retriever = E5()
68
+ query = ['how much protein should a child consume', 'What is the CDC requirements for women?']
69
+ passage = [
70
+ "As a general guideline, the CDC's average requirement of protein for women ages 19 to 70 is 46 grams per day. But, as you can see from this chart, you'll need to increase that if you're expecting or training for a marathon. Check out the chart below to see how much protein you should be eating each day.",
71
+ "Definition of summit for English Language Learners. : 1 the highest point of a mountain : the top of a mountain. : 2 the highest level. : 3 a meeting or series of meetings between the leaders of two or more governments.",
72
+ "Definition of summit for English Language Learners. : 1 the highest point of a mountain : the top of a mountain. : 2 the highest level. : 3 a meeting or series of meetings between the leaders of two or more governments."
73
+ ]
74
+ query_embeds = retriever.embed_queries(query)
75
+ passage_embeds = retriever.embed_quotes(passage)
76
+ scores = retriever.score(query, passage)
77
+ print(scores)
78
+ ```
79
+
80
+ - **For image retrievers**:
81
+
82
+ ```python
83
+ From vision_wrapper import DSE, ColQwen2Retriever, ColPaliRetriever
84
+
85
+ retriever = DSE(model_name="checkpoint/dse-phi3-v1", bs=2)
86
+
87
+ query = ['how much protein should a child consume', 'What is the CDC requirements for women?']
88
+ prefix = "/home/user/xxx"
89
+ images = [
90
+ "0704.0418_1.jpg",
91
+ "0704.0418_2.jpg",
92
+ "0704.0418_3.jpg",
93
+ "0705.1104_0.jpg",
94
+ "0705.1104_1.jpg",
95
+ "0705.1104_2.jpg",
96
+ "0704.0418_1.jpg",
97
+ "0704.0418_2.jpg",
98
+ "0704.0418_3.jpg",
99
+ "0705.1104_0.jpg",
100
+ "0705.1104_1.jpg",
101
+ "0705.1104_2.jpg",
102
+ ]
103
+ images = [Image.open(prefix+x) for x in images]
104
+ q_embeds = retriever.embed_queries(queries)
105
+ img_embeds = retriever.embed_quotes(images)
106
+
107
+ scores = retriever.score(q_embeds, img_embeds)
108
+ print(scores)
109
+ ```
110
+
111
+
112
+
113
 
114
  ## 💾Citation
115
  If you use any datasets or models from this organization in your research, please cite our work as follows: