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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON Former Example: "No valid option generated in #select!" #67

Closed
lolz0r opened this issue May 19, 2023 · 5 comments
Closed

JSON Former Example: "No valid option generated in #select!" #67

lolz0r opened this issue May 19, 2023 · 5 comments

Comments

@lolz0r
Copy link

lolz0r commented May 19, 2023

The bug
Guidance throws an error when trying to run the JSONformer example while using the 'mosaicml/mpt-7b-instruct' model. The error message asks to create a github issue as "this should not happen :)"

To Reproduce

import guidance
guidance.llm = guidance.llms.transformers.MPTChat('mosaicml/mpt-7b-instruct', device="cpu")

# define a jsonformer schema
json_schema = {
    "type": "object",
    "properties": {
        "name": {"type": "string"},
        "age": {"type": "number"},
        "is_student": {"type": "boolean"},
        "courses": {
            "type": "array",
            "items": {"type": "string"}
        }
    }
}

# run the guidance program
prompt = "Generate a person's information based on the following schema:"
program = guidance(prompt + "\n" + jsonformer2guidance(json_schema))
out = program()

System info (please complete the following information):
MacOS 11.7.3, CPU only.

@slundberg
Copy link
Collaborator

Thanks can you include the guidance version you are using? 0.0.49 includes a fix for errors like this

@lolz0r
Copy link
Author

lolz0r commented May 20, 2023

This is my pip show

Name: guidance
Version: 0.0.49
Summary: A guidance language for controlling large language models.
Home-page: https://github.com/slundberg/guidance
Author: Scott Lundberg and Marco Tulio Ribeiro
Author-email: scott.lundberg@microsoft.com
License: 
Location: /usr/local/lib/python3.9/site-packages
Requires: diskcache, nest-asyncio, numpy, openai, parsimonious, platformdirs, pygtrie, requests, tiktoken
Required-by: 

@Mihaiii
Copy link
Contributor

Mihaiii commented May 20, 2023

I can confirm the issue with version 0.0.49.

@slundberg I replaced in the above script guidance.llm = guidance.llms.transformers.MPTChat('mosaicml/mpt-7b-instruct') with guidance.llm = guidance.llms.OpenAI("text-ada-001") and I get "The OpenAI API does not support Guidance pattern controls! Please either switch to an endpoint that does, or don't use the pattern argument to gen.".

Is this error expected? I'm asking because the very first example in readme uses OpenAi API with "gen" and it works just fine. The error message is strange.

Mihaiii added a commit to Mihaiii/guidance that referenced this issue May 20, 2023
…hen we would have a token that represents a text that only ends with the option

Fixes guidance-ai#67
@slundberg
Copy link
Collaborator

I can confirm the issue with version 0.0.49.

@slundberg I replaced in the above script guidance.llm = guidance.llms.transformers.MPTChat('mosaicml/mpt-7b-instruct') with guidance.llm = guidance.llms.OpenAI("text-ada-001") and I get "The OpenAI API does not support Guidance pattern controls! Please either switch to an endpoint that does, or don't use the pattern argument to gen.".

Is this error expected? I'm asking because the very first example in readme uses OpenAi API with "gen" and it works just fine. The error message is strange.

It is because that notebook uses the pattern=.... argument. We could add an option to remove that so OpenAI can work as well. It might also be nice to add examples of other formats like YAML etc.

@slundberg
Copy link
Collaborator

I am closing this issue for now because I don't get the error anymore with 0.0.55. Let me know if there is a problem still.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants