Instructions to use asif00/mistral-bangla with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use asif00/mistral-bangla with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("question-answering", model="asif00/mistral-bangla")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("asif00/mistral-bangla", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Unsloth Studio
How to use asif00/mistral-bangla with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
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/mistral-bangla to start chatting
Install Unsloth Studio (Windows)
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/mistral-bangla to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for asif00/mistral-bangla to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="asif00/mistral-bangla", max_seq_length=2048, )
Update README.md
Browse files
README.md
CHANGED
|
@@ -12,4 +12,65 @@ base_model: unsloth/mistral-7b-v0.3-bnb-4bit
|
|
| 12 |
pipeline_tag: question-answering
|
| 13 |
---
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
Work in progress...
|
|
|
|
| 12 |
pipeline_tag: question-answering
|
| 13 |
---
|
| 14 |
|
| 15 |
+
# How to Use:
|
| 16 |
+
|
| 17 |
+
You can use the model with a pipeline for a high-level helper or load the model directly. Here's how:
|
| 18 |
+
|
| 19 |
+
```python
|
| 20 |
+
# Use a pipeline as a high-level helper
|
| 21 |
+
from transformers import pipeline
|
| 22 |
+
pipe = pipeline("question-answering", model="asif00/mistral-bangla")
|
| 23 |
+
```
|
| 24 |
+
|
| 25 |
+
```python
|
| 26 |
+
# Load model directly
|
| 27 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 28 |
+
tokenizer = AutoTokenizer.from_pretrained("asif00/mistral-bangla")
|
| 29 |
+
model = AutoModelForCausalLM.from_pretrained("asif00/mistral-bangla")
|
| 30 |
+
```
|
| 31 |
+
|
| 32 |
+
# General Prompt Structure:
|
| 33 |
+
|
| 34 |
+
```python
|
| 35 |
+
prompt = """Below is an instruction in Bengali language that describes a task, paired with an input also in Bengali language that provides further context. Write a response in Bengali language that appropriately completes the request.
|
| 36 |
+
|
| 37 |
+
### Instruction:
|
| 38 |
+
{}
|
| 39 |
+
|
| 40 |
+
### Input:
|
| 41 |
+
{}
|
| 42 |
+
|
| 43 |
+
### Response:
|
| 44 |
+
{}
|
| 45 |
+
"""
|
| 46 |
+
```
|
| 47 |
+
|
| 48 |
+
# To get a cleaned up version of the response, you can use the `generate_response` function:
|
| 49 |
+
|
| 50 |
+
```python
|
| 51 |
+
def generate_response(question, context):
|
| 52 |
+
inputs = tokenizer([prompt.format(question, context, "")], return_tensors="pt").to("cuda")
|
| 53 |
+
outputs = model.generate(**inputs, max_new_tokens=1024, use_cache=True)
|
| 54 |
+
responses = tokenizer.batch_decode(outputs, skip_special_tokens=True)[0]
|
| 55 |
+
response_start = responses.find("### Response:") + len("### Response:")
|
| 56 |
+
response = responses[response_start:].strip()
|
| 57 |
+
return response
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
# Example Usage:
|
| 61 |
+
|
| 62 |
+
```python
|
| 63 |
+
question = "ভারতীয় বাঙালি কথাসাহিত্যিক মহাশ্বেতা দেবীর মৃত্যু কবে হয় ?"
|
| 64 |
+
context = "২০১৬ সালের ২৩ জুলাই হৃদরোগে আক্রান্ত হয়ে মহাশ্বেতা দেবী কলকাতার বেল ভিউ ক্লিনিকে ভর্তি হন। সেই বছরই ২৮ জুলাই একাধিক অঙ্গ বিকল হয়ে তাঁর মৃত্যু ঘটে। তিনি মধুমেহ, সেপ্টিসেমিয়া ও মূত্র সংক্রমণ রোগেও ভুগছিলেন।"
|
| 65 |
+
answer = generate_response(question, context)
|
| 66 |
+
print(answer)
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
# Disclaimer:
|
| 71 |
+
|
| 72 |
+
The Bangla LLaMA-4bit model has been trained on a limited dataset, and its responses may not always be perfect or accurate. The model's performance is dependent on the quality and quantity of the data it has been trained on. Given more resources, such as high-quality data and longer training time, the model's performance can be significantly improved.
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
# Resources:
|
| 76 |
Work in progress...
|