/ Модель

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

Контекст
4 096 токенов
Параметры
6,6 млрд
Размер весов
27 ГБ
Лицензия
Llama 2
Архитектура
llama · dense
Опубликована
25 фев 2024

DetoxLLM-7B

Генерация текстаТекст → текст3 профессии

DetoxLLM-7B — англоязычная модель на базе LLaMA 2 для снижения токсичности текста с объяснениями преобразования.

67скачиваний за 30 дней1лайквеса обновлены12 ноя 2024

Бенчмарки

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

Тесты пользователейпока нет

Никто ещё не опубликовал тест этой модели. Соберите бенчмарк из своих задач — результат появится здесь.

  1. Добавьте модель в бенчмарк

    Вместе с другими моделями категории «Текст» — сравнение идёт внутри одной категории.

  2. Опишите свои задачи

    Напишите запросы, при необходимости приложите файлы и эталонные ответы.

  3. Запустите и опубликуйте

    Модели ответят на каждую задачу, судья оценит ответы. Опубликованный результат появится на этой странице.

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

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

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

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

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

DetoxLLM-7B — модель для детоксикации текста, разработанная Md Tawkat Islam Khondaker, Muhammad Abdul-Mageed и Laks V.S. Lakshmanan. Она дообучена на основе LLaMA 2 с Chain-of-Thought-объяснениями и предназначена для преобразования токсичных высказываний в менее токсичные, сохраняя их смысл и предоставляя объяснения. Модель обучена на синтетическом псевдопараллельном корпусе для детоксикации, сформированном из данных разных платформ.

Модель имеет архитектуру LLaMA, около 6,6 млрд параметров и контекст до 4096 токенов. Карточка указывает английский язык. Работа представлена на EMNLP 2024. Модель можно использовать как исследовательский базовый инструмент для очистки пользовательского текста и разработки систем модерации. Лицензия — Llama 2.

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

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

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

Ограничения

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

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

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

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

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

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

Открыть на Hugging Face

DetoxLLM-7B

This model card corresponds to the DetoxLLM-7B detoxification model based on LLaMA-2. The model is finetuned with Chain-of-Thought (CoT) explanation.

Paper: DetoxLLM: A Framework for Detoxification with Explanations (EMNLP 2024 Main)

Authors: Md Tawkat Islam Khondaker, Muhammad Abdul-Mageed, Laks V.S. Lakshmanan

Dataset: Dataset used to train this model can be found here.

Model Information

Summary description and brief definition of inputs and outputs.

Description

DetoxLLM is the first comprehensive end-to-end detoxification framework trained on cross-platform pseudo-parallel corpus. DetoxLLM further introduces explanation to promote transparency and trustworthiness. The framework also demonstrates robustness against adversarial toxicity.

Usage

Below we share some code snippets on how to get quickly started with running the model. First make sure to pip install -U transformers accelerate bitsandbytes, then copy the snippet from the section that is relevant for your usecase.

Running the model on a CPU

from transformers import AutoTokenizer, AutoModelForCausalLM

model_name = "UBC-NLP/DetoxLLM-7B"

tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)

prompt = "Rewrite the following toxic input into non-toxic version. Let's break the input down step by step to rewrite the non-toxic version. You should first think about the expanation of why the input text is toxic. Then generate the detoxic output. You must preserve the original meaning as much as possible.\nInput: "

input = "Those shithead should stop talking and get the f*ck out of this place"
input_text = prompt+input+"\n"

input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")

outputs = model.generate(**input_ids, do_sample=False)
print(tokenizer.decode(outputs[0]))

Running the model on a single / multi GPU

from transformers import AutoTokenizer, AutoModelForCausalLM

model_name = "UBC-NLP/DetoxLLM-7B"

tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name, device_map="auto")


prompt = "Rewrite the following toxic input into non-toxic version. Let's break the input down step by step to rewrite the non-toxic version. You should first think about the expanation of why the input text is toxic. Then generate the detoxic output. You must preserve the original meaning as much as possible.\nInput: "

input = "Those shithead should stop talking and get the f*ck out of this place"
input_text = prompt+input+"\n"

input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")

outputs = model.generate(**input_ids, do_sample=False)
print(tokenizer.decode(outputs[0]))

Running the model on a GPU using different precisions

  • Using torch.float16
# pip install accelerate
from transformers import AutoTokenizer, AutoModelForCausalLM

model_name = "UBC-NLP/DetoxLLM-7B"

tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name, device_map="auto", torch_dtype=torch.float16)

prompt = "Rewrite the following toxic input into non-toxic version. Let's break the input down step by step to rewrite the non-toxic version. You should first think about the expanation of why the input text is toxic. Then generate the detoxic output. You must preserve the original meaning as much as possible.\nInput: "

input = "Those shithead should stop talking and get the f*ck out of this place"
input_text = prompt+input+"\n"

input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")

outputs = model.generate(**input_ids, do_sample=False)
print(tokenizer.decode(outputs[0]))
  • Using torch.bfloat16
from transformers import AutoTokenizer, AutoModelForCausalLM

model_name = "UBC-NLP/DetoxLLM-7B"

tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name, device_map="auto", torch_dtype=torch.bfloat16)

prompt = "Rewrite the following toxic input into non-toxic version. Let's break the input down step by step to rewrite the non-toxic version. You should first think about the expanation of why the input text is toxic. Then generate the detoxic output. You must preserve the original meaning as much as possible.\nInput: "

input = "Those shithead should stop talking and get the f*ck out of this place"
input_text = prompt+input+"\n"

input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")

outputs = model.generate(**input_ids, do_sample=False)
print(tokenizer.decode(outputs[0]))

Quantized Versions through bitsandbytes

  • Using 8-bit precision (int8)
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig

quantization_config = BitsAndBytesConfig(load_in_8bit=True)

model_name = "UBC-NLP/DetoxLLM-7B"

tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name, quantization_config=quantization_config)

prompt = "Rewrite the following toxic input into non-toxic version. Let's break the input down step by step to rewrite the non-toxic version. You should first think about the expanation of why the input text is toxic. Then generate the detoxic output. You must preserve the original meaning as much as possible.\nInput: "

input = "Those shithead should stop talking and get the f*ck out of this place"
input_text = prompt+input+"\n"

input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")

outputs = model.generate(**input_ids, do_sample=False)
print(tokenizer.decode(outputs[0]))
  • Using 4-bit precision
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig

quantization_config = BitsAndBytesConfig(load_in_4bit=True)

model_name = "UBC-NLP/DetoxLLM-7B"

tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name, quantization_config=quantization_config)

prompt = "Rewrite the following toxic input into non-toxic version. Let's break the input down step by step to rewrite the non-toxic version. You should first think about the expanation of why the input text is toxic. Then generate the detoxic output. You must preserve the original meaning as much as possible.\nInput: "

input = "Those shithead should stop talking and get the f*ck out of this place"
input_text = prompt+input+"\n"

input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")

outputs = model.generate(**input_ids, do_sample=False)
print(tokenizer.decode(outputs[0]))

Model Data

The model is trained on cross-platform pseudo-parallel detoxification corpus generated using ChatGPT.

Usage and Limitations

These models have certain limitations that users should be aware of.

Intended Usage

The intended use of DetoxLLM is for the detoxification tasks. We aim to help researchers to build an end-to-end complete detoxification framework. DetoxLLM can also be regarded as a promising baseline to develop more robust and effective detoxification frameworks.

Limitations

  • Data Generation Process: This work uses ChatGPT, a gpt-3.5-turbo version from June, 2023. Since the model can be updated on a regular interval, the data generation process should be treated accordingly.
  • Data Quality: DetoxLLM proposes an automated data generation pipeline to create a pseudo-parallel cross-platform corpus. The synthetic data generation process involves multi-stage data processing without the necessity of direct human inspection. Although this automated pipeline makes the overall data generation process scalable, it comes at the risk of allowing low-quality data in our cross-platform corpus. Hence, human inspection is recommended to remove any sort of potential vulnerability and maintain a standard quality of the corpus.
  • Model Responses: Although DetoxLLM exhibits impressive ability in generating detoxified responses, we believe there is still room for improvement for the model in terms of producing meaning-preserved detoxified outcomes. Moreover, the models can sometimes be vulnerable to implicit, adversarial tokens and continue to produce toxic content. Therefore, we recommend that DetoxLLM should be couched with caution before deployment.

Ethical Considerations and Risks

The development of large language models (LLMs) raises several ethical concerns. In creating an open model, we have carefully considered the following:

  • Data Collection and Release: We compile datasets from a wide range of platforms. To ensure proper credit assignment, we refer users to the original publications in our paper. We create the cross-platform detoxification corpus for academic research purposes. We intend to share the corpus in the future. We would also like to mention that some content are generated using GPT-4 for illustration purposes.
  • Potential Misuse and Bias: DetoxLLM can potentially be misused to generate toxic and biased content. For these reasons, we recommend that DetoxLLM not be used in applications without careful prior consideration of potential misuse and bias.

Citation

If you use DetoxLLM for your scientific publication, or if you find the resources in this repository useful, please cite our paper as follows:

@inproceedings{khondaker-etal-2024-detoxllm,
    title = "{D}etox{LLM}: A Framework for Detoxification with Explanations",
    author = "Khondaker, Md Tawkat Islam  and
      Abdul-Mageed, Muhammad  and
      Lakshmanan, Laks V. S.",
    editor = "Al-Onaizan, Yaser  and
      Bansal, Mohit  and
      Chen, Yun-Nung",
    booktitle = "Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing",
    month = nov,
    year = "2024",
    address = "Miami, Florida, USA",
    publisher = "Association for Computational Linguistics",
    url = "https://aclanthology.org/2024.emnlp-main.1066",
    pages = "19112--19139",
}

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

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

GPU в ailist

Универсальный рантайм

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

Подбираем GPU…

Класс архитектуры
LlamaForCausalLM
Ревизия весов
2a51c4e

0 моделей