Hugging Face Datasets

Arbeta med Hugging Face

Jacob H. Marquez

Lead Data Engineer

hf_datasets1.jpg

1 https://huggingface.co/datasets
Arbeta med Hugging Face

hf_datasets2.jpg

1 https://huggingface.co/datasets
Arbeta med Hugging Face
Arbeta med Hugging Face
Arbeta med Hugging Face
Arbeta med Hugging Face

Installera datasets-paketet

 

pip install datasets

  • 🌐 Åtkomst
  • 📥 Ladda ned
  • 🔧 Använd
  • 🤝 Dela

hf_datasets.jpg

1 https://huggingface.co/docs/datasets/loading
Arbeta med Hugging Face

Ladda ned en datamängd

from datasets import load_dataset

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

$$

Split-parametern

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

Apache Arrow-datamängdsformat

 

Apache Arrow-datamängdsformat

1 https://arrow.apache.org/overview/
Arbeta med Hugging Face

Datamanipulering

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


# Filter for pattern " 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
Arbeta med Hugging Face

Datamanipulering

# Select the first two rows
sliced = filtered.select(range(2))


print(sliced)
Dataset({features: ['text'], num_rows: 2})
# Extract the 'text' for the first row
print(sliced[0]['text'])
Concentrazioni atmosferiche di PCDD/PCDF...
1 https://huggingface.co/docs/datasets/process#select-and-filter
Arbeta med Hugging Face

Nu kör vi en övning!

Arbeta med Hugging Face

Preparing Video For Download...