Skip to content

JSON output doesn't conform to pattern #74

Open

Description

Hello 👋,

When I try to generate JSON using the example in the basics_tutorial notebook with the phi2 model, the JSON generated doesn't conform to the structure specified:

Please summarize and extract key factors from the following text:
<text>
The 3 astronauts who flew to the International Space Station reached their destination today (May 31). The
crew successfully docked at 10:16 a.m. EDT, about 19 hours after blasting off from
NASA's Kennedy Space Center. The docking went smoothly, with the Crew Dragon's soft capture docking
mechanism attaching automatically at 10:16 a.m. EDT.</text>
Return as JSON:{shorttitle: 'Astronauts reach space station', who: '3 astronauts', what: 'docked at 10:16 a.m. EDT', when: 'May 31'}
## INPUT

##OUTPUT
{
    "shorttitle": "Astronauts reach space station",
    "who": "3 astronauts",
    "what": "docked at 10:16 a.m. EDT",
    "when": "May 31"
}
The text summarizes that three ast

(The generation doesn't stop-- I had to interrupt the kernel for it to stop)

There is JSON at the beginning, but it is missing some keys(quality_level, excitement_level).

I realize that phi2 is a relatively small model and limited in capability, but my understanding was that aici would constrain the output forcing specific tokens. In this case, shouldn't it have ensured that the keys specified are output?

Activity

  1. emrekiciman commented on Mar 15, 2024

    @emrekiciman
    Collaborator

    Hi Samrat, thanks for catching this bug. You are correct that the JSON is being incorrectly enforced in that tutorial notebook.

    Looking at the code, I see that the sample is setting the general structure of the JSON, but there is no stop token being enforced. This allows the underlying library to close the JSON object and continue with text generation. A quick fix is to add the ' quote character as a stop token for each of the gen calls for the fields.

    Let me make that quick fix, and then I'll also think about whether there's a more elegant way to do this --- like having the first token of the next fixed string be a stop token (though that might create other surprises as an implicit behavior).

  2. added
    bug
    good first issue
    on Mar 15, 2024
  3. superchargez commented on Mar 18, 2024

    @superchargez

    It is fixed? Can aici work with tiny llama (even 70M models?). Please update.

  4. mmoskal commented on Mar 25, 2024

    @mmoskal
    Contributor

    Yes, AICI does not place limits on the model size. However, you do need to have it integrated in whatever system you're using for inference!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions