Jawi
Collection
Models for historical documents in Jawi (an adaptation of the Perso-Arabic script for the Malay language) • 5 items • Updated
How to use culturalheritagenus/Rumi-degarbler-Gemma-v1 with Transformers:
# 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]:]))How to use culturalheritagenus/Rumi-degarbler-Gemma-v1 with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "culturalheritagenus/Rumi-degarbler-Gemma-v1"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "culturalheritagenus/Rumi-degarbler-Gemma-v1",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/culturalheritagenus/Rumi-degarbler-Gemma-v1
How to use culturalheritagenus/Rumi-degarbler-Gemma-v1 with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "culturalheritagenus/Rumi-degarbler-Gemma-v1" \
--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": "culturalheritagenus/Rumi-degarbler-Gemma-v1",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'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 "culturalheritagenus/Rumi-degarbler-Gemma-v1" \
--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": "culturalheritagenus/Rumi-degarbler-Gemma-v1",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use culturalheritagenus/Rumi-degarbler-Gemma-v1 with Docker Model Runner:
docker model run hf.co/culturalheritagenus/Rumi-degarbler-Gemma-v1
This model is trained to produce clean Jawi text from a garbled source, as part of an OCR pipeline.
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)
The model was trained on culturalheritagenus/rumi-correction-v2-data-v6-real
Carbon emissions can be estimated using the Machine Learning Impact calculator presented in Lacoste et al. (2019).
Base model
google/gemma-2-9b