The dataset viewer is not available because its heuristics could not detect any supported data files. You can try uploading some data files, or configuring the data files location manually.
dynabench/dynasent(複製)
データの内容
英語の文を、positive、negative、neutral の 3 値で感情分類するベンチマーク用のデータ。Round 1 は Yelp のレビューから自然に出現した文、Round 2 は Dynabench でクラウドソーシングした文で、文ごとに本文 sentence、正解ラベル gold_label、作業者のラベルの分布 label_distribution が付いている。Stanford Sentiment Treebank の dev セットを同じ形式に変換し、検証のラベルを付けたものも含む。
データの概要
| 項目 | 値 |
|---|---|
| 行数・列数 | 不明(データセットビューアで読めない形式。ファイルの内訳だけを示す) |
| 容量 | 37.92 KB(ファイル 4 本) |
| ファイルの形式 | json 1、py 1 |
| 公開 | public |
全データセットの一覧は HYUKI5/dataset-catalog にある。
複製について
dynabench/dynasent をリビジョン d1e2d5e619bb78fb6dc4d548108c50cb65b8d78c の時点でそのまま複製したもの。中身は変えていない。判断モデル Laya(convaiinnovations/laya)の微調整に使う候補として、調査メモ(Laya 学習用データセット調査)に載せたデータを集めている。
出典
- 元のデータセット: https://huggingface.co/datasets/dynabench/dynasent
- 複製したリビジョン:
d1e2d5e619bb78fb6dc4d548108c50cb65b8d78c(2021-04-29 11:30:24+00:00) - 元のライセンス表記:
other
論文
アノテーションの方法
(元のカードに該当の見出しが無いので、ラベルの付け方に触れた段落を抜き出した)
Round 1: Dynabench でクラウドソーシングした文
このデータセットには、Stanford Sentiment Treebank の dev セットを本データセットの形式に変換し、検証タスクのラベルを付けたものも含まれる:
'hit_ids': 検証の際にこの例が現れた Amazon Mechanical Turk の Human Interface Tasks(HIT)のリスト。値は匿名化されているが、データセット全体で一貫して使われている。'sentence': 例のテキスト。'indices_into_review_text':元のレビュー(Yelp Academic Dataset 内)における'sentence'の位置(インデックス)。'model_0_label': 論文で述べられた Model 0 の予測。取りうる値は'positive'、'negative'、'neutral'。'model_0_probs': Model 0 が予測した確率分布。キーは('positive', 'negative', 'neutral')、値は浮動小数点数。'text_id': この項目の一意の識別子。'review_id': Yelp Academic Dataset で'sentence'を含むレビューの、レビュー単位の識別子。'review_rating': Yelp Academic Dataset において'sentence'を含むレビューの、レビュー単位の星の評価。取りうる値は1、2、3、4、5。'label_distribution':MTurk の検証タスクにおける回答の分布。キーは('positive', 'negative', 'neutral')、値は匿名化された MTurk の ID のリストで、データセット全体で一貫して使われている。'gold_label': 5 人のワーカーのうち少なくとも 3 人が選んだラベル(ある場合)。取りうる値は'positive'、'negative'、'neutral'、'mixed'。ない場合はNone。'hit_ids': 検証の際にこの例が現れた Amazon Mechanical Turk の Human Interface Tasks(HIT)のリスト。値は匿名化されているが、データセット全体で一貫して使われている。'sentence': 例のテキスト。'sentence_author':'sentence'を書いたワーカーの匿名化された MTurk の ID。'label_distribution'で使われるのと同じ系統の ID だが、この ID がその例の'label_distribution'の ID のいずれかになることはない。'has_prompt':'sentence'がプロンプトを使って書かれた場合はTrue、そうでなければFalse。'prompt_data':'has_prompt'が False の場合は None、そうでなければ次のとおり:'indices_into_review_text': 元のレビュー(Yelp Academic Dataset 内)における'prompt_sentence'の位置(インデックス)。'review_rating': Yelp Academic Dataset において'sentence'を含むレビューの、レビュー単位の星の評価。'prompt_sentence': プロンプトのテキスト。'review_id': Yelp Academic Dataset で'prompt_sentence'を含むレビューの、レビュー単位の識別子。
'model_1_label': 論文で述べられた Model 1 の予測。取りうる値は'positive'、'negative'、'neutral'。'model_1_probs': Model 1 が予測した確率分布。キーは('positive', 'negative', 'neutral')、値は浮動小数点数。'text_id': この項目の一意の識別子。'label_distribution': MTurk の検証タスクにおける回答の分布。キーは('positive', 'negative', 'neutral')、値は匿名化された MTurk の ID のリストで、データセット全体で一貫して使われている。'gold_label': 5 人のワーカーのうち少なくとも 3 人が選んだラベル(ある場合)。取りうる値は'positive'、'negative'、'neutral'、'mixed'。ない場合はNone。'hit_ids': 検証の際にこの例が現れた Amazon Mechanical Turk の Human Interface Tasks(HIT)のリスト。値は匿名化されているが、データセット全体で一貫して使われている。'sentence': 例のテキスト。'tree': SST の配布物にある、この例の構文木。'text_id': この例に新たに付けた識別子。'sst_label': SST のルートノードのラベル。取りうる値は'0'、'1'、'2'、'3'、'4'。'label_distribution':MTurk の検証タスクにおける回答の分布。キーは('positive', 'negative', 'neutral')、値は匿名化された MTurk の ID のリストで、データセット全体で一貫して使われている。'gold_label': 5 人のワーカーのうち少なくとも 3 人が選んだラベル(ある場合)。取りうる値は'positive'、'negative'、'neutral'、'mixed'。ない場合はNone。
微調整に使うときの注意
- 調査メモの台帳での区分: D(記載なし・other・unknown・資料間の食い違い)。区分は記載の文言で機械的に付けたもので、法的な判定ではない。学習に入れる前に元のカードとライセンスの原文で確かめる。
- Laya の入力は 2,048 token まで(ModernBERT-large / mmBERT)。長い本文は先頭から黙って切られるので、切れる行は事前に除くか、要約・切り出しをしてから入れる。
- 分割は記事・文書単位で行い、同じ本文から作った別の問いを学習側と較正側に分けない。温度と閾値は学習に使っていない分割で別々に当てる。
調査メモの記述
| メモ | 節 | ライセンス(記載) | 確認 | 注記 |
|---|---|---|---|---|
general_english_nlu.md |
1. 単文分類: 感情・トピック・意図・感情語・スパム・毒性・皮肉(noul / choice / score に変換) (L33) | タグ無し(未記載) | 確認済 | 原文注記: - dynabench/dynasent: arXiv 2012.15349(タグ)。スクリプトのみで viewer 非対応(/parquet がエラー)。license タグ無し。lastModified 2021-0 |
jev_sources_tasksource_bekko.csv |
CSV(tasksource-jev-typed-decisions) | CC BY 4.0 (DPI) / license_use=commercial | 確認済 | license_use=commercial / [Jev 元データ source] human_votes_aggregated_to_soft_target(source annotation; agg |
jev_sources_tasksource_bekko.csv |
CSV(tasksource-jev-typed-decisions) | CC BY 4.0 (DPI) / license_use=commercial | 確認済 | license_use=commercial / [Jev 元データ source] human_votes_aggregated_to_soft_target(source annotation; agg |
元のカード(日本語訳)
以下は元のデータセットのカードの本文を日本語に訳したもの(機械翻訳)。訳に疑問があるときは、末尾の原文を確かめる。
DynaSent: 動的な感情分析のデータセット
DynaSent は、三値(positive/negative/neutral)の感情分析のための英語のベンチマークタスクである。このデータセットのカードは、元の DynaSent のリポジトリ からフォークしたものである。
目次
- 引用
- データセットのファイル
- クイックスタート
- データの形式
- モデル
- その他のファイル
- ライセンス
引用
Christopher Potts, Zhengxuan Wu, Atticus Geiger, and Douwe Kiela. 2020. DynaSent: A dynamic benchmark for sentiment analysis. 原稿(Ms.)、Stanford University および Facebook AI Research。
@article{potts-etal-2020-dynasent,
title={{DynaSent}: A Dynamic Benchmark for Sentiment Analysis},
author={Potts, Christopher and Wu, Zhengxuan and Geiger, Atticus and Kiela, Douwe},
journal={arXiv preprint arXiv:2012.15349},
url={https://arxiv.org/abs/2012.15349},
year={2020}}
データセットのファイル
データセットは dynasent-v1.1.zip で、このリポジトリに含まれている。v1.1 が v1 と異なるのは、Round 1 に適切な一意の ID を付与したことと、Round 2 で一部の ID が一意でなくなっていたバグを直したことだけである。例やその他のメタデータには変更はない。
データセットは 2 つのラウンドから成り、それぞれに train/dev/test の split がある:
Round 1: 自然に出現する文
dynasent-v1.1-round01-yelp-train.jsonldynasent-v1.1-round01-yelp-dev.jsonldynasent-v1.1-round01-yelp-test.jsonl
Round 1: Dynabench でクラウドソーシングした文
dynasent-v1.1-round02-dynabench-train.jsonldynasent-v1.1-round02-dynabench-dev.jsonldynasent-v1.1-round02-dynabench-test.jsonl
SST-dev の再検証
このデータセットには、Stanford Sentiment Treebank の dev セットを本データセットの形式に変換し、検証タスクのラベルを付けたものも含まれる:
sst-dev-validated.jsonl
クイックスタート
この関数を使うと、ファイルの任意のサブセットを読み込める:
import json
def load_dataset(*src_filenames, labels=None):
data = []
for filename in src_filenames:
with open(filename) as f:
for line in f:
d = json.loads(line)
if labels is None or d['gold_label'] in labels:
data.append(d)
return data
例えば、三値の正解ラベルを持つ例に絞って Round 1 の train セットを作るには:
import os
r1_train_filename = os.path.join('dynasent-v1.1', 'dynasent-v1.1-round01-yelp-train.jsonl')
ternary_labels = ('positive', 'negative', 'neutral')
r1_train = load_dataset(r1_train_filename, labels=ternary_labels)
X_train, y_train = zip(*[(d['sentence'], d['gold_label']) for d in r1_train])
データの形式
Round 1 の形式
{'hit_ids': ['y5238'],
'sentence': 'Roto-Rooter is always good when you need someone right away.',
'indices_into_review_text': [0, 60],
'model_0_label': 'positive',
'model_0_probs': {'negative': 0.01173639390617609,
'positive': 0.7473671436309814,
'neutral': 0.24089649319648743},
'text_id': 'r1-0000001',
'review_id': 'IDHkeGo-nxhqX4Exkdr08A',
'review_rating': 1,
'label_distribution': {'positive': ['w130', 'w186', 'w207', 'w264', 'w54'],
'negative': [],
'neutral': [],
'mixed': []},
'gold_label': 'positive'}
詳細:
'hit_ids': 検証の際にこの例が現れた Amazon Mechanical Turk の Human Interface Tasks(HIT)のリスト。値は匿名化されているが、データセット全体で一貫して使われている。'sentence': 例のテキスト。'indices_into_review_text':元のレビュー(Yelp Academic Dataset 内)における'sentence'の位置(インデックス)。'model_0_label': 論文で述べられた Model 0 の予測。取りうる値は'positive'、'negative'、'neutral'。'model_0_probs': Model 0 が予測した確率分布。キーは('positive', 'negative', 'neutral')、値は浮動小数点数。'text_id': この項目の一意の識別子。'review_id': Yelp Academic Dataset で'sentence'を含むレビューの、レビュー単位の識別子。'review_rating': Yelp Academic Dataset において'sentence'を含むレビューの、レビュー単位の星の評価。取りうる値は1、2、3、4、5。'label_distribution':MTurk の検証タスクにおける回答の分布。キーは('positive', 'negative', 'neutral')、値は匿名化された MTurk の ID のリストで、データセット全体で一貫して使われている。'gold_label': 5 人のワーカーのうち少なくとも 3 人が選んだラベル(ある場合)。取りうる値は'positive'、'negative'、'neutral'、'mixed'。ない場合はNone。
以下は、load_dataset で読み込んだデータセットに、Yelp Academic Dataset の完全なレビューの本文を入れるフィールドを追加するためのコードの例である:
import json
def index_yelp_reviews(yelp_src_filename='yelp_academic_dataset_review.json'):
index = {}
with open(yelp_src_filename) as f:
for line in f:
d = json.loads(line)
index[d['review_id']] = d['text']
return index
yelp_index = index_yelp_reviews()
def add_review_text_round1(dataset, yelp_index):
for d in dataset:
review_text = yelp_index[d['text_id']]
# Check that we can find the sentence as expected:
start, end = d['indices_into_review_text']
assert review_text[start: end] == d['sentence']
d['review_text'] = review_text
return dataset
Round 2 の形式
{'hit_ids': ['y22661'],
'sentence': "We enjoyed our first and last meal in Toronto at Bombay Palace, and I can't think of a better way to book our journey.",
'sentence_author': 'w250',
'has_prompt': True,
'prompt_data': {'indices_into_review_text': [2093, 2213],
'review_rating': 5,
'prompt_sentence': "Our first and last meals in Toronto were enjoyed at Bombay Palace and I can't think of a better way to bookend our trip.",
'review_id': 'Krm4kSIb06BDHternF4_pA'},
'model_1_label': 'positive',
'model_1_probs': {'negative': 0.29140257835388184,
'positive': 0.6788994669914246,
'neutral': 0.029697999358177185},
'text_id': 'r2-0000001',
'label_distribution': {'positive': ['w43', 'w26', 'w155', 'w23'],
'negative': [],
'neutral': [],
'mixed': ['w174']},
'gold_label': 'positive'}
詳細:
'hit_ids': 検証の際にこの例が現れた Amazon Mechanical Turk の Human Interface Tasks(HIT)のリスト。値は匿名化されているが、データセット全体で一貫して使われている。'sentence': 例のテキスト。'sentence_author':'sentence'を書いたワーカーの匿名化された MTurk の ID。'label_distribution'で使われるのと同じ系統の ID だが、この ID がその例の'label_distribution'の ID のいずれかになることはない。'has_prompt':'sentence'がプロンプトを使って書かれた場合はTrue、そうでなければFalse。'prompt_data':'has_prompt'が False の場合は None、そうでなければ次のとおり:'indices_into_review_text': 元のレビュー(Yelp Academic Dataset 内)における'prompt_sentence'の位置(インデックス)。'review_rating': Yelp Academic Dataset において'sentence'を含むレビューの、レビュー単位の星の評価。'prompt_sentence': プロンプトのテキスト。'review_id': Yelp Academic Dataset で'prompt_sentence'を含むレビューの、レビュー単位の識別子。
'model_1_label': 論文で述べられた Model 1 の予測。取りうる値は'positive'、'negative'、'neutral'。'model_1_probs': Model 1 が予測した確率分布。キーは('positive', 'negative', 'neutral')、値は浮動小数点数。'text_id': この項目の一意の識別子。'label_distribution': MTurk の検証タスクにおける回答の分布。キーは('positive', 'negative', 'neutral')、値は匿名化された MTurk の ID のリストで、データセット全体で一貫して使われている。'gold_label': 5 人のワーカーのうち少なくとも 3 人が選んだラベル(ある場合)。取りうる値は'positive'、'negative'、'neutral'、'mixed'。ない場合はNone。
'prompt_data' フィールドにレビューのテキストを追加するには、上の Round 1 のコードを次の関数で拡張すればよい:
def add_review_text_round2(dataset, yelp_index):
for d in dataset:
if d['has_prompt']:
prompt_data = d['prompt_data']
review_text = yelp_index[prompt_data['review_id']]
# Check that we can find the sentence as expected:
start, end = prompt_data['indices_into_review_text']
assert review_text[start: end] == prompt_data['prompt_sentence']
prompt_data['review_text'] = review_text
return dataset
SST-dev の形式
{'hit_ids': ['s20533'],
'sentence': '-LRB- A -RRB- n utterly charming and hilarious film that reminded me of the best of the Disney comedies from the 60s.',
'tree': '(4 (2 (1 -LRB-) (2 (2 A) (3 -RRB-))) (4 (4 (2 n) (4 (3 (2 utterly) (4 (3 (4 charming) (2 and)) (4 hilarious))) (3 (2 film) (3 (2 that) (4 (4 (2 (2 reminded) (3 me)) (4 (2 of) (4 (4 (2 the) (4 best)) (2 (2 of) (3 (2 the) (3 (3 Disney) (2 comedies))))))) (2 (2 from) (2 (2 the) (2 60s)))))))) (2 .)))',
'text_id': 'sst-dev-validate-0000437',
'sst_label': '4',
'label_distribution': {'positive': ['w207', 'w3', 'w840', 'w135', 'w26'],
'negative': [],
'neutral': [],
'mixed': []},
'gold_label': 'positive'}
詳細:
'hit_ids': 検証の際にこの例が現れた Amazon Mechanical Turk の Human Interface Tasks(HIT)のリスト。値は匿名化されているが、データセット全体で一貫して使われている。'sentence': 例のテキスト。'tree': SST の配布物にある、この例の構文木。'text_id': この例に新たに付けた識別子。'sst_label': SST のルートノードのラベル。取りうる値は'0'、'1'、'2'、'3'、'4'。'label_distribution':MTurk の検証タスクにおける回答の分布。キーは('positive', 'negative', 'neutral')、値は匿名化された MTurk の ID のリストで、データセット全体で一貫して使われている。'gold_label': 5 人のワーカーのうち少なくとも 3 人が選んだラベル(ある場合)。取りうる値は'positive'、'negative'、'neutral'、'mixed'。ない場合はNone。
モデル
論文の Model 0 と Model 1 は、ここから入手できる:
https://drive.google.com/drive/folders/1dpKrjNJfAILUQcJPAFc5YOXUT51VEjKQ?usp=sharing
このリポジトリには、これらの(PyTorch)モデルを Hugging Face を基盤にしてラップする Python モジュール dynasent_models.py が含まれている。簡単な例は次のとおり:
import os
from dynasent_models import DynaSentModel
# `dynasent_model0` should be downloaded from the above Google Drive link and
# placed in the `models` directory. `dynasent_model1` works the same way.
model = DynaSentModel(os.path.join('models', 'dynasent_model0.bin'))
examples = [
"superb",
"They said the experience would be amazing, and they were right!",
"They said the experience would be amazing, and they were wrong!"]
model.predict(examples)
これは ['positive', 'positive', 'negative'] というリストを返すはずである。
predict_proba メソッドは、クラスのラベルに対する予測された分布を取得できる。詳細は dynasent_models.py の末尾にあるデモを参照されたい。
次のコードは、上の load_dataset を使って、論文の Model 0 に関する Round 2 の dev セットの報告を再現するものである:
import os
from sklearn.metrics import classification_report
from dynasent_models import DynaSentModel
dev_filename = os.path.join('dynasent-v1.1', 'dynasent-v1.1-round02-dynabench-dev.jsonl')
dev = load_dataset(dev_filename)
X_dev, y_dev = zip(*[(d['sentence'], d['gold_label']) for d in dev])
model = DynaSentModel(os.path.join('models', 'dynasent_model0.bin'))
preds = model.predict(X_dev)
print(classification_report(y_dev, preds, digits=3))
これらのモデルについてより詳しい報告は、論文と モデルカード を参照されたい。
その他のファイル
分析のノートブック
次のノートブックは、論文のデータセットの統計、図、ランダムに選んだ例を再現する:
analyses_comparative.ipynbanalysis_round1.ipynbanalysis_round2.ipynbanalysis_sst_dev_revalidate.ipynb
Python モジュール dynasent_utils.py には、それらのノートブックを支える関数が含まれており、dynasent.mplstyle は図の体裁の設定を助ける。
データシート
このデータセットの Datasheet:
モデルカード
本研究のモデルの Model Card:
テスト
モジュール test_dataset.py には、データセットの PyTest のテストが含まれる。使うには、次を実行する:
py.test -vv test_dataset.py
このリポジトリのルートディレクトリで実行する。
検証の HIT のコード
ファイル validation-hit-contents.html には、検証タスクで使われた HTML/JavaScript が含まれる。その内容を通常の HIT 作成のウィンドウに貼り付けるだけで、Amazon Mechanical Turk でそのまま使える。
ライセンス
DynaSent は Creative Commons Attribution 4.0 International License のもとにある。
原文(英語)
DynaSent: Dynamic Sentiment Analysis Dataset
DynaSent is an English-language benchmark task for ternary (positive/negative/neutral) sentiment analysis. This dataset card is forked from the original DynaSent Repository.
Contents
Citation
Christopher Potts, Zhengxuan Wu, Atticus Geiger, and Douwe Kiela. 2020. DynaSent: A dynamic benchmark for sentiment analysis. Ms., Stanford University and Facebook AI Research.
@article{potts-etal-2020-dynasent,
title={{DynaSent}: A Dynamic Benchmark for Sentiment Analysis},
author={Potts, Christopher and Wu, Zhengxuan and Geiger, Atticus and Kiela, Douwe},
journal={arXiv preprint arXiv:2012.15349},
url={https://arxiv.org/abs/2012.15349},
year={2020}}
Dataset files
The dataset is dynasent-v1.1.zip, which is included in this repository. v1.1 differs from v1 only in that v1.1 has proper unique ids for Round 1 and corrects a bug that led to some non-unique ids in Round 2. There are no changes to the examples or other metadata.
The dataset consists of two rounds, each with a train/dev/test split:
Round 1: Naturally occurring sentences
dynasent-v1.1-round01-yelp-train.jsonldynasent-v1.1-round01-yelp-dev.jsonldynasent-v1.1-round01-yelp-test.jsonl
Round 1: Sentences crowdsourced using Dynabench
dynasent-v1.1-round02-dynabench-train.jsonldynasent-v1.1-round02-dynabench-dev.jsonldynasent-v1.1-round02-dynabench-test.jsonl
SST-dev revalidation
The dataset also contains a version of the Stanford Sentiment Treebank dev set in our format with labels from our validation task:
sst-dev-validated.jsonl
Quick start
This function can be used to load any subset of the files:
import json
def load_dataset(*src_filenames, labels=None):
data = []
for filename in src_filenames:
with open(filename) as f:
for line in f:
d = json.loads(line)
if labels is None or d['gold_label'] in labels:
data.append(d)
return data
For example, to create a Round 1 train set restricting to examples with ternary gold labels:
import os
r1_train_filename = os.path.join('dynasent-v1.1', 'dynasent-v1.1-round01-yelp-train.jsonl')
ternary_labels = ('positive', 'negative', 'neutral')
r1_train = load_dataset(r1_train_filename, labels=ternary_labels)
X_train, y_train = zip(*[(d['sentence'], d['gold_label']) for d in r1_train])
Data format
Round 1 format
{'hit_ids': ['y5238'],
'sentence': 'Roto-Rooter is always good when you need someone right away.',
'indices_into_review_text': [0, 60],
'model_0_label': 'positive',
'model_0_probs': {'negative': 0.01173639390617609,
'positive': 0.7473671436309814,
'neutral': 0.24089649319648743},
'text_id': 'r1-0000001',
'review_id': 'IDHkeGo-nxhqX4Exkdr08A',
'review_rating': 1,
'label_distribution': {'positive': ['w130', 'w186', 'w207', 'w264', 'w54'],
'negative': [],
'neutral': [],
'mixed': []},
'gold_label': 'positive'}
Details:
'hit_ids': List of Amazon Mechanical Turk Human Interface Tasks (HITs) in which this example appeared during validation. The values are anonymized but used consistently throughout the dataset.'sentence': The example text.'indices_into_review_text':indices of'sentence'into the original review in the Yelp Academic Dataset.'model_0_label': prediction of Model 0 as described in the paper. The possible values are'positive','negative', and'neutral'.'model_0_probs': probability distribution predicted by Model 0. The keys are('positive', 'negative', 'neutral')and the values are floats.'text_id': unique identifier for this entry.'review_id': review-level identifier for the review from the Yelp Academic Dataset containing'sentence'.'review_rating': review-level star-rating for the review containing'sentence'in the Yelp Academic Dataset. The possible values are1,2,3,4, and5.'label_distribution':response distribution from the MTurk validation task. The keys are('positive', 'negative', 'neutral')and the values are lists of anonymized MTurk ids, which are used consistently throughout the dataset.'gold_label': the label chosen by at least three of the five workers if there is one (possible values:'positive','negative', 'neutral', and'mixed'), elseNone.
Here is some code one could use to augment a dataset, as loaded by load_dataset, with a field giving the full review text from the Yelp Academic Dataset:
import json
def index_yelp_reviews(yelp_src_filename='yelp_academic_dataset_review.json'):
index = {}
with open(yelp_src_filename) as f:
for line in f:
d = json.loads(line)
index[d['review_id']] = d['text']
return index
yelp_index = index_yelp_reviews()
def add_review_text_round1(dataset, yelp_index):
for d in dataset:
review_text = yelp_index[d['text_id']]
# Check that we can find the sentence as expected:
start, end = d['indices_into_review_text']
assert review_text[start: end] == d['sentence']
d['review_text'] = review_text
return dataset
Round 2 format
{'hit_ids': ['y22661'],
'sentence': "We enjoyed our first and last meal in Toronto at Bombay Palace, and I can't think of a better way to book our journey.",
'sentence_author': 'w250',
'has_prompt': True,
'prompt_data': {'indices_into_review_text': [2093, 2213],
'review_rating': 5,
'prompt_sentence': "Our first and last meals in Toronto were enjoyed at Bombay Palace and I can't think of a better way to bookend our trip.",
'review_id': 'Krm4kSIb06BDHternF4_pA'},
'model_1_label': 'positive',
'model_1_probs': {'negative': 0.29140257835388184,
'positive': 0.6788994669914246,
'neutral': 0.029697999358177185},
'text_id': 'r2-0000001',
'label_distribution': {'positive': ['w43', 'w26', 'w155', 'w23'],
'negative': [],
'neutral': [],
'mixed': ['w174']},
'gold_label': 'positive'}
Details:
'hit_ids': List of Amazon Mechanical Turk Human Interface Tasks (HITs) in which this example appeared during validation. The values are anonymized but used consistently throughout the dataset.'sentence': The example text.'sentence_author': Anonymized MTurk id of the worker who wrote'sentence'. These are from the same family of ids as used in'label_distribution', but this id is never one of the ids in'label_distribution'for this example.'has_prompt':Trueif the'sentence'was written with a Prompt elseFalse.'prompt_data': None if'has_prompt'is False, else:'indices_into_review_text': indices of'prompt_sentence'into the original review in the Yelp Academic Dataset.'review_rating': review-level star-rating for the review containing'sentence'in the Yelp Academic Dataset.'prompt_sentence': The prompt text.'review_id': review-level identifier for the review from the Yelp Academic Dataset containing'prompt_sentence'.
'model_1_label': prediction of Model 1 as described in the paper. The possible values are'positive','negative', and 'neutral'.'model_1_probs': probability distribution predicted by Model 1. The keys are('positive', 'negative', 'neutral')and the values are floats.'text_id': unique identifier for this entry.'label_distribution': response distribution from the MTurk validation task. The keys are('positive', 'negative', 'neutral')and the values are lists of anonymized MTurk ids, which are used consistently throughout the dataset.'gold_label': the label chosen by at least three of the five workers if there is one (possible values:'positive','negative', 'neutral', and'mixed'), elseNone.
To add the review texts to the 'prompt_data' field, one can extend the code above for Round 1 with the following function:
def add_review_text_round2(dataset, yelp_index):
for d in dataset:
if d['has_prompt']:
prompt_data = d['prompt_data']
review_text = yelp_index[prompt_data['review_id']]
# Check that we can find the sentence as expected:
start, end = prompt_data['indices_into_review_text']
assert review_text[start: end] == prompt_data['prompt_sentence']
prompt_data['review_text'] = review_text
return dataset
SST-dev format
{'hit_ids': ['s20533'],
'sentence': '-LRB- A -RRB- n utterly charming and hilarious film that reminded me of the best of the Disney comedies from the 60s.',
'tree': '(4 (2 (1 -LRB-) (2 (2 A) (3 -RRB-))) (4 (4 (2 n) (4 (3 (2 utterly) (4 (3 (4 charming) (2 and)) (4 hilarious))) (3 (2 film) (3 (2 that) (4 (4 (2 (2 reminded) (3 me)) (4 (2 of) (4 (4 (2 the) (4 best)) (2 (2 of) (3 (2 the) (3 (3 Disney) (2 comedies))))))) (2 (2 from) (2 (2 the) (2 60s)))))))) (2 .)))',
'text_id': 'sst-dev-validate-0000437',
'sst_label': '4',
'label_distribution': {'positive': ['w207', 'w3', 'w840', 'w135', 'w26'],
'negative': [],
'neutral': [],
'mixed': []},
'gold_label': 'positive'}
Details:
'hit_ids': List of Amazon Mechanical Turk Human Interface Tasks (HITs) in which this example appeared during validation. The values are anonymized but used consistently throughout the dataset.'sentence': The example text.'tree': The parsetree for the example as given in the SST distribution.'text_id': A new identifier for this example.'sst_label': The root-node label from the SST. Possible values'0','1''2','3', and'4'.'label_distribution':response distribution from the MTurk validation task. The keys are('positive', 'negative', 'neutral')and the values are lists of anonymized MTurk ids, which are used consistently throughout the dataset.'gold_label': the label chosen by at least three of the five workers if there is one (possible values:'positive','negative', 'neutral', and'mixed'), elseNone.
Models
Model 0 and Model 1 from the paper are available here:
https://drive.google.com/drive/folders/1dpKrjNJfAILUQcJPAFc5YOXUT51VEjKQ?usp=sharing
This repository includes a Python module dynasent_models.py that provides a Hugging Face-based wrapper around these (PyTorch) models. Simple examples:
import os
from dynasent_models import DynaSentModel
# `dynasent_model0` should be downloaded from the above Google Drive link and
# placed in the `models` directory. `dynasent_model1` works the same way.
model = DynaSentModel(os.path.join('models', 'dynasent_model0.bin'))
examples = [
"superb",
"They said the experience would be amazing, and they were right!",
"They said the experience would be amazing, and they were wrong!"]
model.predict(examples)
This should return the list ['positive', 'positive', 'negative'].
The predict_proba method provides access to the predicted distribution over the class labels; see the demo at the bottom of dynasent_models.py for details.
The following code uses load_dataset from above to reproduce the Round 2 dev-set report on Model 0 from the paper:
import os
from sklearn.metrics import classification_report
from dynasent_models import DynaSentModel
dev_filename = os.path.join('dynasent-v1.1', 'dynasent-v1.1-round02-dynabench-dev.jsonl')
dev = load_dataset(dev_filename)
X_dev, y_dev = zip(*[(d['sentence'], d['gold_label']) for d in dev])
model = DynaSentModel(os.path.join('models', 'dynasent_model0.bin'))
preds = model.predict(X_dev)
print(classification_report(y_dev, preds, digits=3))
For a fuller report on these models, see our paper and our model card.
Other files
Analysis notebooks
The following notebooks reproduce the dataset statistics, figures, and random example selections from the paper:
analyses_comparative.ipynbanalysis_round1.ipynbanalysis_round2.ipynbanalysis_sst_dev_revalidate.ipynb
The Python module dynasent_utils.py contains functions that support those notebooks, and dynasent.mplstyle helps with styling the plots.
Datasheet
The Datasheet for our dataset:
Model Card
The Model Card for our models:
Tests
The module test_dataset.py contains PyTest tests for the dataset. To use it, run
py.test -vv test_dataset.py
in the root directory of this repository.
Validation HIT code
The file validation-hit-contents.html contains the HTML/Javascript used in the validation task. It could be used directly on Amazon Mechanical Turk, by simply pasting its contents into the usual HIT creation window.
License
DynaSent has a Creative Commons Attribution 4.0 International License.
- Downloads last month
- 103