Edit model card

mT5-small based Turkish Question Answering System

Google's Multilingual T5-small is fine-tuned on Turkish SQuAD for Q&A downstream task by using Pytorch Lightning.

The notebook that includes all fine tuning process will be shared on my Github page later github. mT5 small model has 300 million parameters and model size is about 1.2GB. Therefore, it takes significant amount of time to fine tune it.

Usage 🚀

from transformers import T5TokenizerFast, AutoModelForSeq2SeqLM

tokenizer = T5TokenizerFast.from_pretrained('google/mt5-small')
model = AutoModelForSeq2SeqLM.from_pretrained("anilguven/mt5-small_squad_tr")

def get_answer(question,context):
    input_str = context + " " + question
    source_encoding=tokenizer(
    input_str,
    max_length=512,
    padding="max_length",
    truncation="only_second",
    return_attention_mask=True,
    add_special_tokens=True,
    return_tensors="pt")
    
    model.to("cpu")
    
    generated_ids=model.generate(
      input_ids=source_encoding["input_ids"],
      attention_mask=source_encoding["attention_mask"],
      num_beams=10, 
      num_return_sequences=1,
      max_length=128)

    preds=[tokenizer.decode(gen_id, skip_special_tokens=True, clean_up_tokenization_spaces=True) for gen_id in generated_ids]

    return preds #"".join(preds)

Example 1

question={
    "context":"Ingilizce adi 'Normans' Fransizca kelime Normans/Normanz, Normant çogul, modern Fransiz normand, hangi kendisi \
    Eski Düsük Frankonian Nortmann 'Northman' ödünç veya dogrudan Eski Norse Norðmaðr, Nortmannus, veya Nordmannus (Ortaçag Latince \
    kaydedildi, 9. yüzyil) 'Norseman, Viking' anlamina gelir.",
    "question":"Norman kelimesinin Latince versiyonu ilk ne zaman kaydedildi?"
    }
    
get_answer(question["question"],question["context"])
  1. yüzyil

Example 2

question={
    "context":"Karar sorununa bir örnek asagidaki gibidir. Girdi keyfi bir grafiktir. Sorun, verilen grafigin bagli olup olmadigina \
     karar vermekten olusur. Bu karar problemi ile iliskili biçimsel dil daha sonra bagli tüm grafiklerin kümesidir - tabii ki, bu \
     dilin kesin bir tanimini elde etmek için, grafiklerin ikili dize olarak nasil kodlandigina karar vermelidir.",
    "question":"Karar probleminde kullanilan çiktiya bir örnek ne tür bir grafik?"
    }
    
get_answer(question["question"],question["context"])

No Answer

Downloads last month
12
Safetensors
Model size
300M params
Tensor type
F32
·
Inference Examples
This model does not have enough activity to be deployed to Inference API (serverless) yet. Increase its social visibility and check back later, or deploy to Inference Endpoints (dedicated) instead.

Collection including anilguven/mt5-small_squad_tr