|
| 1 | +.. _humanize: |
| 2 | + |
| 3 | +Humanize |
| 4 | +======== |
| 5 | + |
| 6 | +EDSL comes with built-in methods for generating web-based versions of your surveys and collecting and analyzing human responses. |
| 7 | + |
| 8 | +*Note:* This page provides information about EDSL code methods for launching surveys, gathering human responses, and analyzing results from your workspace. |
| 9 | +For more information about building surveys interactively, see the :ref:`survey_builder` page. |
| 10 | + |
| 11 | + |
| 12 | +How it works |
| 13 | +------------ |
| 14 | + |
| 15 | +1. Create a `Survey` (see the :ref:`surveys` section for details and examples). |
| 16 | +2. Use the `run` method to launch your survey with AI :ref:`agents` and :ref:`language_models`. |
| 17 | +3. Use the `humanize` method to generate a web-based version of your survey, with a link that can be shared with human respondents and another link for the admin page at your Coop account where you can access responses interactively. *Note:* You may want to modify your LLM-based survey to add or change questions specific to human respondents before calling the `humanize` method, e.g., to add screening questions for aligning human respondents and AI agent personas. |
| 18 | +4. Share the web survey link with human respondents. |
| 19 | +5. Use the `Coop().get_project_human_responses` method to collect the responses in a `Results` object. |
| 20 | +6. Analyze the results together with your LLM results. |
| 21 | + |
| 22 | + |
| 23 | +Example |
| 24 | +------- |
| 25 | + |
| 26 | +Code and results for the example below are also accessible at this downloadable `notebook at Coop <https://www.expectedparrot.com/content/RobinHorton/human-results-example-notebook>`_. |
| 27 | + |
| 28 | +.. code-block:: python |
| 29 | +
|
| 30 | + # Import modules from EDSL |
| 31 | + from edsl import ( |
| 32 | + QuestionYesNo, |
| 33 | + QuestionNumerical, |
| 34 | + QuestionLinearScale, |
| 35 | + Survey, |
| 36 | + Agent, |
| 37 | + Model, |
| 38 | + Coop |
| 39 | + ) |
| 40 | +
|
| 41 | + # Create a survey with different question types |
| 42 | + q1 = QuestionYesNo( |
| 43 | + question_name="drive", |
| 44 | + question_text="Do you drive?" |
| 45 | + ) |
| 46 | +
|
| 47 | + q2 = QuestionNumerical( |
| 48 | + question_name="count", |
| 49 | + question_text="How many vehicles do you currently own or lease?", |
| 50 | + ) |
| 51 | +
|
| 52 | + q3 = QuestionLinearScale( |
| 53 | + question_name="enjoy", |
| 54 | + question_text="On a scale from 1 to 10, how much do you enjoy driving?", |
| 55 | + question_options=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], |
| 56 | + option_labels={1: "Hate it", 10: "Love it"}, |
| 57 | + ) |
| 58 | +
|
| 59 | + # Create a survey with the questions |
| 60 | + survey = Survey(questions=[q1, q2, q3]) |
| 61 | +
|
| 62 | + # Create an AI agent to respond to the survey |
| 63 | + agent = Agent( |
| 64 | + traits={ |
| 65 | + "persona": "You are a middle-aged mom working on a software startup.", |
| 66 | + "location": "Massachusetts", |
| 67 | + } |
| 68 | + ) |
| 69 | +
|
| 70 | + # Select a language model to generate the responses |
| 71 | + model = Model("gemini-1.5-pro", service_name="google") |
| 72 | +
|
| 73 | + # Run the survey with the AI agent and model |
| 74 | + results = survey.by(agent).by(model).run() |
| 75 | +
|
| 76 | + # Generate a web-based version of the survey for human respondents |
| 77 | + web_survey_info = survey.humanize() |
| 78 | +
|
| 79 | + # Create a Coop instance |
| 80 | + coop = Coop() |
| 81 | +
|
| 82 | + # Get human responses from Coop |
| 83 | + human_responses = coop.get_project_human_responses(web_survey_info["uuid"]) |
| 84 | +
|
| 85 | + # Combine results (you can add Results objects for the same survey) |
| 86 | + combined_results = results + human_results |
| 87 | +
|
| 88 | +
|
| 89 | +*We are continually adding features for launching hybrid LLM and human surveys, so check back for updates!* |
| 90 | +*If you are interested in testing new features please reach out at anytime for credits and access.* |
| 91 | + |
0 commit comments