voorhs commited on
Commit
e592202
·
1 Parent(s): e70a9df

add dataset card

Browse files
Files changed (1) hide show
  1. README.md +53 -0
README.md CHANGED
@@ -42,3 +42,56 @@ configs:
42
  - split: intents
43
  path: intents/intents-*
44
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  - split: intents
43
  path: intents/intents-*
44
  ---
45
+
46
+ # snips
47
+
48
+ This is a text classification dataset. It is intended for machine learning research and experimentation.
49
+
50
+ This dataset is obtained via formatting another publicly available data to be compatible with our [AutoIntent Library](https://deeppavlov.github.io/AutoIntent/index.html).
51
+
52
+ ## Usage
53
+
54
+ It is intended to be used with our [AutoIntent Library](https://deeppavlov.github.io/AutoIntent/index.html):
55
+
56
+ ```python
57
+ from autointent import Dataset
58
+
59
+ dream = Dataset.from_datasets("AutoIntent/banking77")
60
+ ```
61
+
62
+ ## Source
63
+
64
+ This dataset is taken from `benayas/snips` and formatted with our [AutoIntent Library](https://deeppavlov.github.io/AutoIntent/index.html):
65
+
66
+ ```python
67
+ # define util
68
+ from datasets import load_dataset
69
+ from autointent import Dataset
70
+
71
+ def convert_snips(snips_train):
72
+ intent_names = sorted(snips_train.unique("category"))
73
+ name_to_id = dict(zip(intent_names, range(len(intent_names)), strict=False))
74
+ n_classes = len(intent_names)
75
+
76
+ classwise_utterance_records = [[] for _ in range(n_classes)]
77
+ intents = [
78
+ {
79
+ "id": i,
80
+ "name": name,
81
+ }
82
+ for i, name in enumerate(intent_names)
83
+ ]
84
+
85
+ for batch in snips_train.iter(batch_size=16, drop_last_batch=False):
86
+ for txt, name in zip(batch["text"], batch["category"], strict=False):
87
+ intent_id = name_to_id[name]
88
+ target_list = classwise_utterance_records[intent_id]
89
+ target_list.append({"utterance": txt, "label": intent_id})
90
+
91
+ utterances = [rec for lst in classwise_utterance_records for rec in lst]
92
+ return Dataset.from_dict({"intents": intents, "train": utterances})
93
+
94
+ # load and format
95
+ snips = load_dataset("benayas/snips")
96
+ snips_converted = convert_snips(snips["train"])
97
+ ```