Sentiment
Sentiment Guardrail is used to detect a prompt's sentiment and that the prompt has a sentiment score lower than the threshold. The scanner based on the NLTK's SentimentIntensityAnalyzer.
Parameters:
data:
prompt
(str): The prompt to scan for sentiment.
arguments:
threshold
(float, optional): Threshold for the sentiment score (from -1 to 1). Default is -0.1.
Interpretation
The sentiment score is calculated using nltk's Vader sentiment analyzer. The SentimentIntensityAnalyzer produces a sentiment score ranging from -1 to 1:
-1 represents a completely negative sentiment.
0 represents a neutral sentiment.
1 represents a completely positive sentiment.
Example:
Results:
Code Example:
Last updated