Views
No views yet

LoRA Adapters only - KillerShoaib/llama-3-8b-bangla-loraGGUF q4_k_m - KillerShoaib/llama-3-8b-bangla-GGUF-Q4_K_M1
2from unsloth import FastLanguageModel
3model, tokenizer = FastLanguageModel.from_pretrained(
4 model_name = "KillerShoaib/llama-3-8b-bangla-4bit",
5 max_seq_length = 2048,
6 dtype = None,
7 load_in_4bit = True,
8)
9FastLanguageModel.for_inference(model)
10
11# alpaca_prompt for the model
12alpaca_prompt = """Below is an instruction in bangla that describes a task, paired with an input also in bangla that provides further context. Write a response in bangla that appropriately completes the request.
13
14### Instruction:
15{}
16
17### Input:
18{}
19
20### Response:
21{}"""
22
23# input with instruction and input
24inputs = tokenizer(
25[
26 alpaca_prompt.format(
27 "সুস্থ থাকার তিনটি উপায় বলুন", # instruction
28 "", # input
29 "", # output - leave this blank for generation!
30 )
31], return_tensors = "pt").to("cuda")
32
33# generating the output and decoding it
34outputs = model.generate(**inputs, max_new_tokens = 2048, use_cache = True)
35tokenizer.batch_decode(outputs)1from transformers import AutoTokenizer, AutoModelForCausalLM
2
3model_name = "KillerShoaib/llama-3-8b-bangla-4bit" # YOUR MODEL YOU USED FOR TRAINING either hf hub name or local folder name.
4tokenizer_name = model_name
5
6# Load tokenizer
7tokenizer = AutoTokenizer.from_pretrained(tokenizer_name)
8# Load model
9model = AutoModelForCausalLM.from_pretrained(model_name)
10
11alpaca_prompt = """Below is an instruction in bangla that describes a task, paired with an input also in bangla that provides further context. Write a response in bangla that appropriately completes the request.
12
13### Instruction:
14{}
15
16### Input:
17{}
18
19### Response:
20{}"""
21
22inputs = tokenizer(
23[
24 alpaca_prompt.format(
25 "সুস্থ থাকার তিনটি উপায় বলুন", # instruction
26 "", # input
27 "", # output - leave this blank for generation!
28 )
29], return_tensors = "pt").to("cuda")
30
31outputs = model.generate(**inputs, max_new_tokens = 1024, use_cache = True)
32tokenizer.batch_decode(outputs)Google Colab - Llama-3 8b Bangla Inference ScriptGithub Repo - Llama-3 Bangla