Answer extraction
1. Answer extraction
In this video, we'll explore how to extract answers to questions about guest reviews using Snowflake Cortex.2. Why use answer extraction?
This is useful when automating tasks like identifying complaints, extracting feedback on certain amenities, or answering business questions. It really excels with long documents such as reports and policies!3. A common business problem
The Customer Success team at Executive Resorts receives a high volume of reviews, many of which are very long. Ultimately, they want to quickly understand what the issue was and how they can take action to improve based on this feedback. This is, again, where Snowflake Cortex shines!4. Extracting an answer
The `extract_answer()` function helps us pinpoint the exact phrase that answers our question, without needing to read every review manually. To use it, we import the function from `snowflake.cortex`. We then call `extract_answer()` and set two arguments: `from_text`: The full body of text to analyze, and `question`: The specific query we want answered.5. Output
Printing the results, we get a clean, focused answer. We also see a score, which is the model's confidence that the text answers the question, with values ranging from zero (no confidence) to one (certain). This is useful, as we could assign a threshold, such as 0.7, below which we recommend human reviews. This review was only a few lines, but even if it were multiple paragraphs, we could still use an extract answer to avoid reading the whole review and instead produce a targeted insight. Even when a review includes multiple thoughts, the `extract_answer` function helps us pull the part that directly answers our question.6. Building a workflow
Let's apply this to our reviews table. Here, we query a low-rated review.7. SQL output
From the output, we can see the review spans several lines of text! Let's use Snowflake Cortex to find out what the main issue was.8. Asking a question
We first convert the SQL output into a pandas DataFrame and extract the review as a string variable called `negative_review`. Next, we pass it into `extract_answer()` along with a natural-language question. This lets us programmatically query our data and produce actionable feedback!9. Reviewing the response
The result shows a clear response to our question and a confidence score of around 0.76. We can use this information to inform how we collaborate with partners to ensure potential customers have clarity about our services.10. Limitations
As we saw, `extract_answer` is a very powerful tool, but like all AI tools, we should use it with caution. It may return partial answers or misinterpret vague questions. Keep questions short, focused, and use this tool on concise text whenever possible. Always review answers before using them in reports or customer-facing automation.11. Let's practice!
You've learned how to extract relevant information from a review, a powerful way to automate insights and actions. Now, head over to the exercises!Create Your Free Account
or
By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.