Text Generation
Transformers
Safetensors
gemma2
unsloth
trl
sft
conversational
text-generation-inference
Instructions to use Seeker38/gemma-2-9b-it-abc-notation with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Seeker38/gemma-2-9b-it-abc-notation with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Seeker38/gemma-2-9b-it-abc-notation") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Seeker38/gemma-2-9b-it-abc-notation") model = AutoModelForCausalLM.from_pretrained("Seeker38/gemma-2-9b-it-abc-notation") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use Seeker38/gemma-2-9b-it-abc-notation with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Seeker38/gemma-2-9b-it-abc-notation" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Seeker38/gemma-2-9b-it-abc-notation", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Seeker38/gemma-2-9b-it-abc-notation
- SGLang
How to use Seeker38/gemma-2-9b-it-abc-notation 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 "Seeker38/gemma-2-9b-it-abc-notation" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Seeker38/gemma-2-9b-it-abc-notation", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "Seeker38/gemma-2-9b-it-abc-notation" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Seeker38/gemma-2-9b-it-abc-notation", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Studio new
How to use Seeker38/gemma-2-9b-it-abc-notation with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for Seeker38/gemma-2-9b-it-abc-notation to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for Seeker38/gemma-2-9b-it-abc-notation to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for Seeker38/gemma-2-9b-it-abc-notation to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="Seeker38/gemma-2-9b-it-abc-notation", max_seq_length=2048, ) - Docker Model Runner
How to use Seeker38/gemma-2-9b-it-abc-notation with Docker Model Runner:
docker model run hf.co/Seeker38/gemma-2-9b-it-abc-notation
Model Details
This model is finetuned on mutiple datasets related to ABC notation (mostly Irish data)
CLI demo for 4-bit quantize
from transformers import AutoTokenizer, AutoModelForCausalLM, GenerationConfig, BitsAndBytesConfig
import torch
import torchaudio
import re
quantization_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_compute_dtype=torch.float16,
bnb_4bit_use_double_quant=True,
bnb_4bit_quant_type="nf4"
)
# Alpaca prompt template
alpaca_prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
### Instruction:
{}
### Input:
{}
### Response:
{}"""
tokenizer = AutoTokenizer.from_pretrained("Seeker38/gemma-2-9b-it-abc-notation")
# model 4-bit quant
model = AutoModelForCausalLM.from_pretrained(
"Seeker38/gemma-2-9b-it-abc-notation",
quantization_config=quantization_config,
device_map="auto",
resume_download=True
).eval()
generation_config = GenerationConfig(
temperature=0.2,
top_k=40,
top_p=0.9,
do_sample=True,
num_beams=1,
repetition_penalty=1.1,
min_new_tokens=10,
max_new_tokens=1536
)
instruction = """Create a musical composition using the given motif and adhering to the specified musical form represented by alphabet characters.
X:1
L:1/8
Q:3/8=90
M:6/8
K:A
['e cAA ABc dBB Tf2 e fdd', 'e fga']"""
# input_context = "'A', 'D', 'E7', 'A', 'E/G#', 'A', 'Bm', 'A7/C#', 'D', 'E7', 'A', 'A', 'D', 'A', 'A', 'D', 'A', 'A', 'D', 'A', 'D', 'A/D#', 'E', 'A', 'D', 'A', 'A', 'D', 'A', 'E7'"
input_context = ""
prompt = alpaca_prompt.format(
instruction, # instruction
input_context, # input
"", # output - leave this blank for generation!
)
# Tokenize input
inputs = tokenizer([prompt], return_tensors="pt").to("cuda")
# Generate response with specified parameters
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=2048,
temperature=0.2,
top_p=0.9,
top_k=40,
use_cache=True,
do_sample=True,
repetition_penalty=1.1,
pad_token_id=tokenizer.eos_token_id
)
result = tokenizer.batch_decode(outputs, skip_special_tokens=True)
print("Generated Response:")
print(result[0])
# to render abc notation, you need to install symusic
# pip install symusic
import re
from symusic import Score, Synthesizer
abc_notation = re.search(r'### Response:\s*(.*)', result[0], re.DOTALL).group(1).strip()
s = Score.from_abc(abc_notation)
audio = Synthesizer().render(s, stereo=True)
torchaudio.save('cm_music_piece.wav', torch.FloatTensor(audio), 44100)
from IPython.display import Audio, display
from pydub import AudioSegment
wav_link = "cm_music_piece.wav"
mp3_file = AudioSegment.from_wav(wav_link).export("cm_music_piece.mp3", format="mp3")
display(Audio(wav_link))
display(Audio('cm_music_piece.mp3'))
Example Stable Prompts
Here some prompts that are tested to be stable. The convert code and prompt is from 🤗 ChatMusician.
Function: Chord Conditioned Music Generation
Develop a musical piece using the given chord progression.
'Dm', 'C', 'Dm', 'Dm', 'C', 'Dm', 'C', 'Dm'
Function: Text2music
Develop a tune influenced by Bach's compositions.
Using ABC notation, recreate the given text as a musical score.
Meter C
Notes The parts are commonly interchanged.
Transcription 1997 by John Chambers
Key D
Note Length 1/8
Rhythm reel
Function: Melody Harmonization
Construct smooth-flowing chord progressions for the supplied music.
|: BA | G2 g2"^(C)" edeg | B2 BA"^(D7)" BcBA | G2 g2 edeg | dBAG A2 BA |
G2 g2"^(C)" edeg | B2 BA B2 d2 | e2 ef e2 (3def | gedB A2 :: BA | G2 BG dGBe |
dBBA"^(D7)" B3 A | G2 BG dGBe | dBAG A4 | G2 BG dGBe | dBBA B3 d |
e2 ef e2 (3def | gedB A2 :|
Develop a series of chord pairings that amplify the harmonious elements in the given music piece.
E |: EAA ABc | Bee e2 d | cBA ABc | BEE E2 D | EAA ABc | Bee e2 d |
cBA ^GAB |1 A2 A A2 E :|2 A2 A GAB || c3 cdc | Bgg g2 ^g | aed cBA |
^GAB E^F^G | A^GA BAB | cde fed | cBA ^GAB |1 A2 A GAB :|2 \n A3 A2 ||
Function: Musical Form Conditioned Music Generation
Develop a composition by incorporating elements from the given melodic structure.
Ternary, Sectional: Verse/Chorus/Bridge
Function: Motif and Form Conditioned Music Generation
Create music by following the alphabetic representation of the assigned musical structure and the given motif.
Musical Form Input: AB
ABC Notation Music Input:
X:1
L:1/8
M:2/4
K:D
['d>ef>d g>ef>c d>ef>d c2 e2 d>ef>d g>ef>d', '(3(Ace) (3(Ace)']
- Downloads last month
- 1