Jayveersinh-Raj commited on
Commit
b5a7cfb
1 Parent(s): b056387

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +28 -1
README.md CHANGED
@@ -3,4 +3,31 @@ library_name: peft
3
  base_model: autopilot-ai/Indic-sentence-completion
4
  ---
5
 
6
- Low Rank Adapter for Bloom decoder for grammar correction.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  base_model: autopilot-ai/Indic-sentence-completion
4
  ---
5
 
6
+ Low Rank Adapter for Bloom decoder for grammar correction.
7
+
8
+ # Example Usage:
9
+ import torch
10
+ from peft import PeftModel, PeftConfig
11
+ from transformers import AutoModelForCausalLM, AutoTokenizer
12
+ from IPython.display import display, Markdown
13
+
14
+ peft_model_id = "Jayveersinh-Raj/bloom-sentence-correction"
15
+ config = PeftConfig.from_pretrained(peft_model_id)
16
+ model = AutoModelForCausalLM.from_pretrained(config.base_model_name_or_path, return_dict=True, load_in_8bit=False, device_map='auto')
17
+ tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path)
18
+
19
+ # Load the Lora model
20
+ qa_model = PeftModel.from_pretrained(model, peft_model_id)
21
+
22
+
23
+
24
+ def make_inference(question):
25
+ batch = tokenizer(f"### INCORRECT\n{question}\n\n### CORRECT\n", return_tensors='pt').to("cuda")
26
+
27
+ with torch.cuda.amp.autocast():
28
+ output_tokens = qa_model.generate(**batch, max_new_tokens=200)
29
+
30
+ display(Markdown((tokenizer.decode(output_tokens[0], skip_special_tokens=True))))
31
+
32
+ text = "I red a book last night"
33
+ make_inference(text)