Rag Use Your Knowledge dataset
Author: Blaizzy
Pull request: no

## Environment info
<!-- You can run the command `transformers-cli env` and copy-and-paste its output below.
     Don't forget to fill out the missing fields in that output! -->

- `transformers` version:
- Platform: Colab
- Python version: 3.7.10
- PyTorch version (CPU): 1.7.0

### Who can help

Models:
rag: @patrickvonplaten, @lhoestq

Library:

- tokenizers: @n1t0, @LysandreJik

## Information

The model I am using (Rag):

The problem arises when using:
* [ ] my own modified scripts: (give details below)

The tasks I am working on is:
* [ ] my own task or dataset: (give details below)

## To reproduce

Steps to reproduce the behavior:

1. Create a csv file with title and text 
2. Load the dataset
3. Map the split_document function
4. Map the embed function (error)

```
def embed(
    documents: dict,
    ctx_encoder: DPRContextEncoder, 
    ctx_tokenizer: DPRContextEncoderTokenizerFast
    ):
    """Compute the DPR embeddings of document passages"""
    input_ids = ctx_tokenizer(
        documents["title"], documents["text"], truncation=True,
        padding="longest", return_tensors='pt'
    )
    
    embeddings = ctx_encoder(
        input_ids["input_ids"], 
        return_dict=True).pooler_output
    
    return {'embeddings': embeddings.detach().cpu().numpy()}

# And compute the embeddings
ctx_encoder = DPRContextEncoder.from_pretrained(
    'facebook/dpr-ctx_encoder-multiset-base'
    )
ctx_tokenizer = DPRContextEncoderTokenizerFast.from_pretrained(
    'facebook/dpr-ctx_encoder-multiset-base'
    )
new_fts = Features(
    {
        'text': Value('string'), 
        'title': Value('string'), 
        'embeddings': Sequence(Value('float32'))
    }
)  # optional, save as float32 instead of float64 to save space
dataset = dataset.map(
    partial(embed, ctx_encoder = ctx_encoder, ctx_tokenizer=ctx_tokenizer),
    features = new_fts
)
```
### Error
```
ArrowInvalid                              Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/datasets/arrow_dataset.py in _map_single(self, function, with_indices, input_columns, batched, batch_size, drop_last_batch, remove_columns, keep_in_memory, load_from_cache_file, cache_file_name, writer_batch_size, features, disable_nullable, fn_kwargs, new_fingerprint, rank, offset, update_data)
   1412             if update_data:
-> 1413                 writer.finalize()  # close_stream=bool(buf_writer is None))  # We only close if we are writing in a file
   1414         except (Exception, KeyboardInterrupt):

22 frames
ArrowInvalid: Could not convert [-0.007409881334751844, 0.0715881809592247, -0.130095437169075, 0.08213236927986145, -0.06481412053108215, 0.219411239027977, 0.2758248746395111, -0.24343284964561462, -0.17551296949386597, -0.16576780378818512, -0.19957710802555084, 0.513848602771759, -0.2469034492969513, -0.27209365367889404, -0.019221562892198563, 0.3769649565219879, 0.47224175930023193, -0.5267099142074585, -0.3105331361293793, -0.3371395170688629, -0.2927161753177643, -0.7542601227760315, -0.17370374500751495, -0.024053143337368965, 0.14522959291934967, 0.2945793867111206, 0.03297216817736626, -0.0938640609383583, -0.34509730339050293, 0.3848630487918854, -0.1607687622308731, 0.08243361860513687, 0.036992475390434265, -0.5837609767913818, -0.057669747620821, 0.33589160442352295, -0.6164276003837585, 0.22745771706104279, 0.2599221467971802, 0.021962007507681847, 0.38935932517051697, 0.0007948490092530847, -0.71791011095047, 0.008848031982779503, -0.2997898459434509, -0.17859186232089996, -1.5019792318344116, 0.151197612285614, -0.5586768984794617, -0.008638408035039902, -0.49596720933914185, 0.4330417513847351, 0.16217979788780212, 0.27230459451675415, -0.20549386739730835, 0.24903732538223267, -0.18732021749019623, -0.6536538004875183, 0.09260211139917374, -0.49740439653396606, -0.007311557419598103, 0.3489222824573517, -0.14408843219280243, 0.3663439154624939, -0.09016768634319305, 0.7361327409744263, -0.013332066126167774, 0.241610586643219, -0.779755353927...

During handling of the above exception, another exception occurred:

ArrowInvalid                              Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/pyarrow/error.pxi in pyarrow.lib.check_status()

ArrowInvalid: Could not convert [-0.007409881334751844, 0.0715881809592247, -0.130095437169075, 0.08213236927986145, -0.06481412053108215, 0.219411239027977, 0.2758248746395111, -0.24343284964561462, -0.17551296949386597, -0.16576780378818512, -0.19957710802555084, 0.513848602771759, -0.2469034492969513, -0.27209365367889404, -0.019221562892198563, 0.3769649565219879, 0.47224175930023193, -0.5267099142074585, -0.3105331361293793, -0.3371395170688629, -0.2927161753177643, -0.7542601227760315, -0.17370374500751495, -0.024053143337368965, 0.14522959291934967, 0.2945793867111206, 0.03297216817736626, -0.0938640609383583, -0.34509730339050293, 0.3848630487918854, -0.1607687622308731, 0.08243361860513687, 0.036992475390434265, -0.5837609767913818, -0.057669747620821, 0.33589160442352295, -0.6164276003837585, 0.22745771706104279, 0.2599221467971802, 0.021962007507681847, 0.38935932517051697, 0.0007948490092530847, -0.71791011095047, 0.008848031982779503, -0.2997898459434509, -0.17859186232089996, -1.5019792318344116, 0.151197612285614, -0.5586768984794617, -0.008638408035039902, -0.49596720933914185, 0.4330417513847351, 0.16217979788780212, 0.27230459451675415, -0.20549386739730835, 0.24903732538223267, -0.18732021749019623, -0.6536538004875183, 0.09260211139917374, -0.49740439653396606, -0.007311557419598103, 0.3489222824573517, -0.14408843219280243, 0.3663439154624939, -0.09016768634319305, 0.7361327409744263, -0.013332066126167774, 0.241610586643219, -0.779755353927...
```
## Expected behavior
Return the dataset embedding so I can index it and run inference .

<!-- A clear and concise description of what you would expect to happen. -->


Comments:
Hi ! It looks like you `embed` functions expects a batch of documents as input.
Can you try to set `batched=True` in your call to `dataset.map` ?

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/master/CONTRIBUTING.md) are likely to be ignored.