VOOZH about

URL: https://huggingface.co/asif00/bangla-llama-1B-4bit

⇱ asif00/bangla-llama-1B-4bit · Hugging Face


Bangla LLaMA 1B-4bit

Bangla LLaMA 1B-4bit is a 1-billion-parameter language model optimized for Bengali-language tasks such as context-based question answering and retrieval-augmented generation. It is derived from LLaMA 3.2 1B and trained on the OdiaGenAI/all_combined_bengali_252k dataset using 4-bit quantization for efficient performance.

Features

  • Model Size: 1B parameters
  • Format: 4-bit Quantized
  • Language: Bengali
  • Use Cases:
    • Context-based Question Answering
    • Bengali Retrieval-Augmented Generation
  • Integration: Compatible with Hugging Face transformers and optimized for efficient inference

Usage

1. Installation

Ensure you have the necessary libraries installed:

pip install transformers bitsandbytes accelerate

2. Loading the Model with Transformers

from transformers import AutoTokenizer, AutoModelForCausalLM
import torch

# Load the tokenizer and model with 4-bit quantization
tokenizer = AutoTokenizer.from_pretrained("asif00/bangla-llama-1B-4bit")
model = AutoModelForCausalLM.from_pretrained(
 "asif00/bangla-llama-1B-4bit",
 load_in_4bit=True,
 device_map="auto",
 quantization_config={"bits": 4}
)

# Define the prompt structure
prompt_template = """
নিচের নির্দেশনা বাংলা ভাষায় যা একটি কাজ বর্ণনা করে, এবং ইনপুটও বাংলা ভাষায় যা অতিরিক্ত প্রসঙ্গ প্রদান করে। উপযুক্তভাবে অনুরোধ পূরণ করে বাংলা ভাষায় একটি প্রতিক্রিয়া লিখুন।

### নির্দেশনা:
{}

### ইনপুট:
{}

### প্রতিক্রিয়া:
"""

def generate_response(instruction, context):
 prompt = prompt_template.format(instruction, context)
 inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
 output = model.generate(
 **inputs,
 max_length=512,
 do_sample=True,
 temperature=0.7,
 top_p=0.9,
 eos_token_id=tokenizer.eos_token_id
 )
 response = tokenizer.decode(output[0], skip_special_tokens=True)
 response = response.split("### প্রতিক্রিয়া:")[-1].strip()
 return response

# Example Usage
if __name__ == "__main__":
 instruction = "ভারতীয় বাঙালি কথাসাহিত্যিক মহাশ্বেতা দেবীর সম্পর্কে একটি সংক্ষিপ্ত বিবরণ দিন।"
 context = "মহাশ্বেতা দেবী ২০১৬ সালে হৃদরোগে আক্রান্ত হয়ে কলকাতায় মৃত্যুবরণ করেন।"
 answer = generate_response(instruction, context)
 print("উত্তর:", answer)

3. Example

instruction = "ভারতীয় বাঙালি কথাসাহিত্যিক মহাশ্বেতা দেবীর মৃত্যু কবে হয়?"
context = (
 "২০১৬ সালের ২৩ জুলাই হৃদরোগে আক্রান্ত হয়ে মহাশ্বেতা দেবী কলকাতার বেল ভিউ ক্লিনিকে ভর্তি হন। "
 "সেই বছরই ২৮ জুলাই একাধিক অঙ্গ বিকল হয়ে তাঁর মৃত্যু ঘটে। তিনি মধুমেহ, সেপ্টিসেমিয়া ও মূত্র সংক্রমণ রোগেও ভুগছিলেন।"
)
answer = generate_response(instruction, context)
print("উত্তর:", answer)

Output:

উত্তর: মহাশ্বেতা দেবী ২৮ জুলাই ২০১৬ সালে মৃত্যুবরণ করেন।

Limitations

  • Dataset Size: Trained on a limited dataset, which may affect response accuracy.
  • Factuality: May generate incorrect or nonsensical answers.
  • Language Support: Primarily optimized for Bengali; performance may vary for other languages.

Disclaimer

The Bangla LLaMA 1B-4bit model's performance depends on the quality and diversity of the training data. Users should verify the information generated, especially for critical applications.

Additional Resources

Downloads last month

-

Downloads are not tracked for this model. How to track

Dataset used to train asif00/bangla-llama-1B-4bit