Edit model card

mBART Large for Question Answering in Azerbaijani

This repository contains a fine-tuned mBART Large model for question answering in Azerbaijani. The model was trained on a custom dataset and can be used to answer questions based on a given context.

Model Details

Base Model: facebook/mbart-large-50
Language: Azerbaijani (az_AZ)

Training Details

The model was trained for 3 epochs with the following training and validation loss:

Epoch Training Loss Validation Loss
1 0.015100 0.014827
2 0.009800 0.013616
3 0.004100 0.015270

Usage

To use this model, you need to install the transformers library from Hugging Face. You can then load the model and tokenizer and use them to answer questions based on a given context.

Installation

pip install transformers
from transformers import MBartForConditionalGeneration, MBart50Tokenizer

# Load the model and tokenizer
model_name = "LocalDoc/mbart_large_qa_azerbaijan"
tokenizer = MBart50Tokenizer.from_pretrained(model_name, src_lang="en_XX", tgt_lang="az_AZ")
model = MBartForConditionalGeneration.from_pretrained(model_name)

def answer_question(context, question):
    # Prepare input text
    input_text = f"context: {context} question: {question}"
    inputs = tokenizer(input_text, return_tensors="pt", max_length=512, truncation=True, padding="max_length")
    
    # Generate answer
    outputs = model.generate(
        input_ids=inputs["input_ids"],
        attention_mask=inputs["attention_mask"],
        max_length=128,
        num_beams=5,
        early_stopping=True
    )
    
    # Decode the answer
    answer = tokenizer.decode(outputs[0], skip_special_tokens=True)
    return answer

# Example usage
context = """Ey iman gətirənlər! Səbir edərək və namaz qılaraq Allahdan kömək istəyin! Şübhəsiz ki, Allah səbir edənlərlədir.
Ey iman gətirənlər, əgər yalnız Allaha ibadət edirsinizsə, sizə verdiyimiz ruzilərin təmiz olanlarından yeyin və Ona şükür edin!
Ey iman gətirənlər! Oruc tutmaq sizdən əvvəlkilərə fərz buyurulduğu kimi sizə də fərz buyuruldu ki, bəlkə, günahlardan çəkinəsiniz!
Ey iman gətirənlər, bütövlüklə İslama daxil olun! Şeytanın addımlarını izləməyin! Şübhəsiz ki, o sizin açıq-aydın düşməninizdir.
Ey iman gətirənlər! Həqiqətən, içki, qumar, bütlər və fal oxları şeytan əməli olan murdar şeylərdir. Bunlardan uzaq durun ki, bəlkə nicat tapasınız!
Ey iman gətirənlər! “Allah yolunda döyüşə çıxın!” - deyildiyi zaman sizə nə oldu ki, yerə yapışıb qaldınız. Axirətin əvəzinə dünya həyatına razı oldunuz?
Dünya malı axirət nemətlərinin yanında çox az bir şeydir.
Həqiqətən, insan çox zalım və çox nankordur."""

question = "Allah kiminlədir ?"

answer = answer_question(context, question)
print(answer)

License

This model licensed under the CC BY-NC-ND 4.0 license. What does this license allow?

Attribution: You must give appropriate credit, provide a link to the license, and indicate if changes were made.
Non-Commercial: You may not use the material for commercial purposes.
No Derivatives: If you remix, transform, or build upon the material, you may not distribute the modified material.

For more information, please refer to the CC BY-NC-ND 4.0 license.

Citation

@misc {localdoc_2024,
    author       = { {LocalDoc} },
    title        = { mbart_large_qa_azerbaijan (Revision 7484a07) },
    year         = 2024,
    url          = { https://huggingface.co/LocalDoc/mbart_large_qa_azerbaijan },
    doi          = { 10.57967/hf/2541 },
    publisher    = { Hugging Face }
}

Contact

For more information, questions, or issues, please contact LocalDoc at [v.resad.89@gmail.com].

Downloads last month
23
Safetensors
Model size
611M params
Tensor type
F32
·
Inference API
This model can be loaded on Inference API (serverless).

Dataset used to train LocalDoc/mbart_large_qa_azerbaijan