Downloads · 30 days
10
5% of all-time downloads
shujatoor/phi3nedtuned-ner-json
phi3nedtuned-ner-json is a machine learning model from shujatoor. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for peft. The card lists the license as mit.
should probably proofread and complete it, then remove this comment. --
Downloads · 30 days
10
5% of all-time downloads
All-time downloads
205
Public
Repo size
50.9 MB
Likes
1
Public
Click a slice to open those files.
.safetensors50.4 MB · 95%
From the Hugging Face model README
This model is a fine-tuned version of microsoft/Phi-3-mini-4k-instruct on the dataset: https://huggingface.co/datasets/shujatoor/ner_instruct-json.
from peft import PeftModel, PeftConfig
from transformers import AutoModelForCausalLM
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
config = PeftConfig.from_pretrained("shujatoor/phi3nedtuned-ner-json")
model = AutoModelForCausalLM.from_pretrained(
"microsoft/Phi-3-mini-4k-instruct",
device_map="cuda",
torch_dtype="auto",
trust_remote_code=True,
)
model = PeftModel.from_pretrained(model, "shujatoor/phi3nedtuned-ner-json")
model.config.to_json_file('adapter_config.json')
torch.random.manual_seed(0)
tokenizer = AutoTokenizer.from_pretrained("shujatoor/phi3nedtuned-ner-json")
text = "Tehzeeb Bakers STRN3277876134234 Block A. Police Foundation,PwD Islamabad 051-5170713-4.051-5170501 STRN#3277876134234 NTN#7261076-2 Sales Receipt 05/04/202405:56:40PM CashierM J Payment:Cash Rate Qty. Total # Descriptlon 80.512.000 190.00 1.VEGETABLESAMOSA Sub Total 161.02 Total Tax: 28.98 POS Service Fee 1.00 Total 191.00 Cash 200.00 Change Due 9.00 SR#th007-220240405175640730 Goods Once Sold Can Not Be Taken Back or Replaced All Prices Are Inclusive Sales Tax 134084240405175640553"
q_json = "extracted_data': {'store_name': '', 'address': '', 'receipt_number': '', 'drug_license_number': '', 'gst_number': '', 'vat_number': '', 'date': '', 'time': '', 'items': [], 'total_items': '', 'gst_tax': '', 'vat_tax': '', 'gross_total': '', 'discount': '', 'net_total': '', 'contact': ''}"
qs = f'{text}. {q_json}'
print('Question:',qs, '\n')
messages = [
#{"role": "system", "content": ""},
{"role": "user", "content": qs},
]
pipe = pipeline(
"text-generation",
model=model,
tokenizer=tokenizer,
)
generation_args = {
"max_new_tokens": 512,
"return_full_text": False,
#"temperature": 0.0,
"do_sample": False,
}
output = pipe(messages, **generation_args)
print('Answer:', output[0]['generated_text'], '\n')
More information needed
Named Entity Recognition (NER)
More information needed
The following hyperparameters were used during training:
| Training Loss | Epoch | Step | Validation Loss |
|---|---|---|---|
| 1.1904 | 0.5618 | 500 | 1.0617 |
| 0.765 | 1.1236 | 1000 | 0.9442 |
| 0.782 | 1.6854 | 1500 | 0.8690 |
| 0.5591 | 2.2472 | 2000 | 0.8647 |
| 0.5669 | 2.8090 | 2500 | 0.8296 |
| 0.4205 | 3.3708 | 3000 | 0.8820 |
| 0.3812 | 3.9326 | 3500 | 0.8859 |
| 0.3323 | 4.4944 | 4000 | 0.9360 |