Hugging Face 数据集

使用 Hugging Face

Jacob H. Marquez

Lead Data Engineer

Hugging Face 数据集

1 https://huggingface.co/datasets
使用 Hugging Face

Hugging Face 数据集

1 https://huggingface.co/datasets
使用 Hugging Face
使用 Hugging Face
使用 Hugging Face
使用 Hugging Face

安装 Datasets 包

 

pip install datasets

  • 🌐 访问
  • 📥 下载
  • 🔧 使用
  • 🤝 共享

Apache Arrow 数据集

1 https://huggingface.co/docs/datasets/loading
使用 Hugging Face

下载数据集

from datasets import load_dataset

data = load_dataset("IVN-RIN/BioBERT_Italian")

$$

Split 参数

data = load_dataset("IVN-RIN/BioBERT_Italian", split="train")
1 https://huggingface.co/docs/datasets/v2.15.0/loading
使用 Hugging Face

Apache Arrow 数据集格式

 

Apache Arrow 数据集

1 https://arrow.apache.org/overview/
使用 Hugging Face

数据处理

data = load_dataset("IVN-RIN/BioBERT_Italian", split="train")


# 过滤包含模式 " bella " filtered = data.filter(lambda row: " bella " in row['text']) print(filtered)
Dataset({
    features: ['text'],
    num_rows: 1122
})
1 https://huggingface.co/docs/datasets/process#select-and-filter
使用 Hugging Face

数据处理

# 选择前两行
sliced = filtered.select(range(2))


print(sliced)
Dataset({features: ['text'], num_rows: 2})
# 提取第一行的 'text'
print(sliced[0]['text'])
Concentrazioni atmosferiche di PCDD/PCDF...
1 https://huggingface.co/docs/datasets/process#select-and-filter
使用 Hugging Face

Ayo berlatih!

使用 Hugging Face

Preparing Video For Download...