/ Модель

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

Контекст
514 токенов
Параметры
39,6 млн
Лицензия
Apache 2.0
Архитектура
roberta · dense
Библиотека
transformers
Опубликована
5 сен 2024

granite-guardian-hap-38m

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

Компактный англоязычный классификатор IBM для обнаружения токсичного текста и фильтрации контента в приложениях с LLM.

1 224скачиваний за 30 дней48лайковвеса обновлены19 дек 2024

Бенчмарки

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

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

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

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

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

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

IBM Research разработала Granite Guardian HAP 38M — компактный классификатор токсичности текста на основе RoBERTa с четырьмя слоями и 39,6 млн параметров. Модель анализирует английский текст и классифицирует его на токсичный или нетоксичный, выявляя в том числе ненавистнические высказывания, оскорбления и ненормативную лексику.

Модель предназначена для низколатентной фильтрации текста в качестве защитного барьера для LLM, а также для массовой разметки документов. Она работает на CPU и GPU; длина контекста составляет 514 токенов. Выпущена под лицензией Apache 2.0.

Короткая архитектура обеспечивает высокую скорость обработки, но при необходимости более высокого F1 разработчик рекомендует 12-слойную версию. Классификация может давать ложноположительные и ложноотрицательные результаты, особенно на текстах, отличающихся от обучающих данных; также возможны ошибки при интерпретации нюансов и проявления смещений, известных для детекторов токсичности и языка ненависти.

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

  • фильтрация токсичных запросов перед передачей их LLM
  • проверка ответов LLM на оскорбления и язык ненависти
  • поиск ненормативной лексики в текстах
  • массовая разметка документов по наличию токсичного содержания

Ограничения

Модель может ошибаться на текстах, отличающихся от обучающих данных, и не всегда улавливать нюансы; возможны ложноположительные и ложноотрицательные срабатывания и смещения. Для более высокого F1 разработчик рекомендует 12-слойную версию.

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

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

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

Также подходит для

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

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

Открыть на Hugging Face

Granite-Guardian-HAP-38m

Model Summary

This model is IBM's lightweight, 4-layer toxicity binary classifier for English. Its latency characteristics make it a suitable guardrail for any large language model. It can also be used for bulk processing of data where high throughput is needed. It has been trained on several benchmark datasets in English, specifically for detecting hateful, abusive, profane and other toxic content in plain text.

  • Developers: IBM Research
  • Release Date: September 6th, 2024
  • License: Apache 2.0.

Usage

Intended Use

This model offers very low inference latency and is capable of running on CPUs apart from GPUs and AIUs. It features 38 million parameters, reducing the number of hidden layers from 12 to 4, decreasing the hidden size from 768 to 576, and the intermediate size from 3072 to 768, compared to the original RoBERTa model architecture. The latency on CPU vs accuracy numbers for this model in comparision to others is shown in the chart below.

Description of Image

Prediction

# Example of how to use the model
import torch
from transformers import AutoModelForSequenceClassification, AutoTokenizer

model_name_or_path = 'ibm-granite/granite-guardian-hap-38m'
model = AutoModelForSequenceClassification.from_pretrained(model_name_or_path)
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path)

# Sample text
text = ["This is the 1st test", "This is the 2nd test"]
input = tokenizer(text, padding=True, truncation=True, return_tensors="pt")

with torch.no_grad():
    logits = model(**input).logits
    prediction = torch.argmax(logits, dim=1).detach().numpy().tolist() # Binary prediction where label 1 indicates toxicity.
    probability = torch.softmax(logits, dim=1).detach().numpy()[:,1].tolist() #  Probability of toxicity.
   

Cookbook on Model Usage as a Guardrail

This recipe illustrates the use of the model either in a prompt, the output, or both. This is an example of a “guard rail” typically used in generative AI applications for safety. Guardrail Cookbook

Cookbook on Model Usage for HAP Annotation on Documents in Bulk using Data Prep Kit

This recipe illustrates the use of the model for HAP annotation of documents in bulk. The documents are read from a parquet file. It is then fed to the model sentence by sentence for a document and a HAP score for the document is decided. This is then stored back in the parquet file. Here is the sample cookbook for it Data Prep Kit Cookbook

Performance Comparison with Other Models

The model outperforms most popular models with significantly lower inference latency. If a better F1 score is required, please refer to IBM's 12-layer model here.

Description of Image Description of Image

Ethical Considerations and Limitations

The use of model-based guardrails for Large Language Models (LLMs) involves risks and ethical considerations people must be aware of. This model operates on chunks of texts and provides a score indicating the presence of hate speech, abuse, or profanity. However, the efficacy of the model can be limited by several factors: the potential inability to capture nuanced meanings or the risk of false positives or negatives on text that is dissimilar to the training data. Previous research has demonstrated the risk of various biases in toxicity or hate speech detection. That is also relevant to this work. We urge the community to use this model with ethical intentions and in a responsible way.

Resources

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

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

GPU в ailist

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

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

Подбираем GPU…

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

0 моделей