数据集概览

提示

快速入门: 查找精选数据集社区数据集,通过此损失概览选择损失函数,并验证它是否适用于您的数据集。

重要的是,您的数据集格式与您的损失函数相匹配(或者您选择与您的数据集格式相匹配的损失函数)。请参阅训练概览 > 数据集格式,了解如何验证数据集格式是否适用于损失函数。

在实践中,大多数数据集配置将采用以下四种形式之一

请注意,通常可以简单地将数据集从一种格式转换为另一种格式,使其与您选择的损失函数一起使用。

提示

您可以使用mine_hard_negatives()将正例对数据集转换为三元组数据集。它使用SentenceTransformer模型来查找困难负例:与第一个数据集列相似,但不如第二个数据集列中的文本那么相似的文本。带有困难三元组的数据集通常优于仅带有正例对的数据集。

例如,我们从sentence-transformers/gooaq挖掘了困难负例,以生成tomaarsen/gooaq-hard-negatives,并在两个数据集上分别训练了tomaarsen/mpnet-base-gooaqtomaarsen/mpnet-base-gooaq-hard-negatives。遗憾的是,这两个模型使用了不同的评估拆分,因此它们的性能无法直接比较。

Hugging Face Hub 上的数据集

Datasets library (pip install datasets) 允许您使用load_dataset()函数从 Hugging Face Hub 加载数据集

from datasets import load_dataset

# Indicate the dataset id from the Hub
dataset_id = "sentence-transformers/natural-questions"
dataset = load_dataset(dataset_id, split="train")
"""
Dataset({
   features: ['query', 'answer'],
   num_rows: 100231
})
"""
print(dataset[0])
"""
{
   'query': 'when did richmond last play in a preliminary final',
   'answer': "Richmond Football Club Richmond began 2017 with 5 straight wins, a feat it had not achieved since 1995. A series of close losses hampered the Tigers throughout the middle of the season, including a 5-point loss to the Western Bulldogs, 2-point loss to Fremantle, and a 3-point loss to the Giants. Richmond ended the season strongly with convincing victories over Fremantle and St Kilda in the final two rounds, elevating the club to 3rd on the ladder. Richmond's first final of the season against the Cats at the MCG attracted a record qualifying final crowd of 95,028; the Tigers won by 51 points. Having advanced to the first preliminary finals for the first time since 2001, Richmond defeated Greater Western Sydney by 36 points in front of a crowd of 94,258 to progress to the Grand Final against Adelaide, their first Grand Final appearance since 1982. The attendance was 100,021, the largest crowd to a grand final since 1986. The Crows led at quarter time and led by as many as 13, but the Tigers took over the game as it progressed and scored seven straight goals at one point. They eventually would win by 48 points – 16.12 (108) to Adelaide's 8.12 (60) – to end their 37-year flag drought.[22] Dustin Martin also became the first player to win a Premiership medal, the Brownlow Medal and the Norm Smith Medal in the same season, while Damien Hardwick was named AFL Coaches Association Coach of the Year. Richmond's jump from 13th to premiers also marked the biggest jump from one AFL season to the next."
}
"""

有关如何操作数据集的更多信息,请参阅Datasets Documentation

提示

Hugging Face Datasets 通常包含多余的列,例如 sample_id、metadata、source、type 等。您可以使用Dataset.remove_columns来删除这些列,因为否则它们将被用作输入。您还可以使用Dataset.select_columns仅保留所需的列。

预先存在的数据集

Hugging Face Hub托管了 15 万+ 个数据集,其中许多可以转换为用于训练嵌入模型。我们的目标是标记所有可以直接与 Sentence Transformers 一起使用的 Hugging Face 数据集,使用 sentence-transformers,让您可以通过浏览 https://hugging-face.cn/datasets?other=sentence-transformers 轻松找到它们。我们强烈建议您浏览这些数据集,以查找可能对您的任务有用的训练数据集。

以下是一些流行的预先存在的数据集,标记为 sentence-transformers,可用于训练和微调 SentenceTransformer 模型

数据集 描述
GooAQ 来自 Google 自动建议的(问题,答案)对
Yahoo Answers 来自 Yahoo Answers 的(标题+问题,答案),(标题,答案),(标题,问题),(问题,答案)对
MS MARCO 三元组 (msmarco-distilbert-base-tas-b) 来自 MS MARCO Passages 数据集的(问题,答案,负例)三元组,带有挖掘的负例
MS MARCO 三元组 (msmarco-distilbert-base-v3) 来自 MS MARCO Passages 数据集的(问题,答案,负例)三元组,带有挖掘的负例
MS MARCO 三元组 (msmarco-MiniLM-L6-v3) 来自 MS MARCO Passages 数据集的(问题,答案,负例)三元组,带有挖掘的负例
MS MARCO 三元组 (distilbert-margin-mse-cls-dot-v2) 来自 MS MARCO Passages 数据集的(问题,答案,负例)三元组,带有挖掘的负例
MS MARCO 三元组 (distilbert-margin-mse-cls-dot-v1) 来自 MS MARCO Passages 数据集的(问题,答案,负例)三元组,带有挖掘的负例
MS MARCO 三元组 (distilbert-margin-mse-mean-dot-v1) 来自 MS MARCO Passages 数据集的(问题,答案,负例)三元组,带有挖掘的负例
MS MARCO 三元组 (mpnet-margin-mse-mean-v1) 来自 MS MARCO Passages 数据集的(问题,答案,负例)三元组,带有挖掘的负例
MS MARCO 三元组 (co-condenser-margin-mse-cls-v1) 来自 MS MARCO Passages 数据集的(问题,答案,负例)三元组,带有挖掘的负例
MS MARCO 三元组 (distilbert-margin-mse-mnrl-mean-v1) 来自 MS MARCO Passages 数据集的(问题,答案,负例)三元组,带有挖掘的负例
MS MARCO 三元组 (distilbert-margin-mse-sym-mnrl-mean-v1) 来自 MS MARCO Passages 数据集的(问题,答案,负例)三元组,带有挖掘的负例
MS MARCO 三元组 (distilbert-margin-mse-sym-mnrl-mean-v2) 来自 MS MARCO Passages 数据集的(问题,答案,负例)三元组,带有挖掘的负例
MS MARCO 三元组 (co-condenser-margin-mse-sym-mnrl-mean-v1) 来自 MS MARCO Passages 数据集的(问题,答案,负例)三元组,带有挖掘的负例
MS MARCO 三元组 (BM25) 来自 MS MARCO Passages 数据集的(问题,答案,负例)三元组,带有挖掘的负例
Stack Exchange 重复项 来自 StackExchange 的重复问题对(标题,标题),(标题+正文,标题+正文),(正文,正文)
ELI5 来自 ELI5 数据集的(问题,答案)对
SQuAD 来自 SQuAD 数据集的(问题,答案)对
WikiHow 来自 WikiHow 的(摘要,文本)对
Amazon Reviews 2018 来自 Amazon Reviews 的(标题,评论)对
Natural Questions 来自 Natural Questions 数据集的(查询,答案)对
Amazon QA 来自 Amazon 的(问题,答案)对
S2ORC 科学论文的(标题,摘要),(摘要,引用),(标题,引用)对
Quora 重复项 来自 Quora 的重复问题对
WikiAnswers 来自 WikiAnswers 的重复问题对
AGNews 来自 AG News 数据集的新闻文章的(标题,描述)对
AllNLI 来自 SNLI + MultiNLI 的(Anchor,Entailment,Contradiction)三元组
NPR 来自 npr.org 网站的(标题,正文)对
SPECTER 来自 Specter 的科学出版物的(标题,正面标题,负面标题)三元组
Simple Wiki 来自 Wikipedia 的(英语,简易英语)对
PAQ 来自 Probably-Asked Questions 数据集的(查询,答案)
altlex 来自 Wikipedia 的(英语,简易英语)对
CC News 来自 CC News 数据集的(标题,文章)对
CodeSearchNet 来自 GitHub 上开源库的(注释,代码)对
句子压缩 来自 Sentence Compression 数据集的(长文本,短文本)对
Trivia QA 来自 TriviaQA 数据集的(查询,答案)对
Flickr30k Captions 来自 Flickr30k 数据集的重复标题
xsum 来自 XSUM 数据集的新闻文章,摘要对
Coco Captions 来自 Coco Captions 数据集的重复标题
平行句子:Europarl 跨多种语言的(英语,非英语)对
平行句子:Global Voices 跨多种语言的(英语,非英语)对
平行句子:MUSE 跨多种语言的(英语,非英语)对
平行句子:JW300 跨多种语言的(英语,非英语)对
平行句子:News Commentary 跨多种语言的(英语,非英语)对
平行句子:OpenSubtitles 跨多种语言的(英语,非英语)对
平行句子:Talks 跨多种语言的(英语,非英语)对
平行句子:Tatoeba 跨多种语言的(英语,非英语)对
平行句子:WikiMatrix 跨多种语言的(英语,非英语)对
平行句子:WikiTitles 跨多种语言的(英语,非英语)对

注意

我们建议用户通过添加 tags: sentence-transformers 来标记可用于训练嵌入模型的数据集。我们也很乐意接受高质量的数据集添加到上面的列表中,供大家查看和使用。