/ Модель

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

Контекст
2 048 токенов
Размер весов
6,2 ГБ
Лицензия
WTFPL
Архитектура
gptj · dense
Опубликована
2 окт 2022

bertin-gpt-j-6B-ES-v1-8bit

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

Квантованная до 8 бит испаноязычная GPT-J-6B для генерации текста и экономичного дообучения на GPU.

24скачиваний за 30 дней5лайковвеса обновлены10 окт 2022

Бенчмарки

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Это испаноязычная версия GPT-J-6B проекта BERTIN, представленная в варианте с 8-битными весами. Модель основана на последнем чекпойнте bertin-project/bertin-gpt-j-6B и предназначена для генерации текста, а также для дообучения на GPU с ограниченной памятью.

Весовые матрицы хранятся в динамически квантованном 8-битном формате и преобразуются для вычислений в float16 или float32. README описывает использование gradient checkpointing и LoRA для снижения затрат памяти при дообучении; контекст модели составляет 2048 токенов. Карточка указывает лицензию WTFPL.

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

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

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

Ограничения

Контекст ограничен 2048 токенами. 8-битное квантование может немного снизить качество, а деквантизация и gradient checkpointing добавляют вычислительные накладные расходы.

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

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

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

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

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

Открыть на Hugging Face

BERTIN-GPT-J-6B with 8-bit weights (Quantized)

This model (and model card) is an adaptation of hivemind/gpt-j-6B-8bit, so all credits to him/her.

This is a version of the latest checkpoint (1M steps) bertin-project/bertin-gpt-j-6B that is modified so you can generate and fine-tune the model in Colab or equivalent desktop GPU.

Here's how to run it: colab

The original GPT-J takes 22+ GB memory for float32 parameters alone, and that's before you account for gradients & optimizer. Even if you cast everything to 16-bit, it will still not fit onto most single-GPU setups short of A6000 and A100. You can inference it on TPU or CPUs, but fine-tuning is way more expensive.

Here, we apply several techniques to make GPT-J usable and fine-tunable on a single GPU with ~11 GB memory:

  • large weight tensors are quantized using dynamic 8-bit quantization and de-quantized just-in-time for multiplication
  • using gradient checkpoints to store one only activation per layer: using dramatically less memory at the cost of 30% slower training
  • scalable fine-tuning with LoRA and 8-bit Adam

In other words, all of the large weight-matrices are frozen in 8-bit, and you only train small adapters and optionally 1d tensors (layernorm scales, biases).

img

Does 8-bit affect model quality? Technically yes, but the effect is negligible in practice. This notebook measures wikitext test perplexity and it is nigh indistinguishable from the original GPT-J. Quantized model is even slightly better, but that is not statistically significant.

Our code differs from other 8-bit methods in that we use 8-bit only for storage, and all computations are performed in float16 or float32. As a result, we can take advantage of nonlinear quantization that fits to each individual weight distribution. Such nonlinear quantization does not accelerate inference, but it allows for much smaller error.

What about performance? Both checkpointing and de-quantization has some overhead, but it's surprisingly manageable. Depending on GPU and batch size, the quantized model is 1-10% slower than the original model on top of using gradient checkpoints (which is 30% overhead). In short, this is because block-wise quantization from bitsandbytes is really fast on GPU.

How should I fine-tune the model?

We recommend starting with the original hyperparameters from the LoRA paper. On top of that, there is one more trick to consider: the overhead from de-quantizing weights does not depend on batch size. As a result, the larger batch size you can fit, the more efficient you will train.

Can I use this technique with other models?

The model was converted using this notebook. It can be adapted to work with other model types. However, please bear in mind that some models replace Linear and Embedding with custom alternatives that require their own BNBWhateverWithAdapters.

How to use

wget https://huggingface.co/mrm8488/bertin-gpt-j-6B-ES-v1-8bit/resolve/main/utils.py -O Utils.py
pip install transformers
pip install bitsandbytes-cuda111==0.26.0
import transformers
import torch

from Utils import GPTJBlock, GPTJForCausalLM

device = "cuda" if torch.cuda.is_available() else "cpu"

transformers.models.gptj.modeling_gptj.GPTJBlock = GPTJBlock  # monkey-patch GPT-J

ckpt = "mrm8488/bertin-gpt-j-6B-ES-v1-8bit"

tokenizer = transformers.AutoTokenizer.from_pretrained(ckpt)
model = GPTJForCausalLM.from_pretrained(ckpt, pad_token_id=tokenizer.eos_token_id, low_cpu_mem_usage=True).to(device)


prompt = tokenizer("El sentido de la vida es", return_tensors='pt')
feats = {key: value.to(device) for key, value in prompt.items()}

out = model.generate(**feats, max_length=64, do_sample=True)

print(tokenizer.decode(out[0]))

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

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

GPU в ailist

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

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

Подбираем GPU…

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

0 моделей