Model Details

This model is finetuned on mutiple datasets related to ABC notation (mostly Irish data)

CLI demo

from transformers import AutoTokenizer, AutoModelForCausalLM, GenerationConfig
import torch
import torchaudio
import re
from string import Template
prompt_template = Template("Human: ${inst} </s> Assistant: ")

tokenizer = AutoTokenizer.from_pretrained("Seeker38/gemma-2-9b-it-abc-notation", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("Seeker38/gemma-2-9b-it-abc-notation", torch_dtype=torch.float16, device_map="cuda", resume_download=True).eval()

generation_config = GenerationConfig(
    temperature=0.2,
    top_k=40,
    top_p=0.9,
    do_sample=True,
    num_beams=1,
    repetition_penalty=1.1,
    min_new_tokens=10,
    max_new_tokens=1536
)

instruction = """Develop a musical piece using the given chord progression.
'Dm', 'C', 'Dm', 'Dm', 'C', 'Dm', 'C', 'Dm'
"""

prompt = prompt_template.safe_substitute({"inst": instruction})
inputs = tokenizer(prompt, return_tensors="pt", add_special_tokens=False)
response = model.generate(
        input_ids=inputs["input_ids"].to(model.device),
        attention_mask=inputs['attention_mask'].to(model.device),
        eos_token_id=tokenizer.eos_token_id,
        generation_config=generation_config,
        )
response = tokenizer.decode(response[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)
print(response)

# to render abc notation, you need to install symusic
# pip install symusic
from symusic import Score, Synthesizer, BuiltInSF3, dump_wav

abc_pattern = r'(X:\d+\n(?:[^\n]*\n)+)'
abc_notation = re.findall(abc_pattern, response+'\n')[0]
s = Score.from_abc(abc_notation)
audio = Synthesizer().render(s, stereo=True)
torchaudio.save('cm_music_piece.wav', torch.FloatTensor(audio), 44100)

Example Stable Prompts

Here some prompts that are tested to be stable. The convert code and prompt is from ๐Ÿค— ChatMusician.

Function: Chord Conditioned Music Generation

Develop a musical piece using the given chord progression.
'Dm', 'C', 'Dm', 'Dm', 'C', 'Dm', 'C', 'Dm'

Function: Text2music

Develop a tune influenced by Bach's compositions.
Using ABC notation, recreate the given text as a musical score.
Meter C
Notes The parts are commonly interchanged.
Transcription 1997 by John Chambers
Key D
Note Length 1/8
Rhythm reel

Function: Melody Harmonization

Construct smooth-flowing chord progressions for the supplied music.

|: BA | G2 g2"^(C)" edeg | B2 BA"^(D7)" BcBA | G2 g2 edeg | dBAG A2 BA |
G2 g2"^(C)" edeg | B2 BA B2 d2 | e2 ef e2 (3def | gedB A2 :: BA | G2 BG dGBe |
dBBA"^(D7)" B3 A | G2 BG dGBe | dBAG A4 | G2 BG dGBe | dBBA B3 d |
e2 ef e2 (3def | gedB A2 :|
Develop a series of chord pairings that amplify the harmonious elements in the given music piece.

E |: EAA ABc | Bee e2 d | cBA ABc | BEE E2 D | EAA ABc | Bee e2 d |
cBA ^GAB |1 A2 A A2 E :|2 A2 A GAB || c3 cdc | Bgg g2 ^g | aed cBA |
^GAB E^F^G | A^GA BAB | cde fed | cBA ^GAB |1 A2 A GAB :|2 \n A3 A2 ||

Function: Musical Form Conditioned Music Generation

Develop a composition by incorporating elements from the given melodic structure.

Ternary, Sectional: Verse/Chorus/Bridge

Function: Motif and Form Conditioned Music Generation

Create music by following the alphabetic representation of the assigned musical structure and the given motif.

Musical Form Input: AB

ABC Notation Music Input:
X:1
L:1/8
M:2/4
K:D
['d>ef>d g>ef>c d>ef>d c2 e2 d>ef>d g>ef>d', '(3(Ace) (3(Ace)']
Downloads last month
19
Safetensors
Model size
9.24B params
Tensor type
FP16
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for Seeker38/gemma-2-9b-it-abc-notation

Finetunes
1 model