Hugging Face 推出数据集测量交互工具
Hugging Face 发布了一款在线交互式工具,用于构建、测量和比较机器学习数据集。该工具旨在通过可视化手段(如 nPMI)帮助用户深入理解数据分布与潜在偏差,弥补静态文档在直观性上的不足。
报道正文
本文目录11 个章节
推出 🤗 Data Measurements Tool:一款用于查看数据集的交互式工具
发布于 2021 年 11 月 29 日 在 GitHub 上更新 点赞 - Sasha Luccioni sasha Yacine Jernite yjernite Margaret Mitchell meg
摘要: 我们开发了一款在线工具,供用户构建、测量和比较数据集。
点击此处访问 🤗 Data Measurements Tool。
作为机器学习数据集统一仓库(Lhoest et al. 2021)的开发团队,🤗 Hugging Face 团队一直致力于支持良好的数据集文档实践(McMillan-Major et al., 2021)。虽然静态(但不断演进)的文档是这一方向上的必要第一步,但要真正了解数据集中实际包含的内容,还需要有充分依据的测量指标以及与之交互的能力,从而动态可视化各个感兴趣的方面。
为此,我们推出了一个名为 🤗 Data Measurements Tool 的开源 Python 库和无代码界面,该工具结合了我们强大的 Dataset 和 Spaces Hub 以及优秀的 Streamlit 工具。它可用于帮助用户理解、构建、整理和比较数据集。
什么是 🤗 Data Measurements Tool?
Data Measurements Tool (DMT) 是一个交互式界面和开源库,允许数据集创建者和用户自动计算对负责任的数据开发有意义且有用的指标。
我们为何创建此工具?
对机器学习数据集的审慎策划与分析,在 AI 开发中往往被忽视。当前 AI 领域关于“大数据”的惯例(Luccioni et al., 2021, Dodge et al., 2021)包括使用从各类网站抓取的数据,却很少或完全未关注不同数据源所代表内容的具体度量指标,也未深入探究这些数据如何影响模型学习过程的细微细节。尽管数据集标注方法有助于策划更符合开发者目标的数据集,但用于“衡量”这些数据集不同方面的方法仍相当有限(Sambasivan et al., 2021)。
AI 领域的一波新研究呼吁从根本上转变该领域对待 ML 数据集的方式(Paullada et al., 2020, Denton et al., 2021)。这包括从一开始就为数据集创建定义细粒度的要求(Hutchinson et al., 2021),针对问题内容和偏见担忧来策划数据集(Yang et al., 2020, Prabhu and Birhane, 2020),以及明确数据集构建与维护中固有的价值观(Scheuerman et al., 2021, Birhane et al., 2021)。虽然业界普遍认同数据集开发是一项应由多学科背景人员参与指导的任务,但在实践中,与原始数据的交互往往存在瓶颈,因为分析和查询数据集通常需要复杂的编程技能。
尽管如此,目前公开可用的工具寥寥无几,难以让不同学科背景的人们对数据集进行测量、审查和比较。我们旨在填补这一空白。我们从近期推出的工具如 Know Your Data 和 Data Quality for AI 中汲取经验并加以构建,同时也参考了关于数据集文档的研究提案,例如 Vision and Language Datasets (Ferraro et al., 2015)、Datasheets for Datasets (Gebru et al, 2018) 以及 Data Statements (Bender & Friedman 2019)。最终成果是一个用于数据集测量的开源库,以及一个配套的无需代码的详细数据集分析界面。
我何时可以使用 🤗 Data Measurements Tool?
🤗 Data Measurements Tool 可用于迭代式地探索一个或多个现有的 NLP 数据集,并且很快将支持从零开始迭代开发数据集。它提供了基于数据集研究和负责任的数据集开发实践所形成的可操作洞察,使用户能够聚焦于高层级信息和具体条目。
使用 🤗 Data Measurements Tool 我能学到什么?
数据集基础信息
用于获取数据集的高层级概览
这有助于回答诸如“这个数据集是什么?”、“是否存在缺失项?”等问题。你可以将其作为“合理性检查”,以确认你正在处理的数据集是否符合预期。
- 数据集描述(来自 Hugging Face Hub)
- 缺失值或 NaN 的数量
描述性统计
用于查看数据集的表面特征
这有助于回答诸如“数据集中包含什么样的语言?”、“其多样性如何?”等问题。
- 数据集词汇量大小及词频分布,涵盖 开放类和封闭类词。
- 数据集标签分布及类别(不)平衡相关信息。

- 实例长度的均值、中位数、范围及分布。
- 数据集中重复项的数量及其重复次数。
You can use these widgets to check whether what is most and least represented in the dataset make sense for the goals of the dataset. These measurements are intended to inform whether the dataset can be useful in capturing a variety of contexts or if what it captures is more limited, and to measure how ''balanced'' the labels and instance lengths are. You can also use these widgets to identify outliers and duplicates you may want to remove.
Distributional Statistics
To measure the language patterns in the dataset
This begins to answer questions like “How does the language behave in this dataset?”
- Adherence to Zipf’s law, which provides measurements of how closely the distribution over words in the dataset fits to the expected distribution of words in natural language.
You can use this to figure out whether your dataset represents language as it tends to behave in the natural world or if there are things that are more unnatural about it. If you’re someone who enjoys optimization, then you can view the alpha value this widget calculates as a value to get as close as possible to 1 during dataset development. Further details on alpha values following Zipf’s law in different languages is available here.
In general, an alpha greater than 2 or a minimum rank greater than 10 (take with a grain of salt) means that your distribution is relatively unnatural for natural language. This can be a sign of mixed artefacts in the dataset, such as HTML markup. You can use this information to clean up your dataset or to guide you in determining how further language you add to the dataset should be distributed.
Comparison statistics
This begins to answer questions like “What kinds of topics, biases, and associations are in this dataset?”
[注:本文篇幅超长,以上为核心前篇精译,后续内容保留原文呈现]
-
Embedding clusters to pinpoint any clusters of similar language in the dataset. Taking in the diversity of text represented in a dataset can be challenging when it is made up of hundreds to hundreds of thousands of sentences. Grouping these text items based on a measure of similarity can help users gain some insights into their distribution. We show a hierarchical clustering of the text fields in the dataset based on a Sentence-Transformer model and a maximum dot product single-linkage criterion. To explore the clusters, you can:
-
hover over a node to see the 5 most representative examples (deduplicated)
-
enter an example in the text box to see which leaf clusters it is most similar to
-
select a cluster by ID to show all of its examples
-
The normalized pointwise mutual information (nPMI) between word pairs in the dataset, which may be used to identify problematic stereotypes. You can use this as a tool in dealing with dataset “bias”, where here the term “bias” refers to stereotypes and prejudices for identity groups along the axes of gender and sexual orientation. We will add further terms in the near future.
What is the status of 🤗 Data Measurements Tool development?
We currently present the alpha version (v0) of the tool, demonstrating its usefulness on a handful of popular English-language datasets (e.g. SQuAD, imdb, C4, ...) available on the Dataset Hub, with the functionalities described above. The words that we selected for nPMI visualization are a subset of identity terms that came up frequently in the datasets that we were working with.
In coming weeks and months, we will be extending the tool to:
- Cover more languages and datasets present in the 🤗 Datasets library.
- Provide support for user-provided datasets and iterative dataset building.
- Add more features and functionalities to the tool itself. For example, we will make it possible to add your own terms for the nPMI visualization so you can pick the words that matter most to you.
Acknowledgements
Thank you to Thomas Wolf for initiating this work, as well as other members of the 🤗 team (Quentin, Lewis, Sylvain, Nate, Julien C., Julien S., Clément, Omar, and many others!) for their help and support.

