noamgat / lm-format-enforcer

Enforce the output format (JSON Schema, Regex etc) of a language model
MIT License
1.42k stars 65 forks source link

Speed comparison with other frameworks #24

Closed hypocoristique closed 10 months ago

hypocoristique commented 10 months ago

I consider using this great repository (that is compatible with vLLM!) to enforce the output with a regex. Has anyone compared the inference speed of lm-format-enforcer with outlines or guidance?

noamgat commented 10 months ago

There hasn't been official benchmarks yet as far as I know. However, it's hard to do apples-to-apples comparisons, for several reasons: 1 - lm-format-enforcer is the only one that supports batching, so the comparison could only be in a batch-less scenario. 2 - The libraries have different strategies, and thus different caching mechanisms. Do you use the same regex for all calls, or a different regex per call? The performance ratio could change between libraries based on this. 3 - Have any of the libraries taken heuristic inaccuracies in their format support to improve performance? Etc.

So, I will do my best to list a few advantages of the difference libraries, performance wise.