--- dataset_info: features: - name: query dtype: string - name: positive_passages sequence: string - name: negative_passages sequence: string splits: - name: train num_bytes: 361146987 num_examples: 398398 - name: dev num_bytes: 14493923 num_examples: 4030 - name: test num_bytes: 10891808 num_examples: 6795 download_size: 153841910 dataset_size: 386532718 configs: - config_name: default data_files: - split: train path: data/train-* - split: dev path: data/dev-* - split: test path: data/test-* --- # Dataset Detail this dataset is processed from 3 source of thai dataset consist of - miracl/miracl - facebook/xnli - castorini/mr-tydi - castorini/mr-tydi-corpus ## processing script here is the precessing script I use ### miracl/miracl ```python def create_miracl_datasets(datasets): """ nothing just extract texts """ datasets_ = { 'query': [], 'positive_passages': [], 'negative_passages': [], } for data in tqdm(datasets): datasets_['query'].append(data['query']) negative_passages = [] for negative_passage in data['negative_passages']: negative_passages.append(negative_passage['text']) datasets_['negative_passages'].append(negative_passages) positive_passages = [] for positive_passage in data['positive_passages']: positive_passages.append(positive_passage['text']) datasets_['positive_passages'].append(positive_passages) return Dataset.from_dict(datasets_) ``` ratio ```python DatasetDict({ train: Dataset({ features: ['query', 'positive_passages', 'negative_passages'], num_rows: 2972 }) eval: Dataset({ features: ['query', 'positive_passages', 'negative_passages'], num_rows: 366 }) test: Dataset({ features: ['query', 'positive_passages', 'negative_passages'], num_rows: 367 }) }) ``` ### facebook/xnli ```python def create_xnli_datasets(datasets): """ transform format of ['premise', 'hypothesis', 'label'] to ['query', 'positive_passages', 'negative_passages'] using contradiction as negative passage pair and neutral, entailment -> possitive passage pair premise as passage (premise -> evidence) hypothesis as query (hypothesis so called question so can be used as query) """ datasets_ = { 'query': [], 'positive_passages': [], 'negative_passages': [] } for data in tqdm(datasets): datasets_['query'].append(data['premise']) if data['label'] == 'contradiction': datasets_['positive_passages'].append([]) datasets_['negative_passages'].append([data['hypothesis']]) elif data['label'] == 'neutral' or 'entailment': datasets_['positive_passages'].append([data['hypothesis']]) datasets_['negative_passages'].append([]) return Dataset.from_dict(datasets_) ``` ratio ```python DatasetDict({ train: Dataset({ features: ['query', 'positive_passages', 'negative_passages'], num_rows: 392702 }) eval: Dataset({ features: ['query', 'positive_passages', 'negative_passages'], num_rows: 2490 }) test: Dataset({ features: ['query', 'positive_passages', 'negative_passages'], num_rows: 5010 }) }) ``` ### castorini/mr-tydi ```python def create_tydi_datasets(datasets, corpus, train = False): """ both dev, test set have only docid which may can be retrieve from the corpus """ cor_df = corpus.to_pandas() datasets_ = { 'query': [], 'positive_passages': [], 'negative_passages': [], } for data in tqdm(datasets): datasets_['query'].append(data['query']) if train: negative_passages = [] for negative_passage in data['negative_passages']: negative_passages.append(negative_passage['text']) datasets_['negative_passages'].append(negative_passages) else: datasets_['negative_passages'].append([]) positive_passages = [] for positive_passage in data['positive_passages']: search_value = positive_passage['docid'] text = cor_df[cor_df["docid"] == search_value].text.values[0] # if text.empty: # continue positive_passages.append(text) datasets_['positive_passages'].append(positive_passages) return Dataset.from_dict(datasets_) ``` ratio ```python DatasetDict({ train: Dataset({ features: ['query_id', 'query', 'positive_passages', 'negative_passages'], num_rows: 3319 }) dev: Dataset({ features: ['query_id', 'query', 'positive_passages', 'negative_passages'], num_rows: 807 }) test: Dataset({ features: ['query_id', 'query', 'positive_passages', 'negative_passages'], num_rows: 1190 }) }) ```