shyam-incedoinc commited on
Commit
60952ea
·
1 Parent(s): a3f8edc

Create README.md

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