Views
No views yet
mistralai/Mistral-7B-Instruct-v0.1 that has been specialized to generate song lyrics.pipeline from the transformers library. The model has been fine-tuned to internalize the artist's style, so you only need to provide a creative brief. This method loads the model in full precision. Please read the next section for notes on hardware usage. 1from transformers import pipeline
2
3generator = pipeline('text-generation', model='etang98/lyric-generator-mvp')
4
5# Here is a simple template for a prompt
6prompt = """
7[INST]
8You are an expert lyricist emulating the style of Taylor Swift. Write a complete, original song based on the following creative brief.
9
10**Creative Brief:**
11- **Theme:** [Describe the song's topic, e.g., "A reflective song about memories in a small town"]
12- **Moods:** [List several moods, e.g., "Nostalgia, warmth, a little bittersweet"]
13- **Setting (Optional):** [Add any specific imagery, e.g., "An old coffee shop in the rain"]
14- **Additional Requirements (Optional):** [Anything else that should be included in the song, e.g., "Mention the year 1996"]
15
16Generate the full song lyrics now.
17[/INST]
18"""
19
20result = generator(prompt, max_new_tokens=750, temperature=0.7)
21print(result[0]['generated_text'])from_pretrained method.1from transformers import AutoTokenizer, AutoModelForCausalLM
2
3tokenizer = AutoTokenizer.from_pretrained("etang98/lyric-generator-mvp")
4model = AutoModelForCausalLM.from_pretrained("etang98/lyric-generator-mvp")1from transformers import AutoTokenizer, AutoModelForCausalLM
2
3tokenizer = AutoTokenizer.from_pretrained("etang98/lyric-generator-mvp")
4model = AutoModelForCausalLM.from_pretrained(
5 "etang98/lyric-generator-mvp",
6 load_in_8bit=True
7)1from transformers import AutoTokenizer, AutoModelForCausalLM
2
3tokenizer = AutoTokenizer.from_pretrained("etang98/lyric-generator-mvp")
4model = AutoModelForCausalLM.from_pretrained(
5 "etang98/lyric-generator-mvp",
6 load_in_4bit=True
7)1prompt = """
2[INST]
3You are an expert lyricist emulating the style of Taylor Swift. Write a complete, original song based on the following creative brief.
4
5**Creative Brief:**
6- **Theme:** [Describe the song's topic, e.g., "A reflective song about memories in a small town"]
7- **Moods:** [List several moods, e.g., "Nostalgia, warmth, a little bittersweet"]
8- **Setting (Optional):** [Add any specific imagery, e.g., "An old coffee shop in the rain"]
9- **Additional Requirements (Optional):** [Anything else that should be included in the song, e.g., "Mention the year 1996"]
10
11Generate the full song lyrics now.
12[/INST]
13"""
14
15# Tokenize the prompt
16inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
17
18# Generate the output tokens
19outputs = model.generate(**inputs, max_new_tokens=300, temperature=0.7)
20
21# Decode the tokens back to a string
22decoded_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
23print(decoded_text)r): 64alpha): 640.13e-52816 (2 * 8)0.010.120.0016 (Stopped after 5 due to early stopping)