Philipp Hager commited on
Commit
0fe6ceb
2 Parent(s): 143443d a206038

Merge branch 'main' of hf.co:datasets/philipphager/baidu-ultr_baidu-mlm-ctr

Browse files
Files changed (2) hide show
  1. README.md +44 -11
  2. baidu-ultr_baidu-mlm-ctr.py +78 -8
README.md CHANGED
@@ -50,16 +50,32 @@ Each row of the click / annotation dataset contains the following attributes. Us
50
  |------------------------------|----------------|-------------|
51
  | query_id | string | Baidu query_id |
52
  | query_md5 | string | MD5 hash of query text |
53
- | url_md5 | List[string] | MD5 hash of document url, most reliable document identifier |
 
 
 
54
  | text_md5 | List[string] | MD5 hash of document title and abstract |
55
- | query_document_embedding | Tensor[float16]| BERT CLS token |
 
 
56
  | click | Tensor[int32] | Click / no click on a document |
57
- | n | int32 | Number of documents for current query, useful for padding |
58
  | position | Tensor[int32] | Position in ranking (does not always match original item position) |
59
- | media_type | Tensor[int32] | Document type (label encoding recommended as ids do not occupy a continous integer range) |
60
- | displayed_time | Tensor[float32]| Seconds a document was displayed on screen |
61
- | serp_height | Tensor[int32] | Pixel height of a document on screen |
62
- | slipoff_count_after_click | Tensor[int32] | Number of times a document was scrolled off screen after previously clicking on it |
 
 
 
 
 
 
 
 
 
 
 
 
63
 
64
 
65
  ### Expert annotation dataset
@@ -67,11 +83,28 @@ Each row of the click / annotation dataset contains the following attributes. Us
67
  |------------------------------|----------------|-------------|
68
  | query_id | string | Baidu query_id |
69
  | query_md5 | string | MD5 hash of query text |
70
- | text_md5 | List[string] | MD5 hash of document title and abstract |
71
- | query_document_embedding | Tensor[float16]| BERT CLS token |
72
- | label | Tensor[int32] | Relevance judgment on a scale from 0 (bad) to 4 (excellent) |
73
- | n | int32 | Number of documents for current query, useful for padding |
74
  | frequency_bucket | int32 | Monthly frequency of query (bucket) from 0 (high frequency) to 9 (low frequency) |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
 
76
  ## Example PyTorch collate function
77
  Each sample in the dataset is a single query with multiple documents.
 
50
  |------------------------------|----------------|-------------|
51
  | query_id | string | Baidu query_id |
52
  | query_md5 | string | MD5 hash of query text |
53
+ | query | List[int32] | List of query tokens |
54
+ | query_length | int32 | Number of query tokens |
55
+ | n | int32 | Number of documents for current query, useful for padding |
56
+ | url_md5 | List[string] | MD5 hash of document URL, most reliable document identifier |
57
  | text_md5 | List[string] | MD5 hash of document title and abstract |
58
+ | title | List[List[int32]] | List of tokens for document titles |
59
+ | abstract | List[List[int32]] | List of tokens for document abstracts |
60
+ | query_document_embedding | Tensor[Tensor[float16]]| BERT CLS token |
61
  | click | Tensor[int32] | Click / no click on a document |
 
62
  | position | Tensor[int32] | Position in ranking (does not always match original item position) |
63
+ | media_type | Tensor[int32] | Document type (label encoding recommended as IDs do not occupy a continuous integer range) |
64
+ | displayed_time | Tensor[float32]| Seconds a document was displayed on the screen |
65
+ | serp_height | Tensor[int32] | Pixel height of a document on the screen |
66
+ | slipoff_count_after_click | Tensor[int32] | Number of times a document was scrolled off the screen after previously clicking on it |
67
+ | bm25 | Tensor[float32] | BM25 score for documents |
68
+ | title_bm25 | Tensor[float32] | BM25 score for document titles |
69
+ | abstract_bm25 | Tensor[float32] | BM25 score for document abstracts |
70
+ | tf_idf | Tensor[float32] | TF-IDF score for documents |
71
+ | tf | Tensor[float32] | Term frequency for documents |
72
+ | idf | Tensor[float32] | Inverse document frequency for documents |
73
+ | ql_jelinek_mercer_short | Tensor[float32] | Query likelihood score for documents using Jelinek-Mercer smoothing (alpha = 0.1) |
74
+ | ql_jelinek_mercer_long | Tensor[float32] | Query likelihood score for documents using Jelinek-Mercer smoothing (alpha = 0.7) |
75
+ | ql_dirichlet | Tensor[float32] | Query likelihood score for documents using Dirichlet smoothing (lambda = 128) |
76
+ | document_length | Tensor[int32] | Length of documents |
77
+ | title_length | Tensor[int32] | Length of document titles |
78
+ | abstract_length | Tensor[int32] | Length of document abstracts |
79
 
80
 
81
  ### Expert annotation dataset
 
83
  |------------------------------|----------------|-------------|
84
  | query_id | string | Baidu query_id |
85
  | query_md5 | string | MD5 hash of query text |
86
+ | query | List[int32] | List of query tokens |
87
+ | query_length | int32 | Number of query tokens |
 
 
88
  | frequency_bucket | int32 | Monthly frequency of query (bucket) from 0 (high frequency) to 9 (low frequency) |
89
+ | n | int32 | Number of documents for current query, useful for padding |
90
+ | url_md5 | List[string] | MD5 hash of document URL, most reliable document identifier |
91
+ | text_md5 | List[string] | MD5 hash of document title and abstract |
92
+ | title | List[List[int32]] | List of tokens for document titles |
93
+ | abstract | List[List[int32]] | List of tokens for document abstracts |
94
+ | query_document_embedding | Tensor[Tensor[float16]] | BERT CLS token |
95
+ | label | Tensor[int32] | Relevance judgments on a scale from 0 (bad) to 4 (excellent) |
96
+ | bm25 | Tensor[float32] | BM25 score for documents |
97
+ | title_bm25 | Tensor[float32] | BM25 score for document titles |
98
+ | abstract_bm25 | Tensor[float32] | BM25 score for document abstracts |
99
+ | tf_idf | Tensor[float32] | TF-IDF score for documents |
100
+ | tf | Tensor[float32] | Term frequency for documents |
101
+ | idf | Tensor[float32] | Inverse document frequency for documents |
102
+ | ql_jelinek_mercer_short | Tensor[float32] | Query likelihood score for documents using Jelinek-Mercer smoothing (alpha = 0.1) |
103
+ | ql_jelinek_mercer_long | Tensor[float32] | Query likelihood score for documents using Jelinek-Mercer smoothing (alpha = 0.7) |
104
+ | ql_dirichlet | Tensor[float32] | Query likelihood score for documents using Dirichlet smoothing (lambda = 128) |
105
+ | document_length | Tensor[int32] | Length of documents |
106
+ | title_length | Tensor[int32] | Length of document titles |
107
+ | abstract_length | Tensor[int32] | Length of document abstracts |
108
 
109
  ## Example PyTorch collate function
110
  Each sample in the dataset is a single query with multiple documents.
baidu-ultr_baidu-mlm-ctr.py CHANGED
@@ -53,30 +53,69 @@ class BaiduUltrBuilder(datasets.GeneratorBasedBuilder):
53
 
54
  CLICK_FEATURES = Features(
55
  {
 
56
  "query_id": Value("string"),
57
  "query_md5": Value("string"),
 
 
 
 
58
  "url_md5": Sequence(Value("string")),
59
  "text_md5": Sequence(Value("string")),
 
 
60
  "query_document_embedding": Array2D((None, 768), "float16"),
61
  "click": Sequence(Value("int32")),
62
- "n": Value("int32"),
63
  "position": Sequence(Value("int32")),
64
  "media_type": Sequence(Value("int32")),
65
  "displayed_time": Sequence(Value("float32")),
66
  "serp_height": Sequence(Value("int32")),
67
  "slipoff_count_after_click": Sequence(Value("int32")),
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  }
69
  )
70
 
71
  ANNOTATION_FEATURES = Features(
72
  {
 
73
  "query_id": Value("string"),
74
  "query_md5": Value("string"),
75
- "text_md5": Value("string"),
 
 
 
 
 
 
 
76
  "query_document_embedding": Array2D((None, 768), "float16"),
77
  "label": Sequence(Value("int32")),
78
- "n": Value("int32"),
79
- "frequency_bucket": Value("int32"),
 
 
 
 
 
 
 
 
 
 
 
80
  }
81
  )
82
 
@@ -108,19 +147,34 @@ class BaiduUltrBuilder(datasets.GeneratorBasedBuilder):
108
  query_columns = [
109
  "query_id",
110
  "query_md5",
 
 
111
  ]
112
 
113
  agg_columns = [
114
- "query_md5",
115
  "url_md5",
116
  "text_md5",
117
- "position",
118
- "click",
119
  "query_document_embedding",
 
 
120
  "media_type",
121
  "displayed_time",
122
  "serp_height",
123
  "slipoff_count_after_click",
 
 
 
 
 
 
 
 
 
 
 
 
124
  ]
125
 
126
  return [
@@ -146,12 +200,28 @@ class BaiduUltrBuilder(datasets.GeneratorBasedBuilder):
146
  query_columns = [
147
  "query_id",
148
  "query_md5",
 
 
149
  "frequency_bucket",
150
  ]
151
  agg_columns = [
152
  "text_md5",
153
- "label",
 
154
  "query_document_embedding",
 
 
 
 
 
 
 
 
 
 
 
 
 
155
  ]
156
 
157
  return [
 
53
 
54
  CLICK_FEATURES = Features(
55
  {
56
+ ### Query features
57
  "query_id": Value("string"),
58
  "query_md5": Value("string"),
59
+ "query": Sequence(Value("int32")),
60
+ "query_length": Value("int32"),
61
+ "n": Value("int32"),
62
+ ### Doc features
63
  "url_md5": Sequence(Value("string")),
64
  "text_md5": Sequence(Value("string")),
65
+ "title": Sequence(Sequence(Value("int32"))),
66
+ "abstract": Sequence(Sequence(Value("int32"))),
67
  "query_document_embedding": Array2D((None, 768), "float16"),
68
  "click": Sequence(Value("int32")),
69
+ ### SERP features
70
  "position": Sequence(Value("int32")),
71
  "media_type": Sequence(Value("int32")),
72
  "displayed_time": Sequence(Value("float32")),
73
  "serp_height": Sequence(Value("int32")),
74
  "slipoff_count_after_click": Sequence(Value("int32")),
75
+ ### LTR features
76
+ "bm25": Sequence(Value("float32")),
77
+ "title_bm25": Sequence(Value("float32")),
78
+ "abstract_bm25": Sequence(Value("float32")),
79
+ "tf_idf": Sequence(Value("float32")),
80
+ "tf": Sequence(Value("float32")),
81
+ "idf": Sequence(Value("float32")),
82
+ "ql_jelinek_mercer_short": Sequence(Value("float32")),
83
+ "ql_jelinek_mercer_long": Sequence(Value("float32")),
84
+ "ql_dirichlet": Sequence(Value("float32")),
85
+ "document_length": Sequence(Value("int32")),
86
+ "title_length": Sequence(Value("int32")),
87
+ "abstract_length": Sequence(Value("int32")),
88
  }
89
  )
90
 
91
  ANNOTATION_FEATURES = Features(
92
  {
93
+ ### Query features
94
  "query_id": Value("string"),
95
  "query_md5": Value("string"),
96
+ "query": Sequence(Value("int32")),
97
+ "query_length": Value("int32"),
98
+ "frequency_bucket": Value("int32"),
99
+ "n": Value("int32"),
100
+ ### Doc features
101
+ "text_md5": Sequence(Value("string")),
102
+ "title": Sequence(Sequence(Value("int32"))),
103
+ "abstract": Sequence(Sequence(Value("int32"))),
104
  "query_document_embedding": Array2D((None, 768), "float16"),
105
  "label": Sequence(Value("int32")),
106
+ ### LTR features
107
+ "bm25": Sequence(Value("float32")),
108
+ "title_bm25": Sequence(Value("float32")),
109
+ "abstract_bm25": Sequence(Value("float32")),
110
+ "tf_idf": Sequence(Value("float32")),
111
+ "tf": Sequence(Value("float32")),
112
+ "idf": Sequence(Value("float32")),
113
+ "ql_jelinek_mercer_short": Sequence(Value("float32")),
114
+ "ql_jelinek_mercer_long": Sequence(Value("float32")),
115
+ "ql_dirichlet": Sequence(Value("float32")),
116
+ "document_length": Sequence(Value("int32")),
117
+ "title_length": Sequence(Value("int32")),
118
+ "abstract_length": Sequence(Value("int32")),
119
  }
120
  )
121
 
 
147
  query_columns = [
148
  "query_id",
149
  "query_md5",
150
+ "query",
151
+ "query_length",
152
  ]
153
 
154
  agg_columns = [
 
155
  "url_md5",
156
  "text_md5",
157
+ "title",
158
+ "abstract",
159
  "query_document_embedding",
160
+ "click",
161
+ "position",
162
  "media_type",
163
  "displayed_time",
164
  "serp_height",
165
  "slipoff_count_after_click",
166
+ "bm25",
167
+ "title_bm25",
168
+ "abstract_bm25",
169
+ "tf_idf",
170
+ "tf",
171
+ "idf",
172
+ "ql_jelinek_mercer_short",
173
+ "ql_jelinek_mercer_long",
174
+ "ql_dirichlet",
175
+ "document_length",
176
+ "title_length",
177
+ "abstract_length",
178
  ]
179
 
180
  return [
 
200
  query_columns = [
201
  "query_id",
202
  "query_md5",
203
+ "query",
204
+ "query_length",
205
  "frequency_bucket",
206
  ]
207
  agg_columns = [
208
  "text_md5",
209
+ "title",
210
+ "abstract",
211
  "query_document_embedding",
212
+ "label",
213
+ "bm25",
214
+ "title_bm25",
215
+ "abstract_bm25",
216
+ "tf_idf",
217
+ "tf",
218
+ "idf",
219
+ "ql_jelinek_mercer_short",
220
+ "ql_jelinek_mercer_long",
221
+ "ql_dirichlet",
222
+ "document_length",
223
+ "title_length",
224
+ "abstract_length",
225
  ]
226
 
227
  return [