Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON output doesn't conform to pattern #74

Open
samrat opened this issue Mar 14, 2024 · 3 comments
Open

JSON output doesn't conform to pattern #74

samrat opened this issue Mar 14, 2024 · 3 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@samrat
Copy link

samrat commented Mar 14, 2024

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?

@emrekiciman
Copy link
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).

@emrekiciman emrekiciman added bug Something isn't working good first issue Good for newcomers labels Mar 15, 2024
@superchargez
Copy link

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

@mmoskal
Copy link
Member

mmoskal commented Mar 25, 2024

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
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants