Add FewRel Dataset
State: closed | Author: gchhablani (CONTRIBUTOR)

Hi,

This PR closes this [Card](https://github.com/huggingface/datasets/projects/1#card-53285184) and Issue #1757.

I wasn't sure how to add `pid2name` along with the dataset so I added it as a separate configuration. For each (head, tail, tokens) triplet, I have created one example. I have added the dictionary key as `"relation"` in the dataset. Additionally, for `pubmed_unsupervised`, I kept `"relation":""` in the dictionary.

Please recommend better alternatives, if any.

Thanks,
Gunjan

Comments: Hi @lhoestq,

Sorry for the late response. What do you mean when you say "adding names to default config"? Should I handle "pid2name" in the same config as "default"?

Yes I was thinking of having the pid2name field available in the default configuration (and therefore only have one config). What do you think ?

Hi @lhoestq,

Sorry again, the last couple of weeks were a bit busy for me. I am wondering how do you want me to achieve that. Using a custom BuilderConfig which takes in whether it is the regular data or "pid2name"? "pid2name" is only useful for "train_wiki", "val_nyt" and "val_wiki". So, based on my understanding, it would look like this:

```python
wiki_data = load_dataset('few_rel','train_wiki')
id2name = load_dataset('few_rel','pid2name')
```
and this will be handled in the multiple configs.


A better alternative could be providing name of the relationship in only "train_wiki", "val_nyt" and "val_wiki" as an extra feature in the dataset, and doing away with "pid2name" entirely. I'll only download pid2name if any of those datasets are requested, and then during generation I'll return the list with the dataset under "names" feature. How does this sound?

EDIT:
There is one issue with the second approach, the entire pid2name is saved with all three datasets - "train_wiki", "val_nyt" and "val_wiki" ([see code below](https://github.com/huggingface/datasets/pull/1823#issuecomment-786402026)). In dummy data, I can address this by manually editing the pid2name to contain only a few id-name pairs, those matching with the examples in the corresponding example file. But this seems to be inefficient for the entire dataset - storing the same file in multiple places.

Okay, I apologize, I guess I finally understand what is required.

Basically, using:

```python
few_rel = load_dataset('few_rel')
```
should give all the files. This seems difficult since "pid2name" has a different format. Any suggestions on this?

Yes that's it, sorry if that wasn't clear !

Hi @lhoestq,

Since pid2name has different features from the rest of the files, how will I add them to the same config?

Do we want to exclude pid2name totally and add "names" to every example?

If I understand correctly each sample in the "default" config has one relation, and each relation has corresponding names in pid2name.
Would it be possible to also include the names in the "default" configuration for each sample ? The names of one sample can be retrieved using the relation id no ?

Yes, that can be done. But for some files, the name is already given instead of ID. Only "train_wiki", "val_wiki", "val_nyc" have IDs. For others, I can set the names equal to a list of key.

I think that's fine as long as we mention this processing explicitly in the dataset card.

Hi @lhoestq,

I have added the changes. Please let me know in case of any remaining issues.

Thanks,
Gunjan

Hi @lhoestq,

Thanks for fixing it and approving :)