add readme for inference
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
# MIDI-LLM
|
||||
[NeurIPS AI4Music '25] MIDI-LLM: Adapting LLMs for text-to-MIDI music generation.
|
||||
|
||||
Built with Llama 3.2 (1B) LLM.
|
||||
Built on **Llama 3.2 (1B)** with an extended vocabulary for MIDI tokens.
|
||||
|
||||
# Setup
|
||||
## Research Paper
|
||||
- Shih-Lun Wu, Yoon Kim, and Cheng-Zhi Anna Huang.
|
||||
"**MIDI-LLM: Adapting large language models for text-to-MIDI music generation**."
|
||||
NeurIPS AI4Music Workshop, 2025.
|
||||
|
||||
## Setup
|
||||
|
||||
- A GPU with 16GB+ VRAM and CUDA 12.x is recommended
|
||||
|
||||
@@ -48,4 +52,55 @@ pip install -r requirements.txt
|
||||
- Verify all installation
|
||||
```bash
|
||||
python -c "import torch; from vllm import LLM; from anticipation.convert import events_to_midi; print('Setup successful')"
|
||||
```
|
||||
|
||||
## Run Inference with vLLM
|
||||
### Example 1: Single prompt
|
||||
```bash
|
||||
python generate_vllm.py \
|
||||
--model slseanwu/MIDI-LLM_Llama-3.2-1B # will pull from huggingface hub \
|
||||
--prompt "A cheerful piano melody"
|
||||
```
|
||||
This will output 4 MIDIs (and the synthesized MP3s) conditioned on the same input prompt
|
||||
|
||||
### Example 2: Batch generation from file
|
||||
|
||||
```bash
|
||||
python generate_vllm.py \
|
||||
--model slseanwu/MIDI-LLM_Llama-3.2-1B \
|
||||
--prompts_file some_example_prompts.txt \
|
||||
--fp8 \
|
||||
--no-synthesize
|
||||
```
|
||||
- `some_example_prompts.txt` should contain one prompt per line.
|
||||
- `--fp8` performs dynamic weight quantization for faster inference.
|
||||
- `--no-synthesize` skips audio synthesis (i.e., outputs MIDI only).
|
||||
|
||||
### Example 3: Interactive mode
|
||||
|
||||
```bash
|
||||
python generate_vllm.py \
|
||||
--model slseanwu/MIDI-LLM_Llama-3.2-1B \
|
||||
--output_root generations_interactive/ \
|
||||
--interactive
|
||||
```
|
||||
- Outputs will be saved under `generations_interactive/`
|
||||
This loads the model once, then lets you enter prompts interactively. Press Enter with empty prompt to exit.
|
||||
|
||||
### More options
|
||||
See full options with:
|
||||
```bash
|
||||
python generate_vllm.py --help
|
||||
```
|
||||
|
||||
### Inference Output Structure
|
||||
```
|
||||
[output_root]/
|
||||
└── 2025-10-30_143022/ # Session timestamp
|
||||
├── 20251030_143022_prompt_1/
|
||||
│ ├── prompt.txt
|
||||
│ ├── gen_1.mid
|
||||
│ ├── gen_1.mp3
|
||||
│ └── ...
|
||||
└── generation_stats.json
|
||||
```
|
||||
Reference in New Issue
Block a user