lmql icon indicating copy to clipboard operation
lmql copied to clipboard

Tokens removed by STOPS_BEFORE count towards the length of the output

Open JasperDekoninck opened this issue 1 year ago • 2 comments

In the following query, we would not expect the query to end on the first occurrence of "wall" (output sentence: "what did the fish say when it hit the wall?"), since the length of the sequence right before the word is 37. However, since the word "wall" is also counted in the overall length of the sequence, len(JOKE) > 40 evaluates to true, even though it shouldn't yet.

argmax
   """A list of good dad jokes. A indicates the punchline
   Q: How does a penguin build its house?
   A: Igloos it together.
   Q: Which knight invented King Arthur's Round Table?
   A: Sir Cumference.
   Q:[JOKE]"""
from
   "openai/text-davinci-003"
where
   STOPS_BEFORE(JOKE, "wall") and len(JOKE) > 40

JasperDekoninck avatar May 05 '23 12:05 JasperDekoninck

i got the saame,is there solution?

j4acks0n avatar Jun 05 '23 06:06 j4acks0n

One workaround for now is to use STOPS_AT instead and to strip the suffix in code.

lbeurerkellner avatar Jun 05 '23 16:06 lbeurerkellner