Downloads · 30 days
12
3% of all-time downloads
KillerShoaib/gemma-2-9b-bangla-4bit
gemma-2-9b-bangla-4bit is a text generation model from KillerShoaib. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as apache-2.0.
<div align="center" <img src="https://cdn-uploads.huggingface.co/production/uploads/65ca6f0098a46a56261ac3ac/k4MH-skEIgSzHXyAxtXv.jpeg" width="300"/
Downloads · 30 days
12
3% of all-time downloads
All-time downloads
377
Public
Repo size
12.3 GB
Likes
1
Public
Click a slice to open those files.
.bin6.1 GB · 100%
From the Hugging Face model README
This is 4-bit quantization of Gemma-2 9b model.
LoRA Adapters only - KillerShoaib/gemma-2-9b-bangla-lora16-bit model - KillerShoaib/gemma-2-9b-bangla-16bitGemma 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.
Example 1:
Question: স্সুস্থ থাকার তিনটি উপায় বলুন
Model Generated Answer: ১. স্বাস্থ্যকর খাদ্য গ্রহণ করুনঃ ফল, সবজি, পূর্ণ শস্য, চর্বিযুক্ত প্রোটিন এবং স্বাস্থ্যকর ফ্যাট সমৃদ্ধ একটি ভারসাম্যপূর্ণ খাদ্য গ্রহণ করা স্বাস্থ্যকর থাকার একটি গুরুত্বপূর্ণ উপায়। এটি আপনার শরীরকে প্রয়োজনীয় পুষ্টি সরবরাহ করে এবং আপনাকে সুস্থ থাকতে সহায়তা করে। ২. নিয়মিত ব্যায়াম করুনঃ নিয়মিত শারীরিক ক্রিয়াকলাপ আপনার সামগ্রিক স্বাস্থ্যের উন্নতি করতে পারে, আপনার হৃদরোগের স্বাস্থ্য উন্নত করতে পারে, আপনার মানসিক স্বাস্থ্য উন্নত করতে পারে এবং আপনাকে সুস্থ থাকতে সহায়তা করতে পারে। ৩. পর্যাপ্ত ঘুম পানঃ পর্যাপ্ত ঘুম আপনার শরীরকে পুনরুদ্ধার করতে এবং আপনার সামগ্রিক স্বাস্থ্যের উন্নতি করতে সহায়তা করে। প্রতি রাতে ৭-৮ ঘন্টা ঘুম পাওয়া সুস্থ থাকার জন্য গুরুত্বপূর্ণ
Example 2:
Question: নিচের আলোচনা দেখে বাংলাদেশের রাজধানীর নাম বের করো।
Context: বাংলাদেশের রাজধানী ঢাকায় তার নামে একটি এলাকার নামকরন করা হয়েছে শেরেবাংলা নগর (পূর্ববর্তী আইয়ুবনগর ও তারও পূর্বে মনিপুর) ,২০১৪ বাংলাদেশ স্থানীয় সময় শুক্রবার বেলা তিনটায় রাজধানীর ইউনাইটেড হাসপাতালে চিকিৎসাধীন অবস্থায় মারা যান বেবী মওদুদ। মৃত্যুর সময় তার বয়স হয়েছিল ৬৬ বছর।বাংলাদেশ জাতীয় জাদুঘর বাংলাদেশের রাজধানী ঢাকা শহরে অবস্থিত দেশের প্রধান জাদুঘর। এটি ২০, মার্চ, ১৯১৩ খ্রিস্টাব্দে প্রতিষ্ঠিত হয়, এবং ৭ আগস্ট।
Model Generated Answer: বাংলাদেশের রাজধানী ঢাকা।
Example 3:
Question: বিশ্বের সবচেয়ে বিখ্যাত চিত্রশিল্পী কে?
Model Generated Answer: বিশ্বের সবচেয়ে বিখ্যাত চিত্রশিল্পী হিসেবে লেওনার্দো দা ভিঞ্চি সবচেয়ে বেশি পরিচিত। তিনি রেনেসাঁ যুগের একজন বিশিষ্ট চিত্রশিল্পী, উদ্ভাবক, বিজ্ঞানী এবং প্রকৌশলী ছিলেন। তাঁর সবচেয়ে বিখ্যাত কাজগুলির মধ্যে মোনালিসা এবং দ্য লাস্ট সাপার অন্তর্ভুক্ত রয়েছে।
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
from unsloth import FastLanguageModel
model, tokenizer = FastLanguageModel.from_pretrained(
model_name = "KillerShoaib/gemma-2-9b-bangla-4bit", # 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)
from transformers import AutoTokenizer, AutoModelForCausalLM
model_name = "KillerShoaib/gemma-2-9b-bangla-4bit" # or KillerShoaib/gemma-2-9b-bangla-16bit
tokenizer_name = model_name
# Load tokenizer
tokenizer = AutoTokenizer.from_pretrained(tokenizer_name)
# Load model
model = AutoModelForCausalLM.from_pretrained(model_name)
# Text prompt to start generation
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:
{}"""
# Encode the prompt text
inputs = tokenizer(
[
alpaca_prompt.format(
"বিশ্বের সবচেয়ে বিখ্যাত চিত্রশিল্পী কে?", # instruction
"", # input
"", # output - leave this blank for generation!
)
], return_tensors = "pt").to("cuda")
# output
outputs = model.generate(**inputs, max_new_tokens = 1024, use_cache = True)
tokenizer.batch_decode(outputs)
Google Colab - Gemma-2 9b Bangla Inference ScriptGithub Repo - Llama-3 Bangla‼️ 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. ‼️