guidance icon indicating copy to clipboard operation
guidance copied to clipboard

ValueError: No valid option generated in #select!

Open Sam1320 opened this issue 2 years ago • 5 comments

Error was raised running the following:

prompt = guidance('''Is the following sentence offensive? Please answer with a single word, either "Yes", "Nein", or "Vielleicht".
Sentence: {{example}}
Answer:{{#select "answer" logprobs='logprobs'}} Ja{{or}} Nein{{or}} Vielleicht{{/select}}''')
prompt = prompt(example='I hate tacos.')
prompt

I tried multiple variations. When the answer format specified at the beginning of the prompt and the options inside the select tag vary then very often this error happens.

Sam1320 avatar May 18 '23 17:05 Sam1320

Can you share what version of guidance you are using? I can't get similar errors on the latest 0.0.47

slundberg avatar May 18 '23 19:05 slundberg

Maybe try importing differently:

from guidance import Guidance
from guidance.llms import OpenAI

# example llm setup
# There is also a `token` parameter if necessary.
davinci = OpenAI(model='text-davinci-003')

guidance = Guidance('guidance-name')
prompt = guidance('''
Is the following sentence offensive? Please answer with a single word, either "Yes", "Nein", or "Vielleicht".
Sentence: {{example}}
Answer:{{#select "answer" logprobs='logprobs'}} Ja{{or}} Nein{{or}} Vielleicht{{/select}}
''', llm=davinci)

executed_prompt = prompt(example='I hate tacos.')

amanape avatar May 18 '23 22:05 amanape

@slundberg my version is indeed 0.0.47. I tried the way you suggested @amanape but it also raised the same error.

This is another example that causes the error and is the closest to the example given in the readme:

import guidance
guidance.llm = guidance.llms.OpenAI('text-davinci-003')
guidance.llms.OpenAI.cache.clear()

prompt = guidance('''Is the following sentence offensive? Please answer with a single word, either "Yes", "No", or "Maybe".
Sentence: {{example}}
Answer:{{#select "answer" logprobs='logprobs'}} Yes{{or}} Nein{{or}} Maybe{{/select}}''')
prompt = prompt(example='I hate tacos.')
prompt

Sam1320 avatar May 19 '23 06:05 Sam1320

@Sam1320 This seems to have worked for me https://github.com/microsoft/guidance/issues/40#issuecomment-1554084184

amanape avatar May 19 '23 08:05 amanape

@Sam1320 This seems to have worked for me #40 (comment)

Indeed also for me. Thanks @amanape!

Sam1320 avatar May 19 '23 09:05 Sam1320

Thanks for reporting this! This should now be fixed in 0.0.49 :)

slundberg avatar May 19 '23 19:05 slundberg