OdiaGenAI/all_combined_bengali_252k
Viewer • Updated • 253k • 52 • 10
How to use asif00/bangla-llama-1B-4bit with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("question-answering", model="asif00/bangla-llama-1B-4bit") # Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("asif00/bangla-llama-1B-4bit", dtype="auto")How to use asif00/bangla-llama-1B-4bit with Unsloth Studio:
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for asif00/bangla-llama-1B-4bit to start chatting
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for asif00/bangla-llama-1B-4bit to start chatting
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for asif00/bangla-llama-1B-4bit to start chatting
pip install unsloth
from unsloth import FastModel
model, tokenizer = FastModel.from_pretrained(
model_name="asif00/bangla-llama-1B-4bit",
max_seq_length=2048,
)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.
transformers and optimized for efficient inferenceEnsure you have the necessary libraries installed:
pip install transformers bitsandbytes accelerate
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)
instruction = "ভারতীয় বাঙালি কথাসাহিত্যিক মহাশ্বেতা দেবীর মৃত্যু কবে হয়?"
context = (
"২০১৬ সালের ২৩ জুলাই হৃদরোগে আক্রান্ত হয়ে মহাশ্বেতা দেবী কলকাতার বেল ভিউ ক্লিনিকে ভর্তি হন। "
"সেই বছরই ২৮ জুলাই একাধিক অঙ্গ বিকল হয়ে তাঁর মৃত্যু ঘটে। তিনি মধুমেহ, সেপ্টিসেমিয়া ও মূত্র সংক্রমণ রোগেও ভুগছিলেন।"
)
answer = generate_response(instruction, context)
print("উত্তর:", answer)
Output:
উত্তর: মহাশ্বেতা দেবী ২৮ জুলাই ২০১৬ সালে মৃত্যুবরণ করেন।
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.