findnitai/english-to-hinglish
Viewer • Updated • 189k • 112 • 23
How to use rudrashah/RLM-hinglish-translator-bidir-2 with Transformers:
# Use a pipeline as a high-level helper
# Warning: Pipeline type "translation" is no longer supported in transformers v5.
# You must load the model directly (see below) or downgrade to v4.x with:
# 'pip install "transformers<5.0.0'
from transformers import pipeline
pipe = pipeline("translation", model="rudrashah/RLM-hinglish-translator-bidir-2") # Load model directly
from transformers import AutoProcessor, AutoModelForMultimodalLM
processor = AutoProcessor.from_pretrained("rudrashah/RLM-hinglish-translator-bidir-2")
model = AutoModelForMultimodalLM.from_pretrained("rudrashah/RLM-hinglish-translator-bidir-2", device_map="auto")How to use rudrashah/RLM-hinglish-translator-bidir-2 with PEFT:
Task type is invalid.
RLM-hinglish-translator-bidir-2 is a fully bidirectional Hinglish ↔ English translation model — the first in this series to support translation in both directions. Built on the same 4B instruction-tuned base as v2 and fine-tuned using PEFT (LoRA) with TRL's SFTTrainer, it lets you seamlessly convert between informal Hinglish and English without needing two separate models.
findnitai/english-to-hinglish dataset for balanced performance.from transformers import AutoTokenizer, AutoModelForCausalLM
model_id = "rudrashah/RLM-hinglish-translator-bidir-2"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id)
messages = [
{
"role": "user",
"content": "Hinglish:\naapka name kya hai?"
}
]
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
).to("cuda")
outputs = model.generate(
**inputs,
max_new_tokens=128,
use_cache=True,
temperature=1.0,
top_p=0.95,
top_k=64,
)
print(tokenizer.batch_decode(outputs))
messages = [
{
"role": "user",
"content": "English:\nWhat are you doing tomorrow?"
}
]
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
).to("cuda")
outputs = model.generate(
**inputs,
max_new_tokens=128,
use_cache=True,
temperature=1.0,
top_p=0.95,
top_k=64,
)
print(tokenizer.batch_decode(outputs))
Note: Always include the Language of Input for Best Result.
| Hinglish Input | English Output |
|---|---|
aapka name kya hai? |
What is your name? |
kal mujhe office jaana hai |
I have to go to the office tomorrow. |
Tumne kal ki match dekhi thi? kon man of the match bana tha? |
Did you watch yesterday's match? Who was man of the match? |
| English Input | Hinglish Output |
|---|---|
What is your name? |
aapka naam kya hai? |
I have to go to the office tomorrow. |
kal mujhe office jaana hai. |
Did you watch yesterday's match? |
Tumne kal ki match dekhi thi? |
| Model | Direction | Base Model | Notes |
|---|---|---|---|
| RLM-hinglish-translator | Hinglish → English | 2B | Original release |
| RLM-hinglish-translator-2 | Hinglish → English | 4B | Chat-format fine-tuning, LoRA rank 64 |
| RLM-hinglish-translator-bidir-2 (this) | Hinglish ↔ English | 4B | Bidirectional support |
Thanks to that one girl who motivated me. Thank you P.