Skip to content

Instantly share code, notes, and snippets.

@johnjosephhorton
Created June 26, 2024 20:31
Show Gist options
  • Save johnjosephhorton/75e8bd41c20a84991d7afb739c0ac2fa to your computer and use it in GitHub Desktop.
Save johnjosephhorton/75e8bd41c20a84991d7afb739c0ac2fa to your computer and use it in GitHub Desktop.
from edsl import QuestionList, ScenarioList, QuestionFreeText
import random
q = QuestionList(question_text = "Generate a list of 10 fruits", question_name = "fruits")
fruits = q()
def list_to_pref(items):
return " > ".join(items)
preferences = [list_to_pref(random.sample(fruits, len(fruits))) for _ in range(20)]
scenarios = ScenarioList.from_list("preference", preferences)
q = QuestionFreeText(
question_text = """Imagine a person is describing their taste in fruits to someone who will shop for them.
Generate one sentence of text that try to capture this person's preferences for fruits, without mentioning the fruits by name.
It is OK to mention dislikes and negative opinions.
Their preferences are: {{ preference}}
""",
question_name = "pref_paragraph")
results = q.by(scenarios).run()
results.select("pref_paragraph", 'preference').print(format = "rich")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment