shyam-incedoinc commited on
Commit
195c8ae
1 Parent(s): 2828420

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +73 -0
README.md ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This is a fine-tuned model, trained on 400+ test scripts, written in Java using `Cucumber` and `Selenium` frameworks.
2
+ Base model used is `codellama/CodeLlama-7b-hf`. The dataset used can be found at `shyam-incedoinc/qa-finetune-dataset`.
3
+
4
+ Training metrics can be seen in the metrics section.
5
+
6
+ # Training Parameters
7
+ ```
8
+ num_train_epochs=25,
9
+ per_device_train_batch_size=2,
10
+ gradient_accumulation_steps=1,
11
+ gradient_checkpointing=True,
12
+ optim="paged_adamw_32bit",
13
+ #save_steps=save_steps,
14
+ logging_steps=25,
15
+ save_strategy="epoch",
16
+ learning_rate=2e-4,
17
+ weight_decay=0.001,
18
+ fp16=True,
19
+ bf16=False,
20
+ max_grad_norm=0.3,
21
+ warmup_ratio=0.03,
22
+ #max_steps=max_steps,
23
+ group_by_length=False,
24
+ lr_scheduler_type="cosine",
25
+ disable_tqdm=False,
26
+ report_to="tensorboard",
27
+ seed=42
28
+ )
29
+
30
+ LoraConfig(
31
+ lora_alpha=16,
32
+ lora_dropout=0.1,
33
+ r=64,
34
+ bias="none",
35
+ task_type="CAUSAL_LM",
36
+ )
37
+ ```
38
+
39
+ # Run the below code block for getting inferences from this model.
40
+
41
+ ```
42
+ import torch
43
+ from transformers import AutoModelForCausalLM, AutoTokenizer
44
+
45
+ hf_model_repo = "shyam-incedoinc/codellama-7b-hf-peft-qlora-finetuned-qa"
46
+
47
+ # Get the tokenizer
48
+ tokenizer = AutoTokenizer.from_pretrained(hf_model_repo)
49
+
50
+ # Load the model
51
+ model = AutoModelForCausalLM.from_pretrained(hf_model_repo, load_in_4bit=True,
52
+ torch_dtype=torch.float16,
53
+ device_map="auto")
54
+
55
+ # Load dataset from the hub
56
+ hf_data_repo = "shyam-incedoinc/qa-finetune-dataset"
57
+ train_dataset = load_dataset(hf_data_repo, split="train")
58
+ valid_dataset = load_dataset(hf_data_repo, split="validation")
59
+
60
+ # Load the sample
61
+ sample = valid_dataset[randrange(len(valid_dataset))]['text']
62
+ groundtruth = sample.split("### Output:\n")[1]
63
+ prompt = sample.split("### Output:\n")[0]+"### Output:\n"
64
+
65
+ # Generate response
66
+ input_ids = tokenizer(prompt, return_tensors="pt", truncation=True).input_ids.cuda()
67
+ outputs = model.generate(input_ids=input_ids, max_new_tokens=1024,
68
+ do_sample=True, top_p=0.9, temperature=0.6)
69
+
70
+ # Print the result
71
+ print(f"Generated response:\n{tokenizer.batch_decode(outputs.detach().cpu().numpy(), skip_special_tokens=True)[0]}")
72
+ print(f"Ground Truth:\n{groundtruth}")
73
+ ```