Skip to content

Commit

Permalink
Change variable name (options_alias_to_original)
Browse files Browse the repository at this point in the history
  • Loading branch information
parkervg committed Jul 22, 2024
1 parent 9ab6343 commit d9807aa
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions blendsql/ingredients/builtin/qa/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __call__(
prompt = ""
serialized_db = context.to_string() if context is not None else ""
prompt += "Answer the question for the table. "
modified_option_to_original = {}
options_alias_to_original = {}
if long_answer:
prompt += "Make the answer as concrete as possible, providing more context and reasoning using the entire table.\n"
else:
Expand All @@ -43,11 +43,11 @@ def __call__(
add_first_word = True
for option in options:
option = str(option)
for modified_option in [option.title(), option.upper()]:
_options.add(modified_option)
modified_option_to_original[modified_option] = option
for option_alias in [option.title(), option.upper()]:
_options.add(option_alias)
options_alias_to_original[option_alias] = option
if add_first_word:
modified_option_to_original[option.split(" ")[0]] = option
options_alias_to_original[option.split(" ")[0]] = option
options = _options
prompt += f"\n\nQuestion: {question}"
if table_title is not None:
Expand All @@ -65,7 +65,7 @@ def __call__(
model, prompt=prompt, choices=[re.escape(str(i)) for i in options]
)
# Map from modified options to original, as they appear in DB
response: str = modified_option_to_original.get(_response, _response)
response: str = options_alias_to_original.get(_response, _response)
else:
response = generate.text(
model, prompt=prompt, max_tokens=max_tokens, stop_at="\n"
Expand Down

0 comments on commit d9807aa

Please sign in to comment.