GPT2 Music Generation Trained
简介
核心亮点
- 基于 GPT-2 架构,将音乐创作转化为序列预测
- 轻量级部署,适合快速验证音乐生成逻辑
- 支持根据输入引导自动续写旋律片段
- 采用 MIT 协议,对商业集成和二次开发极友好
使用方法
# 安装 Hugging Face transformers
pip install transformers torch
# 使用 transformers 加载模型
from transformers import AutoModel, AutoTokenizer
model = AutoModel.from_pretrained("hardikpatel/GPT2_Music_Generation_Trained")
tokenizer = AutoTokenizer.from_pretrained("hardikpatel/GPT2_Music_Generation_Trained")
Hugging Face 下载
我们推荐使用命令行或者 Hugging Face Hub SDK 来进行模型的下载。
操作指引:在下载前,请先通过如下命令安装 huggingface_hub:
pip install -U huggingface_hub
命令行下载
下载完整模型库
huggingface-cli download hardikpatel/GPT2_Music_Generation_Trained
下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)
huggingface-cli download hardikpatel/GPT2_Music_Generation_Trained config.json --local-dir ./dir
SDK 下载
# 模型下载
from huggingface_hub import snapshot_download
model_dir = snapshot_download('hardikpatel/GPT2_Music_Generation_Trained')
Git 下载
请确保 lfs 已经被正确安装
git lfs install
git clone https://huggingface.co/hardikpatel/GPT2_Music_Generation_Trained
如果您希望跳过 lfs 大文件下载,可以使用如下命令
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/hardikpatel/GPT2_Music_Generation_Trained
模型文件托管在 Hugging Face Hub,使用 HF CLI / SDK / Git 直接下载,不经过本站。
PyTorch / Transformers 使用
安装 Transformers
pip install -U transformers torch
模型加载和推理
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained('hardikpatel/GPT2_Music_Generation_Trained')
tokenizer = AutoTokenizer.from_pretrained('hardikpatel/GPT2_Music_Generation_Trained')
完整文档
---
license: mit
tags:
- generated_from_trainer
model-index:
- name: lmd-8bars-2048-epochs10
results: []
---
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
should probably proofread and complete it, then remove this comment. -->
lmd-8bars-2048-epochs10
This model is a fine-tuned version of gpt2 on the None dataset.
It achieves the following results on the evaluation set:
- Loss: 1.0086
Model description
More information needed
Intended uses & limitations
More information needed
Training and evaluation data
More information needed
Training procedure
Training hyperparameters
The following hyperparameters were used during training:
- learning_rate: 0.0005
- train_batch_size: 8
- eval_batch_size: 4
- seed: 1
- gradient_accumulation_steps: 2
- total_train_batch_size: 16
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
- lr_scheduler_type: cosine
- lr_scheduler_warmup_ratio: 0.01
- num_epochs: 10
Training results
| Training Loss | Epoch | Step | Validation Loss |
|:-------------:|:-----:|:-----:|:---------------:|
| 2.4182 | 0.5 | 4994 | 1.4933 |
| 1.4626 | 1.0 | 9988 | 1.3082 |
| 1.3176 | 1.5 | 14982 | 1.2276 |
| 1.2604 | 2.0 | 19976 | 1.1815 |
| 1.2101 | 2.5 | 24970 | 1.1499 |
| 1.1804 | 3.0 | 29964 | 1.1260 |
| 1.1517 | 3.5 | 34958 | 1.1043 |
| 1.1349 | 4.0 | 39952 | 1.0887 |
| 1.1133 | 4.5 | 44946 | 1.0762 |
| 1.0995 | 5.0 | 49940 | 1.0618 |
| 1.0824 | 5.5 | 54934 | 1.0507 |
| 1.0713 | 6.0 | 59928 | 1.0423 |
| 1.0552 | 6.5 | 64922 | 1.0328 |
| 1.0505 | 7.0 | 69916 | 1.0279 |
| 1.0365 | 7.5 | 74910 | 1.0217 |
| 1.0307 | 8.0 | 79904 | 1.0153 |
| 1.022 | 8.5 | 84898 | 1.0107 |
| 1.0189 | 9.0 | 89892 | 1.0090 |
| 1.0129 | 9.5 | 94886 | 1.0084 |
| 1.0139 | 10.0 | 99880 | 1.0086 |
Framework versions
- Transformers 4.30.2
- Pytorch 2.0.1+cu118
- Datasets 2.13.1
- Tokenizers 0.13.3