Downloads · 30 days
0
shresthagarwal/Phi_3_5_Instruct_Unsloth_line_item
Phi_3_5_Instruct_Unsloth_line_item is a machine learning model from shresthagarwal. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This model, shresthagarwal/Phi35InstructUnslothlineitem, is a fine-tuned version of the Phi 3.5 Instruct model, specifically designed for extracting and mapping structured data from JSON inputs. It is particularly use…
Downloads · 30 days
0
Access
Public
Updated Oct 24, 2024
Repo size
120 MB
Likes
0
Public
Click a slice to open those files.
.safetensors120 MB · 98%
From the Hugging Face model README
shresthagarwal/Phi_3_5_Instruct_Unsloth_line_itemThis model, shresthagarwal/Phi_3_5_Instruct_Unsloth_line_item, is a fine-tuned version of the Phi 3.5 Instruct model, specifically designed for extracting and mapping structured data from JSON inputs. It is particularly useful for tasks involving the extraction of financial and billing information from invoices and receipts.
First, install the required dependencies:
pip install transformers unsloth
from unsloth import FastLanguageModel
model, tokenizer = FastLanguageModel.from_pretrained( model_name="shresthagarwal/Phi_3_5_Instruct_Unsloth_line_item", # YOUR MODEL YOU USED FOR TRAINING max_seq_length=max_seq_length, dtype=dtype, load_in_4bit=load_in_4bit, ) FastLanguageModel.for_inference(model) # Enable native 2x faster inference
messages = [ {"from": "human", "value": "From the input JSON, your task is to map the values of the input JSON to our predefined classes based on context and output that as a JSON. The predefined classes are HsnCode, Description, Quantity, UnitOfMeasurement, UnitPrice, TotalItemAmount, CgstRate, CgstAmount, SgstRate, SgstAmount, IgstRate, IgstAmount, TaxableValue, CessRate, CessAmount. If the key or value of the input JSON contain more than two data fields like HSN code and Description, you have to map both of their outputs into their respective classes for eg, 123456 Book1 to be, HsnCode: 123456, Description: Book1. If the value does not map to any of our predefined classes, leave that class blank. Provide only the JSON as output and no additional text. In the end only output relevant table items from the rest. Input Data: [{"Bill From:": "GSTIN: 06ADDPT0274H003", "Bill To:": "GSTIN: 24AAZFM1250H1Z5", "Ship To:": "GSTIN: 24AAZFM1250H1Z5"}, {"Bill From:": "Name: BDO India LLP", "Bill To:": "Name: Tata", "Ship To:": "Name: Tata"}, {"Bill From:": "Address: The Palm Springs Plaza, Office No. 1501-10,, ,Sector-54, Golf Course Road,", "Bill To:": "Address: Lad Society Road, Vastrapur , City: Ahmedabad Pin Code: 380015", "Ship To:": "Address: Lad Society Road, Vastrapur, City: Gujarat"}, {"Bill From:": "City: Gurgaon Pin Code: 122001", "Ship To:": "Pin Code: 380015"}]"}, ]
inputs = tokenizer.apply_chat_template( messages, tokenize=True, add_generation_prompt=True, # Must add for generation return_tensors="pt", ).to("cuda")
from transformers import TextStreamer text_streamer = TextStreamer(tokenizer, skip_prompt=True) _ = model.generate(input_ids=inputs, streamer=text_streamer, max_new_tokens=4096, use_cache=True)