This topic covers the configuration of the Sentiment feature of the Discourse AI plugin.
Required user level: Administrator
Sentiment keeps tabs on your community by analyzing posts and providing sentiment and emotional scores to give you an overall sense of your community for any period of time. These insights can be helpful in determining the type of users posting within your community and interacting with one another.
Features
Overall sentiment: compares the number of posts classified as either positive or negative
Bar graph showcasing toggleable numerical value for positive, negative, and overall scores
Emotion: number of topics and posts classified by multiple emotions, grouped by time frame
Today
Yesterday
Last 7 days
Last 30 days
Reports for any period of time that can be accessed via settings
Yearly
Quarterly
Monthly
Weekly
Custom range
Applicable only for admin users
Enabling Sentiment
Configuration
Sentiment is enabled by default for hosted customers. For manual steps see below
Go to Admin settings-> Plugins → search or find discourse-ai and make sure its enabled
Enable ai_sentiment_enabled for Sentiment Analysis
Head over to /admin/dashboard/sentiment to see their respective reports
Once enabled, Sentiment will classify all posts going forward and from the last 60 days. To classify all of your site’s historical posts, a backfill task must be run from the console.
How is topic/post data processed? How are scores assigned?
Sentiment has a “per post” fidelity. For each post we are able to tell sentiment and then cut that data in many shapes (per tag / category / time etc… ). It compares the number of posts classified as either positive or negative. These are calculated when positive or negative scores > the set threshold score.
Are there any plans to add support for other languages?
In the future Yes! both by adding multilingual simple Machine Learning (ML) models and by using multilingual Large Language Models (LLMs) to classify the data, instead of dedicated models.
The OP has been updated with a new video showcasing the updated features of Sentiment including a ton more emotions and understanding which topics/posts are associated with each emotion
I configured the sentiment model config with a model_name, endpoint, and api_key copied from the LLM settings, where it passes the test, but I get the error below in /logs.
(But maybe I don’t understand correctly, because why doesn’t sentiment use one of the configured LLMs?)
Using claude-3-5-sonnet.
{"type":"error","error":{"type":"invalid_request_error","message":"anthropic-version: header is required"}} (Net::HTTPBadResponse)
/var/www/discourse/plugins/discourse-ai/lib/inference/hugging_face_text_embeddings.rb:71:in `classify'
/var/www/discourse/plugins/discourse-ai/lib/sentiment/post_classification.rb:142:in `request_with'
/var/www/discourse/plugins/discourse-ai/lib/sentiment/post_classification.rb:78:in `block (4 levels) in bulk_classify!'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.5/lib/concurrent-ruby/concurrent/promises.rb:1593:in `evaluate_to'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.5/lib/concurrent-ruby/concurrent/promises.rb:1776:in `block in on_resolvable'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.5/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:359:in `run_task'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.5/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:350:in `block (3 levels) in create_worker'
<internal:kernel>:187:in `loop'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.5/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:341:in `block (2 levels) in create_worker'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.5/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:340:in `catch'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.5/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:340:in `block in create_worker'
Status: 400
{"type":"error","error":{"type":"invalid_request_error","message":"anthropic-version: header is required"}} (Net::HTTPBadResponse)
/var/www/discourse/plugins/discourse-ai/lib/inference/hugging_face_text_embeddings.rb:71:in `classify'
/var/www/discourse/plugins/discourse-ai/lib/sentiment/post_classification.rb:142:in `request_wit...
The sentiment module doesn’t use general LLMs, but models specifically fine tuned to sentiment classification. If you want to run those models on your own that is documented at Self-Hosting Sentiment and Emotion for DiscourseAI