philipphager/baidu-ultr_baidu-mlm-ctr
收藏Baidu ULTR Dataset - Baidu BERT-12l-12h
数据集概述
该数据集包含查询-文档向量和点击数据,是Baidu Unbiased Learning to Rank 数据集的一个子集。使用百度发布的BERT交叉编码器(12层)计算查询-文档向量(768维)。
数据加载
加载训练/测试点击数据集
Python from datasets import load_dataset
dataset = load_dataset( "philipphager/baidu-ultr_baidu-mlm-ctr", name="clicks", split="train", # ["train", "test"] cache_dir="~/.cache/huggingface", )
dataset.set_format("torch") # [None, "numpy", "torch", "tensorflow", "pandas", "arrow"]
加载专家标注数据集
Python from datasets import load_dataset
dataset = load_dataset( "philipphager/baidu-ultr_baidu-mlm-ctr", name="annotations", split="test", cache_dir="~/.cache/huggingface", )
dataset.set_format("torch") # [None, "numpy", "torch", "tensorflow", "pandas", "arrow"]
可用特征
点击数据集
| 名称 | 数据类型 | 描述 |
|---|---|---|
| query_id | string | 百度查询ID |
| query_md5 | string | 查询文本的MD5哈希值 |
| query | List[int32] | 查询词列表 |
| query_length | int32 | 查询词数量 |
| n | int32 | 当前查询的文档数量,用于填充 |
| url_md5 | List[string] | 文档URL的MD5哈希值,最可靠的文档标识符 |
| text_md5 | List[string] | 文档标题和摘要的MD5哈希值 |
| title | List[List[int32]] | 文档标题的词列表 |
| abstract | List[List[int32]] | 文档摘要的词列表 |
| query_document_embedding | Tensor[Tensor[float16]] | BERT CLS 标记 |
| click | Tensor[int32] | 文档点击情况 |
| position | Tensor[int32] | 排名中的位置(不一定与原始项目位置匹配) |
| media_type | Tensor[int32] | 文档类型(推荐使用标签编码,因为ID不连续) |
| displayed_time | Tensor[float32] | 文档在屏幕上显示的秒数 |
| serp_height | Tensor[int32] | 文档在屏幕上的像素高度 |
| slipoff_count_after_click | Tensor[int32] | 点击后文档滑出屏幕的次数 |
| bm25 | Tensor[float32] | 文档的BM25分数 |
| bm25_title | Tensor[float32] | 文档标题的BM25分数 |
| bm25_abstract | Tensor[float32] | 文档摘要的BM25分数 |
| tf_idf | Tensor[float32] | 文档的TF-IDF分数 |
| tf | Tensor[float32] | 文档的词频 |
| idf | Tensor[float32] | 文档的逆文档频率 |
| ql_jelinek_mercer_short | Tensor[float32] | 使用Jelinek-Mercer平滑(alpha = 0.1)的查询似然分数 |
| ql_jelinek_mercer_long | Tensor[float32] | 使用Jelinek-Mercer平滑(alpha = 0.7)的查询似然分数 |
| ql_dirichlet | Tensor[float32] | 使用Dirichlet平滑(lambda = 128)的查询似然分数 |
| document_length | Tensor[int32] | 文档长度 |
| title_length | Tensor[int32] | 文档标题长度 |
| abstract_length | Tensor[int32] | 文档摘要长度 |
专家标注数据集
| 名称 | 数据类型 | 描述 |
|---|---|---|
| query_id | string | 百度查询ID |
| query_md5 | string | 查询文本的MD5哈希值 |
| query | List[int32] | 查询词列表 |
| query_length | int32 | 查询词数量 |
| frequency_bucket | int32 | 查询的月频率(桶),从0(高频率)到9(低频率) |
| n | int32 | 当前查询的文档数量,用于填充 |
| url_md5 | List[string] | 文档URL的MD5哈希值,最可靠的文档标识符 |
| text_md5 | List[string] | 文档标题和摘要的MD5哈希值 |
| title | List[List[int32]] | 文档标题的词列表 |
| abstract | List[List[int32]] | 文档摘要的词列表 |
| query_document_embedding | Tensor[Tensor[float16]] | BERT CLS 标记 |
| label | Tensor[int32] | 相关性判断,从0(差)到4(优秀) |
| bm25 | Tensor[float32] | 文档的BM25分数 |
| bm25_title | Tensor[float32] | 文档标题的BM25分数 |
| bm25_abstract | Tensor[float32] | 文档摘要的BM25分数 |
| tf_idf | Tensor[float32] | 文档的TF-IDF分数 |
| tf | Tensor[float32] | 文档的词频 |
| idf | Tensor[float32] | 文档的逆文档频率 |
| ql_jelinek_mercer_short | Tensor[float32] | 使用Jelinek-Mercer平滑(alpha = 0.1)的查询似然分数 |
| ql_jelinek_mercer_long | Tensor[float32] | 使用Jelinek-Mercer平滑(alpha = 0.7)的查询似然分数 |
| ql_dirichlet | Tensor[float32] | 使用Dirichlet平滑(lambda = 128)的查询似然分数 |
| document_length | Tensor[int32] | 文档长度 |
| title_length | Tensor[int32] | 文档标题长度 |
| abstract_length | Tensor[int32] | 文档摘要长度 |
示例 PyTorch 批处理函数
每个样本是单个查询和多个文档。以下示例展示了如何通过填充创建包含多个查询和不同数量文档的批次:
Python import torch from typing import List from collections import defaultdict from torch.nn.utils.rnn import pad_sequence from torch.utils.data import DataLoader
def collate_clicks(samples: List): batch = defaultdict(lambda: [])
for sample in samples:
batch["query_document_embedding"].append(sample["query_document_embedding"])
batch["position"].append(sample["position"])
batch["click"].append(sample["click"])
batch["n"].append(sample["n"])
return {
"query_document_embedding": pad_sequence(
batch["query_document_embedding"], batch_first=True
),
"position": pad_sequence(batch["position"], batch_first=True),
"click": pad_sequence(batch["click"], batch_first=True),
"n": torch.tensor(batch["n"]),
}
loader = DataLoader(dataset, collate_fn=collate_clicks, batch_size=16)



