|
| 1 | +# 📤 Push a QATestset to the Hugging Face Hub |
| 2 | + |
| 3 | +**Learn how to upload and manage your QATestset on the Hugging Face Hub using the `push_to_hf_hub` feature.** |
| 4 | + |
| 5 | +This tutorial will guide you through the steps to push a dataset to the Hugging Face Hub and load it back for reuse. |
| 6 | + |
| 7 | +## Install Required Dependencies |
| 8 | + |
| 9 | +Before you begin, ensure you have the necessary libraries installed. Run the following command to install the `datasets` and `huggingface_hub` packages: |
| 10 | + |
| 11 | +```bash |
| 12 | +pip install datasets huggingface_hub |
| 13 | +``` |
| 14 | + |
| 15 | +## Authenticate with Hugging Face |
| 16 | + |
| 17 | +To enable access to your account, set your Hugging Face authentication token (`HF_TOKEN`). You can generate your token from your [Hugging Face account settings](https://huggingface.co/settings/tokens). |
| 18 | + |
| 19 | +## Push Your Dataset to the Hub |
| 20 | + |
| 21 | +Use the `push_to_hf_hub` method to upload your dataset to the Hugging Face Hub. Replace `<username>` with your Hugging Face username and `<dataset_name>` with the desired name for your dataset: |
| 22 | + |
| 23 | +This example demonstrates how to load a `QATestset` from the file `test_set.jsonl` and push it to the Hugging Face Hub: |
| 24 | + |
| 25 | +```python |
| 26 | +from giskard.rag.testset import QATestset |
| 27 | +test_set = QATestset.load("test_set.jsonl") |
| 28 | +test_set.push_to_hf_hub("<username>/<dataset_name>") |
| 29 | +``` |
| 30 | + |
| 31 | +Once the dataset is successfully pushed, it will be available on your Hugging Face profile. |
| 32 | + |
| 33 | +## Load the Dataset from the Hub |
| 34 | + |
| 35 | +To reuse the dataset, you can load it back using the `load_from_hf_hub` method. This example demonstrates how to load the dataset and convert it to a pandas DataFrame for inspection: |
| 36 | + |
| 37 | +```python |
| 38 | +from giskard.rag.testset import QATestset |
| 39 | +dset = QATestset.load_from_hf_hub("<username>/<dataset_name>") |
| 40 | +dset.to_pandas().head() |
| 41 | +``` |
| 42 | + |
| 43 | +Replace `<username>` and `<dataset_name>` with the appropriate values. |
| 44 | + |
| 45 | +## Benefits of Using the Hugging Face Hub |
| 46 | + |
| 47 | +By leveraging this integration, you can: |
| 48 | + |
| 49 | +- Seamlessly share datasets across projects and collaborators. |
| 50 | +- Reuse datasets without the need for manual file transfers. |
| 51 | +- Access datasets directly from the Hugging Face Hub for streamlined workflows. |
| 52 | + |
| 53 | +Start pushing your datasets today and take advantage of the collaborative power of the Hugging Face Hub! |
0 commit comments