Downloads · 30 days
208
36% of all-time downloads
mlx-community/ChatMusician-hf-4bit-mlx
ChatMusician-hf-4bit-mlx is a text generation model from mlx-community. Use it when you need the model to write or continue text. It is set up for mlx. The card lists the license as mit.
This model was converted to MLX format from m-a-p/ChatMusician. Refer to the original model card for more details on the model.
Downloads · 30 days
208
36% of all-time downloads
All-time downloads
581
Public
Parameters
6.7B
4 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors4 GB · 100%
How the weights are stored.
U326.6B · 98%
From the Hugging Face model README
This model was converted to MLX format from m-a-p/ChatMusician.
Refer to the original model card for more details on the model.
pip install mlx-lm
import re
from string import Template
from mlx_lm.utils import generate, load
prompt_template = Template("Human: ${inst} </s> Assistant: ")
model, tokenizer = load("mlx-community/ChatMusician-hf-4bit-mlx")
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})
response = generate(
model=model,
tokenizer=tokenizer,
prompt=prompt,
temp=0.6,
top_p=0.9,
max_tokens=1000,
repetition_penalty=1.1,
)
# pip install symusic
from symusic import Score, Synthesizer
import wave
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)
sample_rate = 44100
audio = (audio * 32767).astype("int16")
with wave.open("cm_music_piece.wav", "w") as wf:
wf.setnchannels(2)
wf.setsampwidth(2)
wf.setframerate(sample_rate)
wf.writeframes(audio.tobytes())