Views
No views yet
!pip install -U xformers --index-url https://download.pytorch.org/whl/cu121
!pip install "unsloth[kaggle-new] @git+https://github.com/unslothai/unsloth.git@nightly"### Instruction: {instruction}
### Input: {input}
## Response: {response}1from unsloth import FastLanguageModel
2import torch
3max_seq_length = 2048
4dtype = None # None for auto detection. Float16 for Tesla T4, V100, Bfloat16 for Ampere+
5load_in_4bit = False
6model, tokenizer = FastLanguageModel.from_pretrained(
7 model_name = "Telugu-LLM-Labs/Indic-gemma-7b-finetuned-sft-Navarasa-2.0",
8 max_seq_length = max_seq_length,
9 dtype = dtype,
10 load_in_4bit = load_in_4bit,
11 device_map="auto"
12)
13FastLanguageModel.for_inference(model) # Enable native 2x faster inference
14
15input_prompt = """
16### Instruction:
17{}
18
19### Input:
20{}
21
22### Response:
23{}"""
24
25input_text = input_prompt.format(
26 "Tranlsate following sentence to Hindi.", # instruction
27 "India is a great country.", # input
28 "", # output - leave this blank for generation!
29 )
30
31inputs = tokenizer([input_text], return_tensors = "pt").to("cuda")
32
33outputs = model.generate(**inputs, max_new_tokens = 300, use_cache = True)
34response = tokenizer.batch_decode(outputs)1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
3
4model = AutoModelForCausalLM.from_pretrained(
5 "Telugu-LLM-Labs/Indic-gemma-7b-finetuned-sft-Navarasa-2.0",
6 load_in_4bit = False,
7 token = hf_token
8)
9model.to("cuda")
10
11tokenizer = AutoTokenizer.from_pretrained("Telugu-LLM-Labs/Indic-gemma-7b-finetuned-sft-Navarasa-2.0")
12
13input_prompt = """
14### Instruction:
15{}
16
17### Input:
18{}
19
20### Response:
21{}"""
22
23input_text = input_prompt.format(
24 "Tranlsate following sentence to Hindi.", # instruction
25 "India is a great country.", # input
26 "", # output - leave this blank for generation!
27 )
28
29inputs = tokenizer([input_text], return_tensors = "pt").to("cuda")
30
31outputs = model.generate(**inputs, max_new_tokens = 300, use_cache = True)
32response = tokenizer.batch_decode(outputs)[0]