File size: 5,279 Bytes
452f9d6 d6696ae 452f9d6 d6696ae 4142218 72b8554 4142218 72b8554 4142218 72b8554 4142218 72b8554 4142218 72b8554 4142218 72b8554 4142218 72b8554 4142218 72b8554 4142218 72b8554 4142218 72b8554 4142218 72b8554 4142218 72b8554 4142218 72b8554 4142218 72b8554 4142218 72b8554 4142218 72b8554 4142218 72b8554 4142218 72b8554 4142218 72b8554 4142218 72b8554 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
---
language:
- bn
license: apache-2.0
tags:
- text-generation-inference
- transformers
- unsloth
- llama
- trl
datasets:
- OdiaGenAI/all_combined_bengali_252k
pipeline_tag: question-answering
---
# 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](https://huggingface.co/datasets/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:
```bash
pip install transformers bitsandbytes accelerate
```
### 2. Loading the Model with Transformers
```python
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
```python
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
- **Hugging Face Model Page:** [asif00/bangla-llama-1B-4bit](https://huggingface.co/asif00/bangla-llama-1B-4bit)
- **Hugging Face Dataset:** [OdiaGenAI/all_combined_bengali_252k](https://huggingface.co/datasets/OdiaGenAI/all_combined_bengali_252k)
- **Transformers Documentation:** [https://huggingface.co/docs/transformers](https://huggingface.co/docs/transformers)
- **bitsandbytes Repository:** [https://github.com/TimDettmers/bitsandbytes](https://github.com/TimDettmers/bitsandbytes)
|