This playbook is for analytics engineers and data pipeline operators who receive raw, free-text survey responses and need to convert them into structured, analyzable records. Use this prompt when a model has already generated a narrative answer or when you are processing verbatim open-ended responses from a survey platform. The prompt produces typed records with question mapping, answer normalization, sentiment scores, and theme tags. It is designed for post-collection repair and normalization, not for generating survey responses. This workflow assumes you have already extracted the raw text and now need to impose structure for downstream analytics, dashboards, or statistical coding.
Prompt
Survey Response Text to Structured Answers Prompt Template

When to Use This Prompt
Defines the ideal job-to-be-done, required context, and clear boundaries for using the survey response normalization prompt.
The ideal user has a batch of free-text responses that map to known survey questions but lack consistent formatting. For example, a verbatim response like 'I was really frustrated with the checkout process, it took forever to load' needs to become a record with a normalized answer, a sentiment score of -0.7, and a theme tag of 'UX/Performance'. This prompt is not a replacement for a survey platform's native export. Do not use it when you need real-time response generation, when the survey instrument itself is unknown, or when the raw text contains multi-turn conversational threads that require dialogue state tracking. The prompt assumes a single response per input and a known question catalog.
Before using this prompt, ensure you have a defined question catalog with unique IDs and a controlled vocabulary for theme tags. The prompt's value comes from its ability to simulate inter-rater reliability by producing consistent coding across thousands of responses, but it requires a clear target schema. If your survey includes skip logic or branching, pre-process the raw text to associate each response with its specific question ID before calling this prompt. For high-stakes analytics (e.g., regulatory reporting or academic research), always run the eval harness described in the implementation section to measure coding consistency and flag low-confidence normalizations for human review.
Use Case Fit
Where this prompt works, where it fails, and what you must provide before putting it into production.
Good Fit: High-Volume Survey Normalization
Use when: you have thousands of free-text survey responses that need consistent coding into categories, sentiment scores, and theme tags. Guardrail: Run inter-rater reliability simulation across a 50-sample golden set before trusting the pipeline on the full dataset.
Bad Fit: Single-Response Ad-Hoc Analysis
Avoid when: a stakeholder asks you to 'just summarize what this one respondent meant.' The prompt is designed for batch normalization, not one-off interpretation. Guardrail: For single responses, use a simpler extraction prompt without the coding consistency overhead.
Required Inputs: Question-Answer Pairs Plus Codebook
Risk: The model will invent categories if you don't provide a codebook. Guardrail: Always pass [QUESTION_TEXT], [RESPONSE_TEXT], and [CODEBOOK] with defined categories, sentiment anchors, and theme taxonomy. Missing any of these degrades output consistency.
Operational Risk: Coding Drift Across Batches
Risk: The model's interpretation of codebook categories can shift between batches, especially when response distributions change. Guardrail: Run a stability check every 500 responses—compare category distributions and spot-check 20 records against a human coder.
Operational Risk: Sentiment Score Calibration
Risk: Sentiment scores drift toward neutral when responses are ambiguous, masking real signal. Guardrail: Require the model to output a confidence flag alongside each sentiment score. Route low-confidence records to human review before aggregation.
Boundary: Not a Replacement for Survey Design
Risk: Teams treat this prompt as a fix for poorly designed surveys with ambiguous questions. Guardrail: If more than 20% of responses require the model to infer meaning, flag the survey instrument for redesign rather than relying on post-hoc normalization.
Copy-Ready Prompt Template
A reusable prompt template with square-bracket placeholders for converting free-text survey responses into structured, coded answer records.
This template is the core instruction set for converting a batch of free-text survey responses into a structured JSON array. It is designed to be copied directly into your prompt management system, API call, or evaluation harness. The prompt instructs the model to map each response to its corresponding question, normalize the answer, assign a sentiment score, and tag relevant themes. Before using this template, you must have your survey questions, the raw response text, and a defined set of acceptable theme tags ready to insert into the placeholders.
textYou are an analytics engineer converting free-text survey responses into structured, coded records. Your task is to process the provided survey responses and output a single, valid JSON array of answer objects. Do not include any text outside the JSON array. ## SURVEY QUESTIONS [QUESTION_LIST] ## RAW SURVEY RESPONSES [RAW_RESPONSES] ## OUTPUT SCHEMA Output a JSON array where each object has the following keys: - "response_id": A unique identifier from the input, or a generated UUID if none exists. - "question_id": The identifier of the question this response answers, mapped from [QUESTION_LIST]. - "question_text": The exact text of the question being answered. - "raw_answer": The original, unedited answer text. - "normalized_answer": A cleaned and standardized version of the answer (e.g., expand abbreviations, correct obvious typos, standardize casing). - "sentiment_score": A string, one of "positive", "neutral", "negative", or "mixed", based on the sentiment expressed in the answer. - "theme_tags": An array of strings from the approved list in [THEME_TAXONOMY] that apply to this answer. If no themes match, use an empty array. - "confidence": A number between 0.0 and 1.0 indicating your confidence in the accuracy of the coding for this specific response. ## THEME TAXONOMY [THEME_TAXONOMY] ## CONSTRAINTS - Map each response to the correct question using the context and any provided IDs. - Do not invent new theme tags; use only those provided in [THEME_TAXONOMY]. - If an answer is nonsensical, empty, or a non-answer (e.g., "asdf", "no comment"), set the "normalized_answer" to null, "sentiment_score" to "neutral", and "theme_tags" to an empty array. - Ensure the output is strictly valid JSON with no trailing commas.
To adapt this template for your pipeline, replace the square-bracket placeholders with your specific data. [QUESTION_LIST] should be a structured list of your survey questions with their IDs, which the model uses for mapping. [RAW_RESPONSES] is the batch of free-text answers you need to process. [THEME_TAXONOMY] must be an exhaustive list of allowed theme strings; the model is constrained to this list to ensure coding consistency. For high-stakes analysis, such as employee engagement or clinical surveys, you should add a [RISK_LEVEL] constraint that triggers a lower confidence score or a flag for human review when sentiment is strongly negative or themes indicate a critical event. After running this prompt, always validate the output JSON against the defined schema and use an LLM-as-judge eval to check inter-rater reliability against a human-coded golden dataset before trusting the results in a dashboard.
Prompt Variables
Inputs the prompt needs to work reliably. Validate these before sending the prompt.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[SURVEY_RESPONSE_TEXT] | The raw free-text survey response to be converted into structured answers | The checkout process was fine but the app crashed twice when I tried to apply the discount code. Frustrating. | Must be a non-empty string. Check for null, empty, or whitespace-only inputs before sending. Truncate to model context window minus prompt overhead. |
[SURVEY_QUESTIONS] | The list of survey questions the respondent was answering, used to map text to specific questions | [{"question_id": "Q1", "text": "How was your checkout experience?"}, {"question_id": "Q2", "text": "Did you encounter any issues?"}] | Must be a valid JSON array of objects with question_id and text fields. Validate JSON parse before prompt assembly. Reject if empty array. |
[ANSWER_CATEGORIES] | The predefined coding categories or answer options to normalize responses into | [{"category_id": "positive", "label": "Positive"}, {"category_id": "negative", "label": "Negative"}, {"category_id": "neutral", "label": "Neutral"}] | Must be a valid JSON array of objects with category_id and label fields. Validate that category_ids are unique. Reject if fewer than 2 categories provided. |
[THEME_TAXONOMY] | The list of allowed theme tags for classifying response topics | ["usability", "performance", "pricing", "customer_support", "feature_request"] | Must be a valid JSON array of non-empty strings. Validate no duplicate tags. Reject if empty. Tags should be lowercase with underscores for multi-word themes. |
[OUTPUT_SCHEMA] | The target JSON schema describing the expected output structure | {"type": "object", "properties": {"answers": {"type": "array", "items": {"type": "object", "properties": {"question_id": {"type": "string"}, "normalized_answer": {"type": "string"}, "category": {"type": "string"}, "sentiment_score": {"type": "number"}, "themes": {"type": "array", "items": {"type": "string"}}, "confidence": {"type": "number"}}}}}} | Must be a valid JSON Schema object. Validate with a JSON Schema validator before prompt assembly. Required fields must be marked. Reject if schema is not parseable. |
[SENTIMENT_SCALE] | The numeric range and interpretation for sentiment scoring | {"min": -1.0, "max": 1.0, "negative_label": "negative", "neutral_threshold": 0.1, "positive_label": "positive"} | Must be a valid JSON object with min, max, and neutral_threshold fields. Validate that min < neutral_threshold < max. Reject if scale is inverted or thresholds overlap. |
[CONFIDENCE_THRESHOLD] | The minimum confidence score required for an answer to be accepted without human review | 0.7 | Must be a number between 0.0 and 1.0. Validate type coercion from string inputs. Reject if outside range. Answers below this threshold should be flagged for human review in the output. |
Implementation Harness Notes
How to wire the survey response structuring prompt into a reliable data pipeline with validation, retries, and quality gating.
This prompt is designed to sit inside a post-extraction normalization pipeline, not as a standalone chat interface. The typical flow begins when a raw survey response—often a block of free text, a transcript snippet, or a semi-structured markdown field—fails to parse into your target analytics schema. The application layer should first attempt a direct structured output call. If that call returns a parse_error, a schema_mismatch, or a confidence score below your threshold, route the raw text and the failed parse metadata into this repair prompt as the [RAW_SURVEY_TEXT] and [TARGET_SCHEMA] inputs. The [QUESTION_CONTEXT] placeholder should be populated with the original survey question text, the expected answer type (single-select, multi-select, Likert scale, open-ended), and any valid category codes from your codebook. This context is critical for the model to perform accurate answer normalization and theme tagging rather than inventing its own categories.
The application harness must enforce a strict validation loop around the model's output. After the prompt returns a JSON payload, validate it against the expected schema immediately: check that question_id matches the input, normalized_answer is not null for required questions, sentiment_score is a float between -1.0 and 1.0, and theme_tags contains only strings from your approved taxonomy. If validation fails, do not silently drop the record. Implement a retry strategy with a maximum of two additional attempts, feeding the validation error messages back into the [PREVIOUS_ERRORS] placeholder on the next call. After three total failures, route the record to a human review queue with the raw text, the failed outputs, and the validator error log attached. For high-volume pipelines, use a model that supports structured output guarantees (like GPT-4o with response_format or Claude with tool use) for the initial attempt, and reserve this free-text repair prompt for the fallback path only. This keeps latency and cost low for the 80-90% of responses that parse correctly on the first try.
Logging and observability are non-negotiable for this workflow. Every invocation should log the survey_id, response_id, attempt_number, model_used, latency_ms, validation_passed (boolean), and a hash of the raw input text. This lets you track repair rates over time, identify survey questions that consistently produce unparseable responses, and measure inter-rater reliability by comparing the model's coded categories against a human-coded sample. For the inter-rater reliability simulation mentioned in the topic description, run a weekly batch job that pulls 100 randomly selected repaired records, sends them to a second model call with a different temperature setting, and computes Cohen's kappa between the two sets of theme_tags and normalized_answer fields. Flag any question where kappa drops below 0.7 for prompt or codebook review. Do not ship this prompt without building a dashboard that shows repair volume, validation pass rates, and human-approval queue depth—these metrics will tell you whether the prompt is actually reducing manual work or just moving it downstream.
Expected Output Contract
Fields, data types, and validation rules for the structured JSON output produced by the Survey Response Text to Structured Answers prompt. Use this contract to build a post-processing validator or to configure a downstream ingestion schema.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
survey_response_id | string | Must match the [RESPONSE_ID] input exactly. Fail if missing or altered. | |
answers | array of objects | Array length must equal the number of questions in [QUESTION_MAP]. Fail if count mismatch. | |
answers[].question_id | string | Must match a key from the [QUESTION_MAP] input. Fail on unknown or hallucinated IDs. | |
answers[].normalized_answer | string or number | Type must match the expected_type in [QUESTION_MAP] for this question_id. Coerce if safe; flag if coercion fails. | |
answers[].sentiment_score | number | Must be a float between -1.0 and 1.0 inclusive. Null allowed if sentiment is not applicable. Fail on out-of-range values. | |
answers[].theme_tags | array of strings | Each tag must be drawn from the [ALLOWED_THEMES] list if provided. Fail on hallucinated tags not in the allowed set. Empty array allowed. | |
answers[].confidence | number | Must be a float between 0.0 and 1.0 inclusive. Values below [CONFIDENCE_THRESHOLD] should trigger human review in the harness. | |
coding_notes | string | Free text field for coder rationale. Must not exceed 500 characters. Truncate and flag if longer. Null allowed. |
Common Failure Modes
Production failures when converting free-text survey responses into structured answer records, and how to prevent them before they corrupt your analytics pipeline.
Theme Tag Drift
What to watch: The model invents theme tags not present in your taxonomy, or applies inconsistent labels across similar responses. A response about 'wait times' gets tagged 'customer_service' in one record and 'operations' in another. Guardrail: Supply a closed enum of allowed theme tags in the prompt. Run a post-extraction validator that rejects any tag not in the approved list and route outliers to a human review queue.
Sentiment Score-Text Mismatch
What to watch: The model assigns a positive sentiment score to a clearly negative response, or vice versa. This happens when the model latches onto a single positive word in an otherwise critical comment. Guardrail: Add an eval step that samples 5% of records and compares the sentiment score against a second LLM judge prompt. Flag records where the score and text polarity diverge by more than a threshold for manual correction.
Question-to-Answer Misalignment
What to watch: The model maps a survey response to the wrong question, especially when questions are semantically similar or when respondents answered out of order. A comment about 'parking' gets mapped to the 'facilities' question instead of the 'parking' question. Guardrail: Include the full question text and question ID in the prompt context. Add a validation check that verifies the extracted answer is semantically relevant to the mapped question using a lightweight similarity threshold.
Hallucinated Answers for Skipped Questions
What to watch: The model fabricates an answer, sentiment, or theme for a question the respondent skipped or left blank. This inflates response counts and introduces noise into your analytics. Guardrail: Explicitly instruct the model to return null or a designated skip token for unanswered questions. Add a post-processing rule that drops any record where the source text contains no evidence for the extracted answer.
Inconsistent Coding Across Batches
What to watch: When processing surveys in batches, the model applies different coding logic to identical responses across different API calls. This destroys inter-rater reliability and makes trend analysis unreliable. Guardrail: Freeze the prompt template and model version. Run a consistency eval by including a set of 10-20 gold-standard responses in every batch and comparing the model's coding against expected labels. Alert if agreement drops below 90%.
Multi-Language Response Confusion
What to watch: The model receives a survey response in a language it wasn't expecting and either misinterprets the sentiment, applies English-only theme tags incorrectly, or hallucinates a translation. Guardrail: Add a language detection step before extraction. Route non-primary-language responses to a translation prompt first, or use a model with explicit multilingual support. Always preserve the original response text alongside the structured record for auditability.
Evaluation Rubric
Run these checks on a golden dataset of 50-100 manually coded survey responses before shipping the prompt. Each row defines a pass standard, a failure signal, and a test method to catch regressions early.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Question-to-Answer Mapping Accuracy | 95% of mapped answers reference the correct source question ID | Answer content assigned to wrong question ID or orphaned without a question reference | Parse output JSON and assert |
Answer Normalization Consistency | Normalized answers match golden normalized text for 90% of records | Normalized text changes meaning, drops key qualifiers, or introduces synonyms not present in source | Compute string similarity between |
Sentiment Score Calibration | Sentiment scores are within ±1 point of golden labels on a 1-5 scale for 90% of records | Sentiment score is inverted, neutral when clearly positive/negative, or missing when text contains clear sentiment | Calculate mean absolute error between |
Theme Tag Precision | Precision of assigned theme tags is at least 85% against golden tags | Theme tags include categories not supported by the source text or miss obvious themes present in golden labels | Compute precision = true positive tags / total predicted tags per record; average across dataset and assert >= 0.85 |
Theme Tag Recall | Recall of assigned theme tags is at least 80% against golden tags | Theme tags omit categories that human coders consistently identified in the response | Compute recall = true positive tags / total golden tags per record; average across dataset and assert >= 0.80 |
Coding Consistency Across Similar Responses | Responses with semantically equivalent content receive identical category codes in 90% of cases | Two responses expressing the same sentiment or theme receive different category codes or conflicting sentiment scores | Cluster responses by golden category label; assert that predicted |
Inter-Rater Reliability Simulation | Fleiss' kappa between model output and three human coders is at least 0.70 for categorical fields | Model coding pattern diverges significantly from human coder distribution on key categorical variables | Compute Fleiss' kappa across model predictions and three golden human coder labels for |
Hallucinated Content Detection | Zero records contain fabricated quotes, invented respondent details, or themes not present in source text | Output includes a direct quote not found in the input, a theme with no textual evidence, or a sentiment score for an empty response | For each record, verify that |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Use the base prompt with a frontier model (GPT-4o, Claude 3.5 Sonnet). Remove strict output schema enforcement and accept JSON with minor field variations. Focus on getting the coding logic right before hardening the format.
Watch for
- Inconsistent theme tags across responses
- Sentiment scores that don't match the text
- Missing question-to-answer mapping when surveys have skip logic

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us