/ Модель

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

Лицензия
Apache 2.0
Архитектура
perceiver-ar-symbolic-audio-model · dense
Опубликована
3 мая 2023

perceiver-ar-sam-giant-midi

Обработка аудиоАудио → аудио3 профессии

Демонстрационная модель Perceiver AR для продолжения и генерации символической музыки по MIDI-последовательностям.

20скачиваний за 30 дней12лайковвеса обновлены5 мая 2023

Бенчмарки

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

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

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

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

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

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

Perceiver AR symbolic audio model — модель на 134 млн параметров, разработанная как пример обучения моделей Perceiver AR с библиотекой perceiver-io. Она обучена на датасете GiantMIDI-Piano из MIDI-файлов в течение 27 эпох, всего на 157 млн токенов. Архитектура расширяет декодерный трансформер механизмом перекрёстного внимания к длинному префиксу; применяются rotary embeddings. Контекст составляет 6144 токена, из них до 4096 токенов префикса и 2048 латентных позиций.

Модель предназначена для генерации MIDI-подобной символической музыки по заданному начальному фрагменту. Пользователь может задавать число начальных латентных токенов. Карточка описывает её прежде всего как демонстрационный пример, а не как высококачественный музыкальный генератор; автор отмечает, что для улучшения качества требуется обучать модель на существенно большем наборе данных. Лицензия — Apache-2.0.

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

  • генерация продолжения MIDI-фрагмента
  • создание символических музыкальных последовательностей по начальному мотиву
  • эксперименты с генерацией музыки на архитектуре Perceiver AR

Ограничения

Модель обучена только на GiantMIDI-Piano и предназначена главным образом для демонстрации; качество генерации ограничено размером обучающих данных. Для запуска требуется библиотека perceiver-io с расширением audio.

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

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

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

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

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

Открыть на Hugging Face

Perceiver AR symbolic audio model

This model is a Perceiver AR symbolic audio model (134M parameters) pretrained on the GiantMIDI-Piano dataset for 27 epochs (157M tokens). It uses rotary embedding for relative position encoding. It is a training example of the perceiver-io library.

Model description

Perceiver AR is a simple extension of a plain decoder-only transformer such as GPT-2, for example. A core building block of both is the decoder layer consisting of a self-attention layer followed by a position-wise MLP. Self-attention uses a causal attention mask.

Perceiver AR additionally cross-attends to a longer prefix of the input sequence in its first attention layer. This layer is a hybrid self- and cross-attention layer. Self-attention is over the last n positions of the input sequence, with a causal attention mask, cross-attention is from the last n positions to the first m positions. The length of the input sequence is m + n. This allows a Perceiver AR to process a much larger context than decoder-only transformers which are based on self-attention only.

The output of the hybrid attention layer are n latent arrays corresponding to the last n tokens of the input sequence. These are further processed by a stack of L-1 decoder layers where the total number of attention layers is L. A final layer (not shown in Fig. 1) predicts the target token for each latent position. The weights of the final layer are shared with the input embedding layer. Except for the initial cross-attention to the prefix sequence, a Perceiver AR is architecturally identical to a decoder-only transformer.

Model training

The model was trained with the task of symbolic audio modeling on the GiantMIDI-Piano dataset for 27 epochs (157M tokens). This dataset consists of MIDI files, tokenized using the approach from the Perceiver AR paper, which is described in detail in Section A.2 of Huang et al (2019). All hyperparameters are summarized in the training script. The context length was set to 6144 tokens with 2048 latent positions, resulting in a maximal prefix length of 4096. The actual prefix length per example was randomly chosen between 0 and 4096. Training was done with PyTorch Lightning and the resulting checkpoint was converted to this 🤗 model with a library-specific conversion utility.

Intended use and limitations

This model can be used for audio generation with a user-defined initial number of latent tokens. It mainly exists for demonstration purposes on how to train Perceiver AR models with the perceiver-io library. To improve on the quality of the generated audio samples a much larger dataset than GiantMIDI-Piano is required for training.

Usage examples

To use this model you first need to install the perceiver-io library with extension audio.

pip install perceiver-io[audio]

Then the model can be used with PyTorch. Either use the model directly to generate MIDI files:

import torch

from perceiver.model.audio.symbolic import PerceiverSymbolicAudioModel
from perceiver.data.audio.midi_processor import decode_midi, encode_midi
from pretty_midi import PrettyMIDI

repo_id = "krasserm/perceiver-ar-sam-giant-midi"

model = PerceiverSymbolicAudioModel.from_pretrained(repo_id)

prompt_midi = PrettyMIDI("prompt.mid")
prompt = torch.tensor(encode_midi(prompt_midi)).unsqueeze(0)

output = model.generate(prompt, max_new_tokens=64, num_latents=1, do_sample=True, top_p=0.95, temperature=1.0)

output_midi = decode_midi(output[0].cpu().numpy())
type(output_midi)
pretty_midi.pretty_midi.PrettyMIDI

use a symbolic-audio-generation pipeline to generate a MIDI output:

from transformers import pipeline
from pretty_midi import PrettyMIDI
from perceiver.model.audio import symbolic  # auto-class registration

repo_id = "krasserm/perceiver-ar-sam-giant-midi"

prompt = PrettyMIDI("prompt.mid")
audio_generator = pipeline("symbolic-audio-generation", model=repo_id)

output = audio_generator(prompt, max_new_tokens=64, num_latents=1, do_sample=True, top_p=0.95, temperature=1.0)
type(output["generated_audio_midi"])
pretty_midi.pretty_midi.PrettyMIDI

or generate WAV output by rendering the MIDI symbols using fluidsynth (Note: fluidsynth must be installed in order for the following example to work):

from transformers import pipeline
from pretty_midi import PrettyMIDI
from perceiver.model.audio import symbolic  # auto-class registration

repo_id = "krasserm/perceiver-ar-sam-giant-midi"

prompt = PrettyMIDI("prompt.mid")
audio_generator = pipeline("symbolic-audio-generation", model=repo_id)

output = audio_generator(prompt, max_new_tokens=64, num_latents=1, do_sample=True, top_p=0.95, temperature=1.0, render=True)

with open("generated_audio.wav", "wb") as f:
    f.write(output["generated_audio_wav"])

Audio samples

The following (hand-picked) audio samples were generated using various prompts from the validation subset of the GiantMIDI-Piano dataset. The input prompts are not included in the audio output.

Checkpoint conversion

The krasserm/perceiver-ar-sam-giant-midi model has been created from a training checkpoint with:

from perceiver.model.audio.symbolic import convert_checkpoint

convert_checkpoint(
    save_dir="krasserm/perceiver-ar-sam-giant-midi",
    ckpt_url="https://martin-krasser.com/perceiver/logs-0.8.0/sam/version_1/checkpoints/epoch=027-val_loss=1.944.ckpt",
    push_to_hub=True,
)

Citation

@inproceedings{hawthorne2022general,
  title={General-purpose, long-context autoregressive modeling with perceiver ar},
  author={Hawthorne, Curtis and Jaegle, Andrew and Cangea, C{\u{a}}t{\u{a}}lina and Borgeaud, Sebastian and Nash, Charlie and Malinowski, Mateusz and Dieleman, Sander and Vinyals, Oriol and Botvinick, Matthew and Simon, Ian and others},
  booktitle={International Conference on Machine Learning},
  pages={8535--8558},
  year={2022},
  organization={PMLR}
}

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

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

GPU в ailist

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

Нельзя запустить

Обработка «аудио → аудио» пока не поддерживается.

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

0 моделей