microsoft / unilm

Large-scale Self-supervised Pre-training Across Tasks, Languages, and Modalities
https://aka.ms/GeneralAI
MIT License
20.19k stars 2.55k forks source link

how to control output length in Kosmos-2 #1240

Open sheldonchiu opened 1 year ago

sheldonchiu commented 1 year ago

The output from using the default "detailed caption" prompt can be very long, is there any ways to control the output length without decreasing the accuracy?

I have tried a smaller value for max-len-b, but this will only truncate the result.

donglixp commented 1 year ago

https://fairseq.readthedocs.io/en/latest/command_line_tools.html?highlight=length%20penalty#Generation

--lenpen | length penalty: <1.0 favors shorter, >1.0 favors longer sentencesDefault: 1 -- | --
sheldonchiu commented 1 year ago

I have tried changing lenpen by passing it as an arg --lenpen 0.1 or setting it in generate_predictions() by cfg.generation.lenpen = 0.1, but the output is the same as before.