File size: 7,716 Bytes
8ce4d25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
be59b6e
 
 
8ce4d25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
be59b6e
 
 
 
8ce4d25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
schema pdf_page {
    document pdf_page {
        field id type string {
            indexing: summary | index
            match {
                word
            }
        }
        field url type string {
            indexing: summary | index
        }
        field title type string {
            indexing: summary | index
            index: enable-bm25
            match {
                text
            }
        }
        field page_number type int {
            indexing: summary | attribute
        }
        field image type raw {
            indexing: summary
        }
        field full_image type raw {
            indexing: summary
        }
        field text type string {
            indexing: summary | index
            index: enable-bm25
            match {
                text
            }
        }
        field embedding type tensor<int8>(patch{}, v[16]) {
            indexing: attribute | index
            attribute {
                distance-metric: hamming
            }
            index {
                hnsw {
                    max-links-per-node: 32
                    neighbors-to-explore-at-insert: 400
                }
            }
        }
    }
    fieldset default {
        fields: title, url, page_number, text
    }
    fieldset image {
        fields: image
    }
    rank-profile default {
        inputs {
            query(qt) tensor<float>(querytoken{}, v[128])             
        
        }
        function max_sim() {
            expression {
                
                                    sum(
                                        reduce(
                                            sum(
                                                query(qt) * unpack_bits(attribute(embedding)) , v
                                            ),
                                            max, patch
                                        ),
                                        querytoken
                                    )
                                
            }
        }
        function bm25_score() {
            expression {
                bm25(title) + bm25(text)
            }
        }
        first-phase {
            expression {
                bm25_score
            }
        }
        second-phase {
            rerank-count: 10
            expression {
                max_sim
            }
        }
    }
    rank-profile retrieval-and-rerank {
        inputs {
            query(rq0) tensor<int8>(v[16])             
            query(rq1) tensor<int8>(v[16])             
            query(rq2) tensor<int8>(v[16])             
            query(rq3) tensor<int8>(v[16])             
            query(rq4) tensor<int8>(v[16])             
            query(rq5) tensor<int8>(v[16])             
            query(rq6) tensor<int8>(v[16])             
            query(rq7) tensor<int8>(v[16])             
            query(rq8) tensor<int8>(v[16])             
            query(rq9) tensor<int8>(v[16])             
            query(rq10) tensor<int8>(v[16])             
            query(rq11) tensor<int8>(v[16])             
            query(rq12) tensor<int8>(v[16])             
            query(rq13) tensor<int8>(v[16])             
            query(rq14) tensor<int8>(v[16])             
            query(rq15) tensor<int8>(v[16])             
            query(rq16) tensor<int8>(v[16])             
            query(rq17) tensor<int8>(v[16])             
            query(rq18) tensor<int8>(v[16])             
            query(rq19) tensor<int8>(v[16])             
            query(rq20) tensor<int8>(v[16])             
            query(rq21) tensor<int8>(v[16])             
            query(rq22) tensor<int8>(v[16])             
            query(rq23) tensor<int8>(v[16])             
            query(rq24) tensor<int8>(v[16])             
            query(rq25) tensor<int8>(v[16])             
            query(rq26) tensor<int8>(v[16])             
            query(rq27) tensor<int8>(v[16])             
            query(rq28) tensor<int8>(v[16])             
            query(rq29) tensor<int8>(v[16])             
            query(rq30) tensor<int8>(v[16])             
            query(rq31) tensor<int8>(v[16])             
            query(rq32) tensor<int8>(v[16])             
            query(rq33) tensor<int8>(v[16])             
            query(rq34) tensor<int8>(v[16])             
            query(rq35) tensor<int8>(v[16])             
            query(rq36) tensor<int8>(v[16])             
            query(rq37) tensor<int8>(v[16])             
            query(rq38) tensor<int8>(v[16])             
            query(rq39) tensor<int8>(v[16])             
            query(rq40) tensor<int8>(v[16])             
            query(rq41) tensor<int8>(v[16])             
            query(rq42) tensor<int8>(v[16])             
            query(rq43) tensor<int8>(v[16])             
            query(rq44) tensor<int8>(v[16])             
            query(rq45) tensor<int8>(v[16])             
            query(rq46) tensor<int8>(v[16])             
            query(rq47) tensor<int8>(v[16])             
            query(rq48) tensor<int8>(v[16])             
            query(rq49) tensor<int8>(v[16])             
            query(rq50) tensor<int8>(v[16])             
            query(rq51) tensor<int8>(v[16])             
            query(rq52) tensor<int8>(v[16])             
            query(rq53) tensor<int8>(v[16])             
            query(rq54) tensor<int8>(v[16])             
            query(rq55) tensor<int8>(v[16])             
            query(rq56) tensor<int8>(v[16])             
            query(rq57) tensor<int8>(v[16])             
            query(rq58) tensor<int8>(v[16])             
            query(rq59) tensor<int8>(v[16])             
            query(rq60) tensor<int8>(v[16])             
            query(rq61) tensor<int8>(v[16])             
            query(rq62) tensor<int8>(v[16])             
            query(rq63) tensor<int8>(v[16])             
            query(qt) tensor<float>(querytoken{}, v[128])             
            query(qtb) tensor<int8>(querytoken{}, v[16])             
        
        }
        function max_sim() {
            expression {
                
                                    sum(
                                        reduce(
                                            sum(
                                                query(qt) * unpack_bits(attribute(embedding)) , v
                                            ),
                                            max, patch
                                        ),
                                        querytoken
                                    )
                                
            }
        }
        function max_sim_binary() {
            expression {
                
                                    sum(
                                      reduce(
                                        1/(1 + sum(
                                            hamming(query(qtb), attribute(embedding)) ,v)
                                        ),
                                        max,
                                        patch
                                      ),
                                      querytoken
                                    )
                                
            }
        }
        first-phase {
            expression {
                max_sim_binary
            }
        }
        second-phase {
            rerank-count: 10
            expression {
                max_sim
            }
        }
    }
}