a43992899 commited on
Commit
fcc094a
1 Parent(s): d55b50f

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +51 -49
README.md CHANGED
@@ -25,6 +25,57 @@ margin. Our work reveals that LLMs can be an excellent compressor for music, but
25
 
26
  <!-- <audio controls src="https://cdn-uploads.huggingface.co/production/uploads/5fd6f670053c8345eddc1b68/8NSONUjIF7KGUCfwzPCd9.mpga"></audio> -->
27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  ## Example Prompts
29
 
30
  **Our model produces symbolic music(ABC notation) well in the following prompts.** Here are some musical tasks.
@@ -144,56 +195,7 @@ We included GPT-3.5, GPT-4, LLaMA2-7B-Base, ChatMusician-Base, and ChatMusician.
144
  2. General language abilities of ChatMusician are evaluated on the [Massive Multitask Language Understanding (MMLU) dataset](https://huggingface.co/datasets/lukaemon/mmlu).
145
 
146
 
147
- ## Usage
148
-
149
- You can use the models through Huggingface's Transformers library. Check our Github repo for more advanced use: [https://github.com/hf-lin/ChatMusician](https://github.com/hf-lin/ChatMusician)
150
-
151
- ## CLI demo
152
- ```python
153
- from transformers import AutoTokenizer, AutoModelForCausalLM, GenerationConfig
154
- from string import Template
155
- prompt_template = Template("Human: ${inst} </s> Assistant: ")
156
-
157
- tokenizer = AutoTokenizer.from_pretrained("m-a-p/ChatMusician-v1-sft-78k", trust_remote_code=True)
158
- model = AutoModelForCausalLM.from_pretrained("m-a-p/ChatMusician-v1-sft-78k", trust_remote_code=True).eval()
159
- model.cuda()
160
- generation_config = GenerationConfig(
161
- temperature=0.2,
162
- top_k=40,
163
- top_p=0.9,
164
- do_sample=True,
165
- num_beams=1,
166
- repetition_penalty=1.1,
167
- min_new_tokens=10,
168
- max_new_tokens=1536
169
- )
170
-
171
- instruction = """Using ABC notation, recreate the given text as a musical score.
172
- Meter C
173
- Notes The parts are commonly interchanged.
174
- Transcription 1997 by John Chambers
175
- Key D
176
- Note Length 1/8
177
- Rhythm reel
178
- """
179
-
180
- prompt = prompt_template.safe_substitute({"inst": instruction})
181
- inputs = tokenizer(prompt, return_tensors="pt", add_special_tokens=False)
182
- response = model.generate(
183
- input_ids=inputs["input_ids"].to(model.device),
184
- attention_mask=inputs['attention_mask'].to(model.device),
185
- eos_token_id=tokenizer.eos_token_id,
186
- generation_config=generation_config,
187
- )
188
- response = tokenizer.decode(response[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)
189
- print(response)
190
- ```
191
 
192
- ## Limitations
193
- - For the music tasks, the model currently only supports strict format and close-ended instructions.
194
- - The model suffers from hallucinations, and shouldn't be used for music education.
195
- - A large proportion of the training data is in the style of Irish music.
196
- - The MusicThoeryBench results reported in the paper are obtained with perplexity mode.
197
 
198
  ## Citation
199
  If you find our work helpful, feel free to give us a cite.
 
25
 
26
  <!-- <audio controls src="https://cdn-uploads.huggingface.co/production/uploads/5fd6f670053c8345eddc1b68/8NSONUjIF7KGUCfwzPCd9.mpga"></audio> -->
27
 
28
+ ## Usage
29
+
30
+ You can use the models through Huggingface's Transformers library. Check our Github repo for more advanced use: [https://github.com/hf-lin/ChatMusician](https://github.com/hf-lin/ChatMusician)
31
+
32
+ ## CLI demo
33
+ ```python
34
+ from transformers import AutoTokenizer, AutoModelForCausalLM, GenerationConfig
35
+ from string import Template
36
+ prompt_template = Template("Human: ${inst} </s> Assistant: ")
37
+
38
+ tokenizer = AutoTokenizer.from_pretrained("m-a-p/ChatMusician-v1-sft-78k", trust_remote_code=True)
39
+ model = AutoModelForCausalLM.from_pretrained("m-a-p/ChatMusician-v1-sft-78k", trust_remote_code=True).eval()
40
+ model.cuda()
41
+ generation_config = GenerationConfig(
42
+ temperature=0.2,
43
+ top_k=40,
44
+ top_p=0.9,
45
+ do_sample=True,
46
+ num_beams=1,
47
+ repetition_penalty=1.1,
48
+ min_new_tokens=10,
49
+ max_new_tokens=1536
50
+ )
51
+
52
+ instruction = """Using ABC notation, recreate the given text as a musical score.
53
+ Meter C
54
+ Notes The parts are commonly interchanged.
55
+ Transcription 1997 by John Chambers
56
+ Key D
57
+ Note Length 1/8
58
+ Rhythm reel
59
+ """
60
+
61
+ prompt = prompt_template.safe_substitute({"inst": instruction})
62
+ inputs = tokenizer(prompt, return_tensors="pt", add_special_tokens=False)
63
+ response = model.generate(
64
+ input_ids=inputs["input_ids"].to(model.device),
65
+ attention_mask=inputs['attention_mask'].to(model.device),
66
+ eos_token_id=tokenizer.eos_token_id,
67
+ generation_config=generation_config,
68
+ )
69
+ response = tokenizer.decode(response[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)
70
+ print(response)
71
+ ```
72
+
73
+ ## Limitations
74
+ - For the music tasks, the model currently only supports strict format and close-ended instructions.
75
+ - The model suffers from hallucinations, and shouldn't be used for music education.
76
+ - A large proportion of the training data is in the style of Irish music.
77
+ - The MusicThoeryBench results reported in the paper are obtained with perplexity mode.
78
+
79
  ## Example Prompts
80
 
81
  **Our model produces symbolic music(ABC notation) well in the following prompts.** Here are some musical tasks.
 
195
  2. General language abilities of ChatMusician are evaluated on the [Massive Multitask Language Understanding (MMLU) dataset](https://huggingface.co/datasets/lukaemon/mmlu).
196
 
197
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
198
 
 
 
 
 
 
199
 
200
  ## Citation
201
  If you find our work helpful, feel free to give us a cite.