shujatoor commited on
Commit
0968137
·
verified ·
1 Parent(s): d6347ad

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +52 -2
README.md CHANGED
@@ -22,10 +22,60 @@ This model is a fine-tuned version of [microsoft/Phi-3-mini-4k-instruct](https:/
22
  It achieves the following results on the evaluation set:
23
  - Loss: 0.6568
24
 
25
- ## Model description
26
 
27
- More information needed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
 
29
  ## Intended uses & limitations
30
 
31
  More information needed
 
22
  It achieves the following results on the evaluation set:
23
  - Loss: 0.6568
24
 
25
+ ## For Inference
26
 
27
+ from peft import PeftModel, PeftConfig
28
+ from transformers import AutoModelForCausalLM
29
+ import torch
30
+ from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
31
+
32
+ config = PeftConfig.from_pretrained("shujatoor/phi3nedtuned-ner")
33
+ model = AutoModelForCausalLM.from_pretrained(
34
+ "microsoft/Phi-3-mini-4k-instruct",
35
+ #device_map="cuda",
36
+ #torch_dtype="auto",
37
+ trust_remote_code=True,
38
+ )
39
+ model = PeftModel.from_pretrained(model, "shujatoor/phi3nedtuned-ner")
40
+ model.config.to_json_file('adapter_config.json')
41
+
42
+
43
+ torch.random.manual_seed(0)
44
+ tokenizer = AutoTokenizer.from_pretrained("shujatoor/phi3nedtuned-ner")
45
+
46
+
47
+ text = "Hasan Pharmacy Madina Market Mustafa Chowk.PCsiR Staff Society College Road, Lahore Drug Lic#441-A/AIT No.1023874 24/04/202422:18:03 M/s*CASH SALES-WALKING CUST Remarks: Ref.: Item Name Qty Price Total Advant Tab 16mg 28 37.50 1050.00 Kepra 500mg Tab 30 85.91 2577.30 Kabrokin 200mg 240 10.67 2560.80 Tab Myteka 10mg Tab 14 37.71 527.94 Cipocain Ear/drops 1 168.00 168.00 Medicam T/paste 1 240.00 240.00 100gm Total items:6 Gross Total : 7,124.04 Disc: 523.68 DR.HASAN Net Total. 6,600.00 (Computer Software developed by Abuzar Consultancy Ph 042-37426911-15)."
48
+ qs = f'{text} What is the drug license number of the store??'
49
+ print('Question:',qs, '\n')
50
+ messages = [
51
+ #{"role": "system", "content": "Only output the answer, nothing else"},
52
+ {"role": "user", "content": qs},
53
+
54
+ ]
55
+
56
+ pipe = pipeline(
57
+ "text-generation",
58
+ model=model,
59
+ tokenizer=tokenizer,
60
+ )
61
+
62
+ generation_args = {
63
+ "max_new_tokens": 512,
64
+ "return_full_text": False,
65
+ #"temperature": 0.0,
66
+ "do_sample": False,
67
+ }
68
+
69
+ output = pipe(messages, **generation_args)
70
+
71
+ print('Answer:', output[0]['generated_text'], '\n')
72
+
73
+ """
74
+ expected answer:
75
+
76
+ Answer: 441-A/AIT No.1023874
77
 
78
+ """
79
  ## Intended uses & limitations
80
 
81
  More information needed