# Pipeline inference with Dataset api

**URL:** <https://discuss.huggingface.co/t/pipeline-inference-with-dataset-api/12648>\
**Category:** 🤗Transformers\
**Created:** [December 8, 2021, 10:40pm UTC](https://discuss.huggingface.co/t/pipeline-inference-with-dataset-api/12648 "2021-12-08T22:40:42Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![hmanju](https://avatars.discourse-cdn.com/v4/letter/h/91b2a8/32.png) [@hmanju](https://discuss.huggingface.co/u/hmanju)\
**Post date:** [December 8, 2021, 10:40pm UTC](https://discuss.huggingface.co/t/pipeline-inference-with-dataset-api/12648/1 "2021-12-08T22:40:42Z")

</div>

I am running inference using the pipeline api. But I get the following warning which recommends using the Dataset api. How can I do so?

```auto
transformers4/lib/python3.8/site-packages/transformers/pipelines/base.py:899: 
UserWarning: You seem to be using the pipelines sequentially on GPU. 
In order to maximize efficiency please use a dataset
  warnings.warn()

```

```auto
sentiment_analysis = pipeline("sentiment-analysis", model="siebert/sentiment-roberta-large-english", device=0)

def roberta_sent(verb):
    
    result = sentiment_analysis(verb)[0]    
            
    return result["label"], result["score"]

df = pd.read_csv(file)

df["roberta_sentiment"] = df["sentences"].apply(roberta_sent)

```

---

<div class="post-metadata">

**Author:** ![cyrilw](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/cyrilw/32/4311_2.png) [@cyrilw](https://discuss.huggingface.co/u/cyrilw)\
**Post date:** [March 23, 2022, 2:22pm UTC](https://discuss.huggingface.co/t/pipeline-inference-with-dataset-api/12648/2 "2022-03-23T14:22:04Z")

</div>

Hi, I came across this warning as well. By any chance did you find a solution?

---

<div class="post-metadata">

**Author:** ![cameronw](https://avatars.discourse-cdn.com/v4/letter/c/edb3f5/32.png) [@cameronw](https://discuss.huggingface.co/u/cameronw)\
**Post date:** [March 30, 2022, 6:26pm UTC](https://discuss.huggingface.co/t/pipeline-inference-with-dataset-api/12648/3 "2022-03-30T18:26:16Z")

</div>

I found the following help in the documentation, but I haven’t implemented yet because I’m just doing a POC with 50 documents. Sharing now in case it helps you get started! 🙂

> **[Pipelines](https://huggingface.co/docs/transformers/main_classes/pipelines#transformers.pipeline)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

---

<div class="post-metadata">

**Author:** ![sowmiyan](https://avatars.discourse-cdn.com/v4/letter/s/58f4c7/32.png) [@sowmiyan](https://discuss.huggingface.co/u/sowmiyan)\
**Post date:** [May 12, 2022, 3:09pm UTC](https://discuss.huggingface.co/t/pipeline-inference-with-dataset-api/12648/4 "2022-05-12T15:09:27Z")

</div>

Having same issue while using T5-base-grammar-correction for grammer correction on my dataframe with text column

```auto
rom happytransformer import HappyTextToText
from happytransformer import TTSettings
from tqdm.notebook import tqdm
tqdm.pandas()

happy_tt = HappyTextToText("T5", "./t5-base-grammar-correction")
beam_settings = TTSettings(num_beams=5, min_length=1, max_length=30)
def grammer_pipeline(text):
    text = "gec: " + text
    result = happy_tt.generate_text(text, args=beam_settings)
    
    return result.text

df['new_text'] = df['original_text'].progress_apply(grammer_pipeline)

```

It runs very slow and provides the User Warning

```auto
/home/.local/lib/python3.6/site-packages/transformers/pipelines/base.py:908: UserWarning: You seem to be using the pipelines sequentially on GPU. In order to maximize efficiency please use a dataset
  UserWarning,

```

How to implement this to efficiently utilise GPUs?

---

<div class="post-metadata">

**Author:** ![roma999](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/roma999/32/13043_2.png) [@roma999](https://discuss.huggingface.co/u/roma999)\
**Post date:** [December 14, 2022, 5:36pm UTC](https://discuss.huggingface.co/t/pipeline-inference-with-dataset-api/12648/5 "2022-12-14T17:36:00Z")

</div>

What about you, have you found any solution yet? 😅

---

<div class="post-metadata">

**Author:** ![xiaobinbaby](https://avatars.discourse-cdn.com/v4/letter/x/e274bd/32.png) [@xiaobinbaby](https://discuss.huggingface.co/u/xiaobinbaby)\
**Post date:** [November 15, 2023, 4:12pm UTC](https://discuss.huggingface.co/t/pipeline-inference-with-dataset-api/12648/6 "2023-11-15T16:12:26Z")

</div>

Hi, I have met the same question. Run very slowly and present this warning. Is there any solution now?
