--- base_model: google/gemma-3-270m pipeline_tag: text-classification language: - en tags: - sentiment-analysis - text-classification - seo license: other license_name: link-attribution license_link: https://dejan.ai/link-attribution/ --- # DEJAN AI Sentiment Classifier This is a text sentiment classifier trained by [DEJAN AI](https://dejan.ai), small enough to run over thousands of pages on a laptop. Read how we built it, with training data, charts and results: [DEJAN releases a free sentiment model](https://dejan.ai/blog/sentiment-model/). Try it in the [public demo](https://dejan.ai/tools/sentiment/). | Score | Label | |---|---| | 0 | very positive | | 1 | positive | | 2 | somewhat positive | | 3 | neutral | | 4 | somewhat negative | | 5 | negative | | 6 | very negative | > [!IMPORTANT] > **Feed it one sentence at a time, not a whole page.** > The model reads up to about 90 words and ignores the rest. To score a page, split it into sentences and score each one. The example below shows how. ## What you can use it for - **Reviews:** score your own and competitors' reviews sentence by sentence, and find exactly which product features people praise or complain about. - **Brand mentions:** measure how your brand is talked about in articles, forums, social posts, and AI answers. - **Content audits:** find negative or off-tone sentences on landing pages, product pages, and service pages before users do. - **Competitor pages:** compare how positive your comparison and product pages are against the pages that outrank you. - **SERP research:** see whether the top-ranking content for a query is enthusiastic, balanced, or critical. It understands the formats you work with: product pages, reviews, comparisons, FAQs, blog posts, press releases, forum threads, tweets, transcripts, and tables. ## How accurate is it | | | |---|---| | Exact score | **84%** | | Exact or one point off | **95%** | When it misses, it is almost always by one point, for example "negative" instead of "somewhat negative". ![image](https://cdn-uploads.huggingface.co/production/uploads/64732e7f7be71eb8b1b572a8/HyGInCobx5fLKgxO6t0ra.png) ![image](https://cdn-uploads.huggingface.co/production/uploads/64732e7f7be71eb8b1b572a8/Tnc55aKYHEz_FOKJXj3U9.png) ![image](https://cdn-uploads.huggingface.co/production/uploads/64732e7f7be71eb8b1b572a8/Urc74fNkhEu6GLCJCTCnM.png) ## Quick start ```python from transformers import pipeline clf = pipeline("text-classification", model="dejanai/sentiment-classifier") clf("Delivery took three weeks and nobody answered my emails.") # [{'label': 'negative', 'score': 0.88}] ``` ## Scoring a whole page ```python import re from transformers import pipeline clf = pipeline("text-classification", model="dejanai/sentiment-classifier") def sentences(text): for line in text.splitlines(): line = re.sub(r"^\s*(#+|[-*+]|\d+[.)])\s*", "", line).replace("**", "").strip() if line: yield from (s for s in re.split(r"(?<=[.!?])\s+(?=[A-Z0-9\"'])", line) if s) page = """# Six months with the X200 The battery is superb. The camera, sadly, is a step backwards. - Price: $499 - Software updates have been slow.""" parts = list(sentences(page)) for part, result in zip(parts, clf(parts)): print(result["label"], "|", part) ``` ## Good to know - English only. - Each sentence is scored on its own, so a sentence like "And yet it works" may be misread without the sentence before it. - Trained on about 83,000 sentences written and scored by AI across 26 content types. It has not yet been tested on real-world review datasets. ## License Released under the [DEJAN link attribution license](https://dejan.ai/link-attribution/). Built on Google's Gemma, so use is also subject to the [Gemma Terms of Use](https://ai.google.dev/gemma/terms).