# SentencePiece Model: Passing Flag into Function

**URL:** <https://discuss.pytorch.org/t/sentencepiece-model-passing-flag-into-function/117125>\
**Category:** nlp\
**Created:** [April 5, 2021, 2:49pm UTC](https://discuss.pytorch.org/t/sentencepiece-model-passing-flag-into-function/117125 "2021-04-05T14:49:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![J\_Johnson](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/j_johnson/32/55494_2.png) [@J\_Johnson](https://discuss.pytorch.org/u/J_Johnson)\
**Post date:** [April 5, 2021, 2:49pm UTC](https://discuss.pytorch.org/t/sentencepiece-model-passing-flag-into-function/117125/1 "2021-04-05T14:49:11Z")

</div>

The code is:

```auto
generate_sp_model('example.csv', vocab_size=20000, model_prefix='example', model_type='char')

```

But I get the following because my lines are 7000 characters long:

```auto
trainer_interface.cc(287) LOG(WARNING) Found too long line (7034 > 4192).
trainer_interface.cc(289) LOG(WARNING) Too long lines are skipped in the training.
trainer_interface.cc(290) LOG(WARNING) The maximum length can be changed with --max_sentence_length=<size> flag.
trainer_interface.cc(315) LOG(INFO) Loaded all 0 sentences
trainer_interface.cc(321) LOG(INFO) Skipped 12048 too long sentences.

```

I see that there may be some way to run this from command prompt(see the third WARNING above). But is there a way to pass the `max_sentence_length` flag into the above code to make this work as a python function?

Thanks!
