roboflow / inference

A fast, easy-to-use, production-ready inference server for computer vision supporting deployment of many popular model architectures and fine-tuned models.
https://inference.roboflow.com
Other
1.38k stars 133 forks source link

Florence finetunes in workflows #794

Closed probicheaux closed 2 weeks ago

probicheaux commented 2 weeks ago

Description

A few notable changes to florence models:

Why we set no_repeat_ngram_size=0:

I found a very sneaky bug destroying the ability of the model to generate valid json, where this parameter was set to 3. Having the parameter set to 3 means that once the model has seen a sequence of 3 tokens, it can never repeat that sequence.

Here's the generation for a receipt json before and after making this change: Generation before:

{'<RECEIPT>': '{"subtotal": "$27.36", "total":{"29.96"}'}

Generation after:

{'<RECEIPT>': '{"subtotal": "$27.36", "total": "$29.96"}'}

Here's why -- here's the tokens the model generated after I fixed the parameter.

['</s>', '<s>', '{"', 'sub', 'total', '":', ' "$', '27', '.', '36', '",', ' "', 'total', '":', ' "$', '29', '.', '96', '"}', '</s>']

Notice the repeated sequence of tokens:

'total', '":', ' "$',

that the model was unable to generate before this change.

Type of change

Please delete options that are not relevant.

How has this change been tested, please provide a testcase or example of how you tested the change?

tested and deployed thouroughly on localhost

Any specific deployment considerations

no

Docs

probicheaux commented 2 weeks ago

@PawelPeczek-Roboflow good to go?