Edit model card

Gemma-2 Bangla LoRA

  • Developed by: KillerShoaib
  • License: apache-2.0
  • Finetuned from model : unsloth/gemma-2-9b-it-bnb-4bit
  • Datset used for fine-tuning : iamshnoo/alpaca-cleaned-bengali

LoRA Adapter

This is not the entire model, but rather only the LoRA adapter.

Gemma-2 Bangla Different Formats

Model Details

Gemma 2 9 billion model was finetuned using unsloth package on a cleaned Bangla alpaca dataset. The model was finetune using LoRA finetuning technique. The model is finetuned for 1 epoch on a single T4 GPU.

Pros & Cons of the Model

Pros

  • The model can comprehend the Bangla language, including its semantic nuances
  • Given context model can answer the question based on the context

Cons

  • Model is unable to do creative or complex work. i.e: creating a poem or solving a math problem in Bangla
  • Since the size of the dataset was small, the model lacks lot of general knowledge in Bangla

Llama 3 8b Bangla Vs Gemma 2 9b Bangla

  • Overall both performace were similar, the pros and cons both were same, both the model struggle with longer context query and reasoning, but able to answer question if the context is given

Some Examples from the model:

  • Example 1:

    Question: স্সুস্থ থাকার তিনটি উপায় বলুন
    Model Generated Answer: ১. স্বাস্থ্যকর খাদ্য গ্রহণ করুনঃ ফল, সবজি, পূর্ণ শস্য, চর্বিযুক্ত প্রোটিন এবং স্বাস্থ্যকর ফ্যাট সমৃদ্ধ একটি ভারসাম্যপূর্ণ খাদ্য গ্রহণ করা স্বাস্থ্যকর থাকার একটি গুরুত্বপূর্ণ উপায়। এটি আপনার শরীরকে প্রয়োজনীয় পুষ্টি সরবরাহ করে এবং আপনাকে সুস্থ থাকতে সহায়তা করে। ২. নিয়মিত ব্যায়াম করুনঃ নিয়মিত শারীরিক ক্রিয়াকলাপ আপনার সামগ্রিক স্বাস্থ্যের উন্নতি করতে পারে, আপনার হৃদরোগের স্বাস্থ্য উন্নত করতে পারে, আপনার মানসিক স্বাস্থ্য উন্নত করতে পারে এবং আপনাকে সুস্থ থাকতে সহায়তা করতে পারে। ৩. পর্যাপ্ত ঘুম পানঃ পর্যাপ্ত ঘুম আপনার শরীরকে পুনরুদ্ধার করতে এবং আপনার সামগ্রিক স্বাস্থ্যের উন্নতি করতে সহায়তা করে। প্রতি রাতে ৭-৮ ঘন্টা ঘুম পাওয়া সুস্থ থাকার জন্য গুরুত্বপূর্ণ
    
  • Example 2:

    Question: নিচের আলোচনা দেখে বাংলাদেশের রাজধানীর নাম বের করো।
    Context: বাংলাদেশের রাজধানী ঢাকায় তার নামে একটি এলাকার নামকরন করা হয়েছে শেরেবাংলা নগর (পূর্ববর্তী আইয়ুবনগর ও তারও পূর্বে মনিপুর) ,২০১৪ বাংলাদেশ স্থানীয় সময় শুক্রবার বেলা তিনটায় রাজধানীর ইউনাইটেড হাসপাতালে চিকিৎসাধীন অবস্থায় মারা যান বেবী মওদুদ। মৃত্যুর সময় তার বয়স হয়েছিল ৬৬ বছর।বাংলাদেশ জাতীয় জাদুঘর বাংলাদেশের রাজধানী ঢাকা শহরে অবস্থিত দেশের প্রধান জাদুঘর। এটি ২০, মার্চ, ১৯১৩ খ্রিস্টাব্দে প্রতিষ্ঠিত হয়, এবং ৭ আগস্ট।
    Model Generated Answer: বাংলাদেশের রাজধানী ঢাকা।
    
  • Example 3:

    Question: বিশ্বের সবচেয়ে বিখ্যাত চিত্রশিল্পী কে?
    Model Generated Answer: বিশ্বের সবচেয়ে বিখ্যাত চিত্রশিল্পী হিসেবে লেওনার্দো দা ভিঞ্চি সবচেয়ে বেশি পরিচিত। তিনি রেনেসাঁ যুগের একজন বিশিষ্ট চিত্রশিল্পী, উদ্ভাবক, বিজ্ঞানী এবং প্রকৌশলী ছিলেন। তাঁর সবচেয়ে বিখ্যাত কাজগুলির মধ্যে মোনালিসা এবং দ্য লাস্ট সাপার অন্তর্ভুক্ত রয়েছে।
    

Run The Model

Download the right dependency for Unsloth

Google Colab

%%capture
# Installs Unsloth, Xformers (Flash Attention) and all other packages!
!pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"

# We have to check which Torch version for Xformers (2.3 -> 0.0.27)
from torch import __version__; from packaging.version import Version as V
xformers = "xformers==0.0.27" if V(__version__) < V("2.4.0") else "xformers"
!pip install --no-deps {xformers} trl peft accelerate bitsandbytes triton

FastLanguageModel from unsloth for 2x faster inference


from unsloth import FastLanguageModel
model, tokenizer = FastLanguageModel.from_pretrained(
    model_name = "KillerShoaib/gemma-2-9b-bangla-lora", # or  KillerShoaib/gemma-2-9b-bangla-4bit / KillerShoaib/gemma-2-9b-bangla-16bit
    max_seq_length = 2048,
    dtype = None,
    load_in_4bit = True,
)
FastLanguageModel.for_inference(model)

# alpaca_prompt for the model
alpaca_prompt = """Below is an instruction in bangla that describes a task, paired with an input also in bangla that provides further context. Write a response in bangla that appropriately completes the request.

### Instruction:
{}

### Input:
{}

### Response:
{}"""

# input with instruction and input
inputs = tokenizer(
[
    alpaca_prompt.format(
        "সুস্থ থাকার তিনটি উপায় বলুন", # instruction
        "", # input
        "", # output - leave this blank for generation!
    )
], return_tensors = "pt").to("cuda")

# generating the output and decoding it
outputs = model.generate(**inputs, max_new_tokens = 2048, use_cache = True)
tokenizer.batch_decode(outputs)

AutoModelForPeftCausalLM from Hugginface

from peft import AutoPeftModelForCausalLM
from transformers import AutoTokenizer

model = AutoPeftModelForCausalLM.from_pretrained(
    "KillerShoaib/gemma-2-9b-bangla-lora",
    load_in_4bit = True,
)
tokenizer = AutoTokenizer.from_pretrained("KillerShoaib/gemma-2-9b-bangla-lora")

alpaca_prompt = """Below is an instruction in bangla that describes a task, paired with an input also in bangla that provides further context. Write a response in bangla that appropriately completes the request.

### Instruction:
{}

### Input:
{}

### Response:
{}"""

inputs = tokenizer(
[
    alpaca_prompt.format(
        "নিচের আলোচনা দেখে বাংলাদেশের রাজধানীর নাম বের করো।", # instruction
        "বাংলাদেশের রাজধানী ঢাকায় তার নামে একটি এলাকার নামকরন করা হয়েছে শেরেবাংলা নগর (পূর্ববর্তী আইয়ুবনগর ও তারও পূর্বে মনিপুর) ,২০১৪ বাংলাদেশ স্থানীয় সময় শুক্রবার বেলা তিনটায় রাজধানীর ইউনাইটেড হাসপাতালে চিকিৎসাধীন অবস্থায় মারা যান বেবী মওদুদ। মৃত্যুর সময় তার বয়স হয়েছিল ৬৬ বছর।বাংলাদেশ জাতীয় জাদুঘর বাংলাদেশের রাজধানী ঢাকা শহরে অবস্থিত দেশের প্রধান জাদুঘর। এটি ২০, মার্চ, ১৯১৩ খ্রিস্টাব্দে প্রতিষ্ঠিত হয়, এবং ৭ আগস্ট।", # input
        "", # output - leave this blank for generation!
    )
], return_tensors = "pt").to("cuda")

outputs = model.generate(**inputs, max_new_tokens = 1024, use_cache = True)
tokenizer.batch_decode(outputs)

Inference Script & Github Repo

‼️ Github Repo shows how to finetune any unsloth model using incremental training. For Gemma 2 9b model finetuning I've used the exact same logic that was used for Llama 3 8b model. Remember to change the dependency based on the Unsloth notebook example. ‼️

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference API
Inference API (serverless) has been turned off for this model.

Model tree for KillerShoaib/gemma-2-9b-bangla-lora

Finetuned
(86)
this model