Views
No views yet
Aria is a pretrained autoregressive generative model for symbolic music based on the LLaMA 3.2 (1B) architecture. It was trained on ~60k hours of MIDI transcriptions of expressive solo-piano recordings. It has been finetuned to produce realistic continuations of solo-piano compositions as well as to produce general-purpose contrastive MIDI embeddings.pip install git+https://github.com/EleutherAI/aria-utils.git1pip install transformers
2pip install torch1from transformers import AutoModelForCausalLM
2from transformers import AutoTokenizer
3
4PROMPT_MIDI_LOAD_PATH = "mydir/prompt.midi"
5MAX_SEQ_LEN = 2048
6
7model = AutoModelForCausalLM.from_pretrained(
8 "loubb/aria-medium-embedding",
9 trust_remote_code=True,
10)
11tokenizer = AutoTokenizer.from_pretrained(
12 "loubb/aria-medium-embedding",
13 trust_remote_code=True,
14)
15
16prompt = tokenizer.encode_from_file(PROMPT_MIDI_LOAD_PATH, return_tensors="pt")
17
18# Only sequences up to 2048 are supported.
19# Embedding is extracted from end-of-sequence token
20assert prompt.input_ids.shape[1] <= MAX_SEQ_LEN
21assert prompt.input_ids[0, -1] == tokenizer._convert_token_to_id(tokenizer.eos_token)
22
23# Alternatively if the sequence is too long:
24prompt.input_ids = prompt.input_ids[:, :MAX_SEQ_LEN]
25prompt.input_ids[:, -1] = tokenizer._convert_token_to_id(tokenizer.eos_token)
26
27# Generate and extract embedding
28outputs = model.forward(input_ids=prompt.input_ids)
29embedding = outputs[0].squeeze(0)1@inproceedings{bradshawscaling,
2 title={Scaling Self-Supervised Representation Learning for Symbolic Piano Performance},
3 author={Bradshaw, Louis and Fan, Honglu and Spangher, Alex and Biderman, Stella and Colton, Simon},
4 booktitle={arXiv preprint},
5 year={2025},
6 url={https://arxiv.org/abs/2504.15071}
7}