Instructions to use musiclang/musiclang-chord-v2-4k with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use musiclang/musiclang-chord-v2-4k with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="musiclang/musiclang-chord-v2-4k")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("musiclang/musiclang-chord-v2-4k") model = AutoModelForCausalLM.from_pretrained("musiclang/musiclang-chord-v2-4k", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use musiclang/musiclang-chord-v2-4k with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "musiclang/musiclang-chord-v2-4k" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "musiclang/musiclang-chord-v2-4k", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/musiclang/musiclang-chord-v2-4k
- SGLang
How to use musiclang/musiclang-chord-v2-4k with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "musiclang/musiclang-chord-v2-4k" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "musiclang/musiclang-chord-v2-4k", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "musiclang/musiclang-chord-v2-4k" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "musiclang/musiclang-chord-v2-4k", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use musiclang/musiclang-chord-v2-4k with Docker Model Runner:
docker model run hf.co/musiclang/musiclang-chord-v2-4k
MusicLang Chord Predictor model
MusicLang Chord Predictor is a model for creating original chord scale progressions in the musiclang format with generative AI model.
It can be used for different use cases :
- Predict a chord progression from scratch (a fixed number of chords)
- Continue a chord progression (using a MusicLang prompt)
If you are only looking to generate chord progressions in an easily readable format, consider using our text chord predictor
To make the prediction we have an inference package available here : MusicLang Predict which is based on the musiclang language : MusicLang.
Installation
Install the musiclang-predict package with pip :
pip install musiclang-predict
How to use ?
- Generate a 4 chords progression in few lines :
from musiclang_predict import predict_chords, MusicLangTokenizer
from transformers import AutoModelForCausalLM, AutoTokenizer
from musiclang.library import *
# Load model and tokenizer
model = AutoModelForCausalLM.from_pretrained('musiclang/musiclang-chord-v2-4k')
tokenizer = AutoTokenizer.from_pretrained('musiclang/musiclang-chord-v2-4k')
soundtrack = predict_chords(model, tokenizer, nb_chords=4, temperature=1.0)
# Give the chord a simple voicing (closed position chord)
soundtrack = soundtrack(b0, b1, b2, b3)
# Save it to midi
soundtrack.to_midi('song.mid', tempo=120, time_signature=(4, 4))
- Use a prompt
from musiclang_predict import predict_chords, MusicLangTokenizer
from transformers import AutoModelForCausalLM, AutoTokenizer
from musiclang.library import *
prompt = (I % I.M) + (V % I.M)['6'].o(-1)
# Load model and tokenizer
model = GPT2LMHeadModel.from_pretrained('musiclang/musiclang-chord-v2-4k')
tokenizer = AutoTokenizer.from_pretrained('musiclang/musiclang-chord-v2-4k')
soundtrack = predict_chords(model, tokenizer, nb_chords=4, prompt=prompt)
# Give the chord a simple voicing (closed position chord)
soundtrack = soundtrack(b0, b1, b2, b3)
# Save it to midi
soundtrack.to_midi('song.mid', tempo=120, time_signature=(4, 4))
Contact us
If you want to help shape the future of open source music generation, please contact us
License
This model is free to use for research and open source purpose only. Please credit me (Florian GARDIN) and musiclang if you do so.
If you would like to use this in a commercial product please contact us to discuss licensing terms and potential integration in your product. I am looking forward to hearing about your project !
- Downloads last month
- 286
