Fix conditional logic in _info and _load_hf_data_from_remote for correct label assignment and data fetching
Browse files1. **'_info' enhancements and bug fix**
- Updated the if conditions so that any subset_id ending with "domain" now uses DOMAIN_LABELS, and any ending with "intent" uses INTENT_LABELS. This improves the logic by removing hard-coded comparisons and making it more dynamic.
2. **Refined '_load_hf_data_from_remote'**
- Simplified the logic in _load_hf_data_from_remote by using subset_id.endswith(...) to check for "domain" or "intent", and dynamically constructing the HF_REMOTE_REF as mteb/mtop_{subset}. This ensures that datasets.load_dataset fetches the correct dataset, either mteb/mtop_domain or mteb/mtop_intent.
3. **Kept backward‑compatible defaults**
- Left `DEFAULT_CONFIG_NAME` unchanged to `mtop_intent_classification_domain_source` so that existing workflows continue to work without any extra branches or special cases.
4. **Version updates**
- Increased `_SOURCE_VERSION` to `1.0.1` and set `_SEACROWD_VERSION` to `2025.04.22` to reflect these changes and fixes.
@@ -50,8 +50,8 @@ _URL = "https://huggingface.co/datasets/mteb/"
|
|
50 |
|
51 |
|
52 |
_SUPPORTED_TASKS = [Tasks.INTENT_CLASSIFICATION]
|
53 |
-
_SOURCE_VERSION = "1.0.
|
54 |
-
_SEACROWD_VERSION = "
|
55 |
|
56 |
|
57 |
class MTOPIntentClassificationDataset(datasets.GeneratorBasedBuilder):
|
@@ -95,9 +95,9 @@ class MTOPIntentClassificationDataset(datasets.GeneratorBasedBuilder):
|
|
95 |
)
|
96 |
|
97 |
elif self.config.schema == "seacrowd_text":
|
98 |
-
if self.config.subset_id
|
99 |
labels = DOMAIN_LABELS
|
100 |
-
elif self.config.subset_id
|
101 |
labels = INTENT_LABELS
|
102 |
else:
|
103 |
raise ValueError(f"Received unexpected schema name {self.config.name}")
|
@@ -117,9 +117,13 @@ class MTOPIntentClassificationDataset(datasets.GeneratorBasedBuilder):
|
|
117 |
|
118 |
def _load_hf_data_from_remote(self, split: str) -> datasets.DatasetDict:
|
119 |
"""Load dataset from HuggingFace."""
|
120 |
-
if self.config.subset_id
|
|
|
|
|
|
|
|
|
121 |
raise ValueError(f"Received unexpected schema name {self.config.name}")
|
122 |
-
HF_REMOTE_REF = "/
|
123 |
_hf_dataset_source = datasets.load_dataset(HF_REMOTE_REF, "th", split=split)
|
124 |
return _hf_dataset_source
|
125 |
|
|
|
50 |
|
51 |
|
52 |
_SUPPORTED_TASKS = [Tasks.INTENT_CLASSIFICATION]
|
53 |
+
_SOURCE_VERSION = "1.0.1"
|
54 |
+
_SEACROWD_VERSION = "2025.04.22"
|
55 |
|
56 |
|
57 |
class MTOPIntentClassificationDataset(datasets.GeneratorBasedBuilder):
|
|
|
95 |
)
|
96 |
|
97 |
elif self.config.schema == "seacrowd_text":
|
98 |
+
if self.config.subset_id.endswith("domain"):
|
99 |
labels = DOMAIN_LABELS
|
100 |
+
elif self.config.subset_id.endswith("intent"):
|
101 |
labels = INTENT_LABELS
|
102 |
else:
|
103 |
raise ValueError(f"Received unexpected schema name {self.config.name}")
|
|
|
117 |
|
118 |
def _load_hf_data_from_remote(self, split: str) -> datasets.DatasetDict:
|
119 |
"""Load dataset from HuggingFace."""
|
120 |
+
if self.config.subset_id.endswith("domain"):
|
121 |
+
subset = "domain"
|
122 |
+
elif self.config.subset_id.endswith("intent"):
|
123 |
+
subset = "intent"
|
124 |
+
else:
|
125 |
raise ValueError(f"Received unexpected schema name {self.config.name}")
|
126 |
+
HF_REMOTE_REF = f"mteb/mtop_{subset}"
|
127 |
_hf_dataset_source = datasets.load_dataset(HF_REMOTE_REF, "th", split=split)
|
128 |
return _hf_dataset_source
|
129 |
|