- You already have a codebook: turn its categories and definitions into structured questions, then apply them to your data.
- You want to develop the labels from the data: use exploratory questions first, organize their answers into a codebook, then use that codebook to construct structured labeling questions.
Start with an existing codebook
A codebook names your labels and explains when each applies. For a multiple-choice question, its category names becomequestion_options, and its definitions become part of question_text. A checkbox question can use the same approach when several labels may apply to one item.
This example labels four service requests as Billing, Access, Feature request, or Other. It also asks for a supporting quotation. The codebook distinguishes a payment problem from an access problem, including when the inaccessible page concerns billing. The sample requests have no preassigned labels:
QuestionMultipleChoice produces the category label in answer.category; QuestionFreeText produces supporting text in answer.evidence. add_targeted_memory(evidence, category) supplies the category question and its answer to the evidence question, so it knows which choice to support. Add more questions to label other characteristics of the same request.
Generate and inspect the labels
With model access configured, run the job and view each classification beside its source and evidence:
Actual answers come from your chosen model. Read the labels and quotations alongside the source, especially where category boundaries matter. To save the labeled data:
Develop labels through exploratory questions
When you do not yet know which categories will be useful, start by asking open-ended questions about your material. Their answers help you decide what the later structured questions should ask and which choices they should offer. The code below reusesrecords from the example above; it does not use the existing codebook.
1. Explore the material
This first survey proposes issue categories and describes what each person needs. For a larger dataset, begin with a selection of records covering the range of material you want to label:2. Consolidate the suggestions into a codebook
You can choose and define the labels yourself, making this a two-stage workflow: explore, then label. Or add a question that considers the exploratory answers together. HereQuestionExtract asks for a draft with two named fields: a list of labels and their definitions, including rules for ambiguous cases:
draft_codebook["labels"] and draft_codebook["definitions"], ask further questions to refine them, or explore additional records. For large collections, consolidate suggestions in batches before combining them into one codebook.
3. Use the chosen labels in structured questions
The next question takes its answer options directly from the codebook you developed. The definitions explain how to choose among those options. Apply this shared question to all records, including any used during exploration:QuestionCheckBox instead when several discovered themes may apply, or construct several questions for different characteristics. For example, exploration might reveal that topic and urgency should be labeled separately.
Choose the right labeling question
The response type determines what kind of labeling you can do:
For a larger dataset, import records from a file or DataFrame and reuse the same survey. Qualitative coding develops the example of assigning overlapping themes to interview excerpts.
