I’d like to do some local sentiment analysis on my humble M1. Is there an easy way to do this?
It's possible to prompt a language model to do sentiment analysis (keep it simple like "Given the above text decide if the sentiment is positive, negative or neutral. Don't provide any other text." There are small Open Source modles (e.g. 1.1B, 2.5B, 4B. 8B) - if the tiny ones don't work you can upgrade to a bigger one.
Sparring a bit with ChatGPT. I think basilisp and 🤗transformers is the way to go. Seems pretty easy to use :^)
I used 🤗’s (.pipeline transformer "sentiment-analysis") which was very easy to use, thanks #basilisp! All it does is classify strings as positive or negative with a confidence number, which tends to be approximately zero or one and as such is not a very good proxy for how positive or negative a string is. E.g “i’m happy” gives 1 and “this is the best day of my life” also gives 1.
I managed to get a somewhat decent heuristic by partitioning my input and averaging the sentiment of the partitions, but the result is so so. Useful enough to be interesting in my case :^).
I’m curious if there’s a good way to get a measure of how positive a string is using a local model. I suppose I could just ask a llm directly.
I’ve done that with llama.clj with moderate success. I wrote a bit about the underlying approach at https://phronmophobic.github.io/llama.clj/notebooks/intro.html#classifiers. I think the method could still be improved.
Cool, will read!