# How to pass pipeline parameters when using sagemaker DataSerializer?

**URL:** <https://discuss.huggingface.co/t/how-to-pass-pipeline-parameters-when-using-sagemaker-dataserializer/26963>\
**Category:** Amazon SageMaker\
**Created:** [November 29, 2022, 9:17pm UTC](https://discuss.huggingface.co/t/how-to-pass-pipeline-parameters-when-using-sagemaker-dataserializer/26963 "2022-11-29T21:17:05Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![marshmellow77](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/marshmellow77/32/3279_2.png) [@marshmellow77](https://discuss.huggingface.co/u/marshmellow77)\
**Post date:** [November 29, 2022, 10:21pm UTC](https://discuss.huggingface.co/t/how-to-pass-pipeline-parameters-when-using-sagemaker-dataserializer/26963/2 "2022-11-29T22:21:15Z")

</div>

Given that SageMaker Hugging Face Inference Toolkit [builds on top of the pipeline feature](https://huggingface.co/docs/sagemaker/inference#inference-toolkit---api-description), I took a look at the [pipeline documentation for ASR](https://huggingface.co/docs/transformers/v4.24.0/en/main_classes/pipelines#transformers.AutomaticSpeechRecognitionPipeline), and it seems to me that parameters like `chunk_length_s` and `stride_length_s` are specified when **creating** the pipeline, not at every inference request. I don’t have enough experience with ASR to say if that makes sense or not, but that’s what it looks like to me.

Now, how to fix your problem with that information? Again, I have very little experience with ASR workloads, but at the very least I would think you could create a custom inference script, create and use the ASR pipeline in that script and pass the parameters to the endpoint when creating it with the `deploy()` method via the `env` dictionary. Should be sth along the lines of

```auto
model.deploy(..., env={'chunk_length_s': 5, 'stride_length_s': 10}, ...)

```

and in the inference script:

```auto
def model_fn():
    pipe = pipeline("automatic-speech-recognition", chunk_length_s=os.environ('chunk_length_s'), ...

```

I haven’t tested this but maybe give it a try? Or, at the very least, I hope it sparks some other ideas how to go about this 🙂

Cheers  
Heiko

---

_[View the full topic](https://discuss.huggingface.co/t/how-to-pass-pipeline-parameters-when-using-sagemaker-dataserializer/26963)._
