Open
Conversation
cris-seaton
suggested changes
Jun 2, 2023
cris-seaton
left a comment
There was a problem hiding this comment.
first iteration of review. let's chat about it when your back in the 'office'
| This model is trained on 124M tweets from January 2018 to December 2021, | ||
| and is finetuned for sentiment analysis. | ||
| It outputs a label - Neutral, Positive or Negative - and a score ranging | ||
| from 0 to 1 - 0 being the most negative and 1, the most positive. |
Comment on lines
+3
to
+4
| create or replace function {{target.schema}}.udf_sentiment_analysis(text STRING, output INTEGER) | ||
| returns STRING |
There was a problem hiding this comment.
your arguments need revision
text STRING, model INTEGER or STRING [more on this later], output VARIANT (if you still want to differentiate between label and score)
and returns STRING, you have to make sure L32 has to cast as a string.
| model = "cardiffnlp/twitter-roberta-base-sentiment-latest" | ||
| -- model = 'nlptown/bert-base-multilingual-uncased-sentiment' | ||
|
|
||
| def sentiment_analysis(text, model_id, output='score'): |
There was a problem hiding this comment.
your function name (sentiment_analysis) and your handler on L8 have to be equivalent. you also should have the equivalent # of arguments here and in your UDF call.
|
function name and handler should be quivalent |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


This macro iterates through a piece of text to return the overall sentiment of that text.
First, the macro pre-processes the text removing unnecessary punctuation and stopwords to help increase the accuracy of the model. Subsequently, using the transformers library it applies a sentiment analysis pipeline based on a pre-trained model that will return either a score or a label for the text.
Recommendation is to use the following popular models:
cardiffnlp/twitter-roberta-base-sentiment-latest:
(https://huggingface.co/cardiffnlp/twitter-roberta-base-sentiment-latest)
This model is trained on 124M tweets from January 2018 to December 2021, and is finetuned for sentiment analysis.
It outputs a label - Neutral, Positive or Negative - and a score ranging from 0 to 1 - 0 being the most negative and 1,
the most positive.
nlptown/bert-base-multilingual-uncased-sentiment:
(https://huggingface.co/nlptown/bert-base-multilingual-uncased-sentiment)
This model is fine-tuned for sentiment analysis on product reviews in six languages: English, Dutch, German, French,
Spanish and Italian. It outputs a label - 1 to 5 stars - and a score ranging from 0 to 1 - 0 being the
most negative and 1, the most positive.
Macro returns a STRING data type. If 'score' is used as an output, then it will have to be cast to FLOAT data type.