pietrolesci/joci
收藏数据集概述
本数据集为“full” JOCI数据集,文件名为joci.csv.zip,原始数据集可在此链接获取。
数据集处理
-
将
label列重命名为original_label。 -
创建新的
label列,使用以下映射关系进行转换:{ 0: "contradiction", 1: "contradiction",
2: "neutral", 3: "neutral", 4: "neutral", 5: "entailment", } -
将标签转换为NLI标准类别:
{"entailment": 0, "neutral": 1, "contradiction": 2}。
数据集创建代码
python import pandas as pd from datasets import Features, Value, ClassLabel, Dataset
读取数据
df = pd.read_csv("<path to folder>/joci.csv")
列名转换为小写
df.columns = df.columns.str.lower()
重命名标签列
df = df.rename(columns={"label": "original_label"})
编码标签
df["label"] = df["original_label"].map({
0: "contradiction",
1: "contradiction",
2: "neutral",
3: "neutral",
4: "neutral",
5: "entailment",
})
编码标签
df["label"] = df["label"].map({"entailment": 0, "neutral": 1, "contradiction": 2})
转换为数据集格式
features = Features({ "context": Value(dtype="string"), "hypothesis": Value(dtype="string"), "label": ClassLabel(num_classes=3, names=["entailment", "neutral", "contradiction"]), "original_label": Value(dtype="int32"), "context_from": Value(dtype="string"), "hypothesis_from": Value(dtype="string"), "subset": Value(dtype="string"), }) ds = Dataset.from_pandas(df, features=features) ds.push_to_hub("joci", token="<token>")



