How to use from the
Use from the
Transformers library
# Use a pipeline as a high-level helper
from transformers import pipeline

pipe = pipeline("text-generation", model="culturalheritagenus/Rumi-degarbler-Gemma-v1")
messages = [
    {"role": "user", "content": "Who are you?"},
]
pipe(messages)
# Load model directly
from transformers import AutoTokenizer, AutoModelForMultimodalLM

tokenizer = AutoTokenizer.from_pretrained("culturalheritagenus/Rumi-degarbler-Gemma-v1")
model = AutoModelForMultimodalLM.from_pretrained("culturalheritagenus/Rumi-degarbler-Gemma-v1")
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]:]))
Quick Links

Model Card for Model ID

Model Details

Model Description

This model is trained to produce clean Jawi text from a garbled source, as part of an OCR pipeline.

  • Developed by: Computational Cultural Heritage Research Group (NUS).
  • Model type: Gemma 2 9B
  • Language(s) (NLP): Malay, English
  • Finetuned from model aisingapore/Gemma-SEA-LION-v3-9B-IT

How to Get Started with the Model

Use the code below to get started with the model:

from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer

trained_model = AutoModelForCausalLM.from_pretrained(
    "culturalheritagenus/rumi-degarbler-v1",
    device_map="auto",
    torch_dtype=torch.bfloat16
)
trained_tokenizer = AutoTokenizer.from_pretrained("culturalheritagenus/rumi-degarbler-v1")

To perform inference:

messages = [
    {"role": "user", "content": "You are a Malay language spelling corrector. I will give you some text written in messy Rumi (shortened or mistyped). Rewrite it in correct Malay Rumi spelling.\naurng ank. yngdim dimn anm aurngdan"},
]
inputs = tokenizer.apply_chat_template(
    messages,
    tokenize = True,
    add_generation_prompt = True, # Must add for generation
    return_tensors = "pt",
).to("cuda")


text_streamer = TextStreamer(tokenizer)
_ = trained_model.generate(input_ids = inputs, streamer = text_streamer, max_new_tokens = 128, use_cache = True)

Training Details

Training Data

The model was trained on culturalheritagenus/rumi-correction-v2-data-v6-real

Environmental Impact

Carbon emissions can be estimated using the Machine Learning Impact calculator presented in Lacoste et al. (2019).

  • Hardware Type: 1x GH200 (96 GB)
  • Hours used: < 72
  • Cloud Provider: Lambda
  • Compute Region: US-East (Lambda Labs)

Technical Specifications

Software

  • Python version: 3.10.12
  • CUDA version: 12.8
  • Torch version: 2.7.1+cu128
Downloads last month
2
Safetensors
Model size
9B params
Tensor type
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for culturalheritagenus/Rumi-degarbler-Gemma-v1

Finetuned
(3)
this model

Collection including culturalheritagenus/Rumi-degarbler-Gemma-v1

Paper for culturalheritagenus/Rumi-degarbler-Gemma-v1