add dataset card
Browse files
README.md
CHANGED
|
@@ -42,3 +42,73 @@ configs:
|
|
| 42 |
- split: intents
|
| 43 |
path: intents/intents-*
|
| 44 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
- split: intents
|
| 43 |
path: intents/intents-*
|
| 44 |
---
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
# banking77
|
| 48 |
+
|
| 49 |
+
This is a text classification dataset. It is intended for machine learning research and experimentation.
|
| 50 |
+
|
| 51 |
+
This dataset is obtained via formatting another publicly available data to be compatible with our [AutoIntent Library](https://deeppavlov.github.io/AutoIntent/index.html).
|
| 52 |
+
|
| 53 |
+
## Usage
|
| 54 |
+
|
| 55 |
+
It is intended to be used with our [AutoIntent Library](https://deeppavlov.github.io/AutoIntent/index.html):
|
| 56 |
+
|
| 57 |
+
```python
|
| 58 |
+
from autointent import Dataset
|
| 59 |
+
|
| 60 |
+
dream = Dataset.from_datasets("AutoIntent/banking77")
|
| 61 |
+
```
|
| 62 |
+
|
| 63 |
+
## Source
|
| 64 |
+
|
| 65 |
+
This dataset is taken from `PolyAI/banking77` and formatted with our [AutoIntent Library](https://deeppavlov.github.io/AutoIntent/index.html):
|
| 66 |
+
|
| 67 |
+
```python
|
| 68 |
+
# define utils
|
| 69 |
+
import requests
|
| 70 |
+
import json
|
| 71 |
+
from autointent import Dataset
|
| 72 |
+
from datasets import load_dataset
|
| 73 |
+
|
| 74 |
+
def load_json_from_url(github_file: str):
|
| 75 |
+
raw_text = requests.get(github_file).text
|
| 76 |
+
return json.loads(raw_text)
|
| 77 |
+
|
| 78 |
+
def convert_banking77(banking77_train, shots_per_intent, intent_names):
|
| 79 |
+
all_labels = sorted(banking77_train.unique("label"))
|
| 80 |
+
n_classes = len(intent_names)
|
| 81 |
+
assert all_labels == list(range(n_classes))
|
| 82 |
+
|
| 83 |
+
classwise_utterance_records = [[] for _ in range(n_classes)]
|
| 84 |
+
intents = [
|
| 85 |
+
{
|
| 86 |
+
"id": i,
|
| 87 |
+
"name": name,
|
| 88 |
+
}
|
| 89 |
+
for i, name in enumerate(intent_names)
|
| 90 |
+
]
|
| 91 |
+
|
| 92 |
+
for b77_batch in banking77_train.iter(batch_size=16, drop_last_batch=False):
|
| 93 |
+
for txt, intent_id in zip(b77_batch["text"], b77_batch["label"], strict=False):
|
| 94 |
+
target_list = classwise_utterance_records[intent_id]
|
| 95 |
+
if shots_per_intent is not None and len(target_list) >= shots_per_intent:
|
| 96 |
+
continue
|
| 97 |
+
target_list.append({"utterance": txt, "label": intent_id})
|
| 98 |
+
|
| 99 |
+
utterances = [rec for lst in classwise_utterance_records for rec in lst]
|
| 100 |
+
return Dataset.from_dict({"intents": intents, "train": utterances})
|
| 101 |
+
|
| 102 |
+
# load
|
| 103 |
+
file_url = "https://huggingface.co/datasets/PolyAI/banking77/resolve/main/dataset_infos.json"
|
| 104 |
+
dataset_description = load_json_from_url(file_url)
|
| 105 |
+
intent_names = dataset_description["default"]["features"]["label"]["names"]
|
| 106 |
+
banking77 = load_dataset("PolyAI/banking77", trust_remote_code=True)
|
| 107 |
+
|
| 108 |
+
# convert
|
| 109 |
+
banking77_converted = convert_banking77(
|
| 110 |
+
banking77["train"],
|
| 111 |
+
shots_per_intent=None,
|
| 112 |
+
intent_names=intent_names
|
| 113 |
+
)
|
| 114 |
+
```
|