/ Модель

Характеристики

Контекст
512 токенов
Параметры
137 млн
Лицензия
Apache 2.0
Архитектура
bert · dense
Базовая модель
bert-base-uncased
Библиотека
transformers
Опубликована
16 дек 2024

polite-guard

Классификация текстаТекст → label3 профессии

Polite Guard — англоязычная BERT-модель Intel для классификации текста по четырём уровням вежливости.

1 440скачиваний за 30 дней17лайковвеса обновлены24 фев 2025

Бенчмарки

Как модель справилась с задачами пользователей ailist и что о ней публикуют открытые лидерборды

Публичные оценки

Из открытых лидербордов. Сравнивайте результаты одного теста при одинаковых условиях — отсутствие оценки не значит, что модель хуже.

В подключённых источниках результатов для этой модели пока нет.

Что умеет модель

Описание составлено по карточке модели и метаданным Hugging Face

Polite Guard — модель классификации текста, разработанная Intel и дообученная на базе BERT-base uncased. Она относит текст к одной из четырёх категорий вежливости: вежливый, в некоторой степени вежливый, нейтральный или невежливый. Модель предназначена для анализа отзывов и сообщений службы поддержки, оценки тона общения и сравнения систем по качеству вежливой коммуникации.

Архитектура — BERT для классификации последовательностей; в метаданных указано 136,7 млн параметров и контекст до 512 токенов. Модель принимает текст на английском языке и выдаёт метку класса. В тестировании на наборе Polite Guard, включавшем синтетические и вручную размеченные данные, заявлены точность и F1 по 92%. Доступны форматы ONNX и safetensors.

Модель выпущена под лицензией Apache-2.0. Обучающие данные состоят из синтетических клиентских диалогов для нескольких отраслей, а карточка предупреждает об ограниченной области валидации: результаты могут быть хуже на других типах текста. Модель не предназначена для оценки эффективности сотрудников и сама по себе недостаточна для предотвращения вреда в чувствительных сценариях.

Сценарии применения

  • Определение вежливости сообщений службы поддержки
  • Классификация отзывов по тону общения
  • Проверка вежливости ответов чат-бота
  • Сравнение моделей по качеству вежливой коммуникации

Ограничения

Проверена на ограниченном наборе отзывов и корпоративных коммуникаций, поэтому качество на других типах текста не гарантируется. Не предназначена для оценки сотрудников и недостаточна как единственная мера защиты в чувствительных сценариях.

Для каких профессий подходит3

Разделы каталога профессий, в задачах которых используется эта модель

Все профессии

Карточка модели

README от автора на Hugging Face, как он его опубликовал

Открыть на Hugging Face

Polite Guard

Polite Guard is an open-source NLP language model developed by Intel, fine-tuned from BERT for text classification tasks. It is designed to classify text into four categories: polite, somewhat polite, neutral, and impolite. This model, along with its accompanying datasets and source code, is available on Hugging Face* and GitHub* to enable both communities to contribute to developing more sophisticated and context-aware AI systems.

Use Cases

Polite Guard provides a scalable model development pipeline and methodology, making it easier for developers to create and fine-tune their own models. Other contributions of the project include:

  • Improved Robustness: Polite Guard enhances the resilience of systems by providing a defense mechanism against adversarial attacks. This ensures that the model can maintain its performance and reliability even when faced with potentially harmful inputs.
  • Benchmarking and Evaluation: The project introduces the first politeness benchmark, allowing developers to evaluate and compare the performance of their models in terms of politeness classification. This helps in setting a standard for future developments in this area.
  • Enhanced Customer Experience: By ensuring respectful and polite interactions on various platforms, Polite Guard can significantly boost customer satisfaction and loyalty. This is particularly beneficial for customer service applications where maintaining a positive tone is crucial.

Description of labels

  • polite: Text is considerate and shows respect and good manners, often including courteous phrases and a friendly tone.
  • somewhat polite: Text is generally respectful but lacks warmth or formality, communicating with a decent level of courtesy.
  • neutral: Text is straightforward and factual, without emotional undertones or specific attempts at politeness.
  • impolite: Text is disrespectful or rude, often blunt or dismissive, showing a lack of consideration for the recipient's feelings.

Model Details

  • Training Data: The model was trained on the Polite Guard Dataset utilizing Intel® Gaudi® Al accelerators. The training dataset consists of synthetically generated customer service interactions across various sectors, including finance, travel, food and drink, retail, sports clubs, culture and education, and professional development.
  • Base Model: BERT-base, with 12 layers, 110M parameters.
  • Fine-tuning Process: Fine-tuning was performed on the Polite Guard train dataset with the following hyperparameters using PyTorch Lightning*.
HypeparameterBatch sizeLearning rateLearning rate scheduleMax epochsOptimizerWeight decayPrecision
Value324.78e-05Linear warmup (10% of steps)2AdamW1.01e-06bf16-mixed

Hyperparameter tuning was performed using Bayesian optimization with the Tree-structured Parzen Estimator (TPE) algorithm through Optuna* with 35 trials to maximize the validation F1-score. The hyperparameter search space included

learning rate: [1e-5, 5e-4]
weight decay: [1e-6, 1e-2]

The fine-tuning process used Optuna's pruning callback to terminate underperforming hyperparameter trials, and model checkpointing to save the best performing model states.

Parallel Coordinate Plot Hyperparameter Importance Plot

The code for the synthetic data generation and fine-tuning can be found here.

Metrics

Here are the key performance metrics of the model on the test dataset containing both synthetic and manually annotated data:

  • Accuracy: 92% on the Polite Guard test dataset.
  • F1-Score: 92% on the Polite Guard test dataset.

How to Use

You can use this model directly with a pipeline for categorizing text into classes polite, somewhat polite, neutral, and impolite.

from transformers import pipeline

classifier = pipeline("text-classification", "Intel/polite-guard")
text = "Your input text"
output = classifier(text)
print(output)

The next example demonstrates how to run this model in the browser using Hugging Face's transformers.js library with webnn-gpu for hardware acceleration.

<!DOCTYPE html>
<html>
  <body>
    <h1>WebNN Transformers.js Intel/polite-guard</h1>
    <script type="module">
      import { pipeline } from "https://cdn.jsdelivr.net/npm/@huggingface/transformers";

      const classifier = await pipeline("text-classification", "Intel/polite-guard", {
        dtype: "fp32",
        device: "webnn-gpu", // You can also try: "webgpu", "webnn", "webnn-npu", "webnn-cpu", "wasm" 
      });

      const text = "Your input text";
      const output = await classifier(text);
      console.log(`${text}: ${output[0].label}`);
    </script>
  </body>
</html>

Articles

To learn more about the implementation of the data generator and fine-tuner packages, refer to

For more AI development how-to content, visit Intel® AI Development Resources.

Join the Community

If you are interested in exploring other models, join us in the Intel and Hugging Face communities. These models simplify the development and adoption of Generative AI solutions, while fostering innovation among developers worldwide. If you find this project valuable, please like ❤️ it on Hugging Face and share it with your network. Your support helps us grow the community and reach more contributors.

Disclaimer

Polite Guard has been trained and validated on a limited set of data that pertains to customer reviews, product reviews, and corporate communications. Accuracy metrics cannot be guaranteed outside these narrow use cases, and therefore this tool should be validated within the specific context of use for which it might be deployed. This tool is not intended to be used to evaluate employee performance. This tool is not sufficient to prevent harm in many contexts, and additional tools and techniques should be employed in any sensitive use case where impolite speech may cause harm to individuals, communities, or society.

Privacy Notice

Please note that the Polite Guard model uses AI technology and you are interacting with a chatbot. Prompts that are being used during the demo will not be stored. For information regarding the handling of personal data collected refer to the Global Privacy Notice (https://www.intel.com/content/www/us/en/privacy/intelprivacy-notice.html), which encompass our privacy practices.

*Other names and brands may be claimed as the property of others.

Как запустить

На своей GPU в ailist. Цена — по текущим предложениям провайдеров

GPU в ailist

Универсальный рантайм · transformers · text-classification

Можно запустить

Подбираем GPU…

Класс архитектуры
BertForSequenceClassification
Ревизия весов
b302b4b

0 моделей