traintogpb/aihub-koen-translation-integrated-large-10m
Viewer • Updated • 10.4M • 1.6k • 18
How to use DevWorld/Gemago-2b 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="DevWorld/Gemago-2b") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("DevWorld/Gemago-2b")
model = AutoModelForCausalLM.from_pretrained("DevWorld/Gemago-2b")Original Gemma Model Page: Gemma
Model Page On Github: Gemago
Resources and Technical Documentation:
Terms of Use: Terms
Authors: Orginal Google, Fine-tuned by DevWorld
Translate English/Korean to Korean/English.
Gemago is a lightweight English-and-Korean translation model based on Gemma.
Models are trained on a context length of 8192 tokens, which is equivalent to Gemma.
Below we share some code snippets on how to get quickly started with running the model. First make sure to pip install -U transformers, then copy the snippet from the section that is relevant for your usecase.
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("devworld/gemago-2b")
model = AutoModelForCausalLM.from_pretrained("devworld/gemago-2b")
def gen(text, max_length):
input_ids = tokenizer(text, return_tensors="pt")
outputs = model.generate(**input_ids, max_length=max_length)
return tokenizer.decode(outputs[0])
def e2k(e):
input_text = f"English:\n{e}\n\nKorean:\n"
return gen(input_text, 1024)
def k2e(k):
input_text = f"Korean:\n{k}\n\nEnglish:\n"
return gen(input_text, 1024)