Icon

Aspect-based Sentiment Analysis

<p>This workflow demonstrates how <strong>a few-shot prompt</strong> can be used to perform <strong>aspect-based sentiment analysis </strong>an how to validate the model's response. It showcases <strong>response control techniques </strong>by guiding the model with labelled examples and checking whether the predicted<strong> output follows the intended format (string or JSON</strong>).</p><p>The workflow processes product review data for laptops, combining review content with few-shot examples to generate aspect-specific prompts. It then sends these prompts to an LLM, which is expected to identify both the aspect and the <strong>corresponding sentiment</strong>. After the response is received, <strong>validation</strong> steps compare the output against the original prompt, checking for consistency.</p>

Prompt engineering - create few-shot prompt examples

Prompt engineering - create the full prompt for each review with instructions and examples

Set up the OpenAI API key, authenticate, and select the LLM. Send the prompt to LLM to extract aspect and sentiment.

Import few-shot examples


Convert the JSON response into table, extract aspect and sentiment, and evaluate output consistency

Aspect Based Sentiment Analysis


This workflow demonstrates how a few-shot prompt can be used to perform aspect-based sentiment analysis. The workflow processes product review data for laptops, combining review content with few-shot examples to generate aspect-specific prompts. It then sends these prompts to an LLM, which is expected to identify both the aspect and the corresponding sentiment.

Create promptwith instructions and examples+ request JSON Output
Expression
Evaluate responseusing columns
Expression
Table Row to Variable
Credentials Configuration
Create JSON exampleswith aspectand sentiment
Expression
Examples
Table Reader
Concatenate examplesand separatethem by \n\n
GroupBy
Parse output stringto JSON
String to JSON
Transform JSONto table
JSON to Table
Reviews
Table Reader
Extract aspects andpredict sentiment+ activate JSON Output
LLM Prompter
OpenAI Authenticator
Connect to model
OpenAI LLM Selector
Inspect mismatches

Nodes

Extensions

Links