Views
No views yet
| Parameter | Value |
|---|---|
| Batch size | 128 |
| Learning rate | 3e-4 |
| Epochs | 3 |
| Cutoff length | 256 |
| Weight_decay | 0.001 |
| Warmup_rate | 0.1 |
| LR_scheduler | linear |
| Lora r | 16 |
| Lora target modules | (q_proj, k_proj, v_proj, o_proj) |
1import torch
2from peft import PeftModel
3import transformers
4from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
5from peft import PeftModel, PeftConfig
6from transformers import LlamaTokenizer, LlamaForCausalLM, GenerationConfig
7
8base_model_path = "meta-llama/Llama-2-7b-hf"
9adapter_path = "OdiaGenAI/odiagenAI-model-v1"
10
11tokenizer = AutoTokenizer.from_pretrained(base_model_path, trust_remote_code=True)
12tokenizer.pad_token = tokenizer.eos_token
13
14bnb_config = BitsAndBytesConfig(
15 load_in_4bit=True,
16 bnb_4bit_quant_type="nf4",
17 bnb_4bit_use_double_quant=True,
18 bnb_4bit_compute_dtype=torch.float16,
19)
20
21base_model = AutoModelForCausalLM.from_pretrained(
22 base_model_path,
23 quantization_config=bnb_config,
24 device_map="auto",
25 trust_remote_code=True
26)
27
28model = PeftModel.from_pretrained(base_model, adapter_path)
29
30instruction = "ଭାରତ ବିଷୟରେ କିଛି କୁହନ୍ତୁ"
31
32device = "cuda" if torch.cuda.is_available() else "cpu"
33
34inputs = tokenizer(instruction, return_tensors="pt").to(device)
35input_ids = inputs["input_ids"].to(device)
36generation_config = GenerationConfig(
37 temperature=0.1,
38 top_p=0.75,
39 top_k=40,
40 num_beams=4,
41)
42with torch.no_grad():
43 generation_output = model.generate(
44 input_ids=input_ids,
45 generation_config=generation_config,
46 return_dict_in_generate=True,
47 output_scores=True,
48 max_new_tokens=128,
49 )
50s = generation_output.sequences[0]
51output = tokenizer.decode(s)
52print(output)
53@misc{OdiaGenAI,
author = {Shantipriya Parida and Sambit Sekhar and Subhadarshi Panda and Soumendra Kumar Sahoo and Swateek Jena and Abhijeet Parida and Arghyadeep Sen and Satya Ranjan Dash and Deepak Kumar Pradhan},
title = {OdiaGenAI: Generative AI and LLM Initiative for the Odia Language},
year = {2023},
publisher = {Hugging Face},
journal = {Hugging Face repository},
howpublished = {\url{https://huggingface.co/OdiaGenAI}},
}