File size: 1,341 Bytes
fbc68f7
 
8570f4f
58bcdce
33c4b56
80217c4
58bcdce
 
fbc68f7
58bcdce
81cb633
fbc68f7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
233673b
fbc68f7
 
 
 
 
 
81cb633
8570f4f
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
---
license: mit
language:
  - bn
pipeline_tag: table-question-answering
library_name: transformer unsloth
base_model: Bikas0/Bengali-Question-Answer-Llama3

---

```bash
from transformers import TextStreamer
from unsloth import FastLanguageModel
import torch
alpaca_prompt = """
### Instruction:
{}

### Input:
{}

### Response:
{}"""
model, tokenizer = FastLanguageModel.from_pretrained(
    model_name = "Bikas0/Bengali-Question-Answer-Llama3", # YOUR MODEL YOU USED FOR TRAINING
    max_seq_length = 2048,
    dtype = torch.float16,
    load_in_4bit = True,
)
FastLanguageModel.for_inference(model) # Enable native 2x faster inference
inputs = tokenizer(
[
    alpaca_prompt.format(
        "Please provide a detailed answer to the following question", # instruction
        "বাংলা একাডেমি আইন কোন কারণে সদস্যপদ বাতিল করা হবে ?", # input
        # সড়ক রক্ষণাবেক্ষণ তহবিল বোর্ড আইন, ২০১৩ অনুযায়ী, তহবিলের উৎসসমূহ কী কী?
        "", # output - leave this blank for generation!
    )
], return_tensors = "pt").to("cuda")

text_streamer = TextStreamer(tokenizer)
_ = model.generate(**inputs, streamer = text_streamer, max_new_tokens = 2048)

```