Replies: 0 comments 1 reply
-
Thank you so much for putting the time to do these benchmarks, this is really helpful. It looks like these times are in second; if that's the case I am really surprised as they are at odds with what we observe in our benchmarks in |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
cc @cpfiffer, following up on the discussion from #180
My colleague @frankdvd has done some analysis of the time it takes to build a
RegexGuide
based on the complexity of the input json schema, which I'll paste below. We also saw similar results using theVocabulary, Index, Guide
method shown on the readme.It looks like we're doing something wrong, since it's taking quite a long time to compile these guides for relatively simple json schemas. When we try the same thing with
lm-format-enforcer
, we don't see a meaningful increase in time taken to compile a token enforcer for the same schemas.On the related issue where we had a user passing in an invalid schema, you had mentioned I was able to get this to compile in 80-90ms using our internal API. I had assumed you were talking about
outlines-core
, but maybe not? If there is a super secret sauce that y'all aren't open sourcing, I'd be happy to email you about it, but I did want to have this discussion in the open if we're just usingoutlines-core
wrong.Here's the anaylsis:
I did some experiments to measure the performance of the
outlines
, and try to find the root case of the hang/slowness. At first I thought it was some special keyword or syntax that was causing the hang, so I wasted some time trying to troubleshoot what was causing the problem. I eventually realized that the root cause of the problem was so simple that the number of fileds in an object would exponentially affect the computation time.Test 1: # of fields in 1 objects vs time
Example schema when n = 3:
We can see that the time grows exponentially as n increases.
Test 2: # of json object in depth nested vs time
Example schema when n = 3:
We can see that the time grows linearly as n increases, so the depth is not the root cause.
Test 3: total number of fields in a 2 depth json with nested object contains 6 fields vs time
Example schema when n = 12:
Test 4: total number of fields in a 2 depth json with nested object contains 3 fields vs time
Example schema when n = 9:
conclusion
if we want to control the size of the input to avoid timeout or hang, the regex generation needs to less than 30s(I guess):
According to test1/3/4, the maximum number of fields in each object must be less than 9. And the total number of fields in the whole json needs to be less than 20.
I'm not sure how many tools/api's would still be available if the above restrictions were applied to our api.......
Python code to reproduce this:
Beta Was this translation helpful? Give feedback.
All reactions