Downloads · 30 days
7
5% of all-time downloads
JacobLinCool/gemma-3n-E4B-transcribe-zh-tw-1
gemma-3n-E4B-transcribe-zh-tw-1 is a machine learning model from JacobLinCool. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for peft.
This model is a fine-tuned version of google/gemma-3n-E4B-it. It has been trained using TRL.
Downloads · 30 days
7
5% of all-time downloads
All-time downloads
138
Public
Parameters
7.8B
21.5 GB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors17.5 GB · 86%
From the Hugging Face model README
This model is a fine-tuned version of google/gemma-3n-E4B-it. It has been trained using TRL.
import torch
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoProcessor
device = "cuda" if torch.cuda.is_available() else "cpu"
processor = AutoProcessor.from_pretrained("google/gemma-3n-E4B-it", device_map="auto")
base_model = AutoModelForCausalLM.from_pretrained("google/gemma-3n-E4B-it")
model = PeftModel.from_pretrained(
base_model, "JacobLinCool/gemma-3n-E4B-transcribe-zh-tw-1"
).to(device)
def trascribe(model, processor, audio):
messages = [
{
"role": "system",
"content": [
{
"type": "text",
"text": "You are an assistant that transcribes speech accurately.",
}
],
},
{
"role": "user",
"content": [
{"type": "audio", "audio": audio},
{"type": "text", "text": "Transcribe this audio."},
],
},
]
input_ids = processor.apply_chat_template(
messages,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
)
input_ids = input_ids.to(device, dtype=model.dtype)
model.eval()
with torch.no_grad():
outputs = model.generate(**input_ids, max_new_tokens=128)
prediction = processor.batch_decode(
outputs, skip_special_tokens=True, clean_up_tokenization_spaces=False
)[0]
prediction = prediction.split("\nmodel\n")[-1].strip()
return prediction
if __name__ == "__main__":
prediction = trascribe(model, processor, "/workspace/audio.mp3")
print(prediction)
This model was trained with SFT.
Cite TRL as:
@misc{vonwerra2022trl,
title = {{TRL: Transformer Reinforcement Learning}},
author = {Leandro von Werra and Younes Belkada and Lewis Tunstall and Edward Beeching and Tristan Thrush and Nathan Lambert and Shengyi Huang and Kashif Rasul and Quentin Gallou{\'e}dec},
year = 2020,
journal = {GitHub repository},
publisher = {GitHub},
howpublished = {\url{https://github.com/huggingface/trl}}
}