ratulsur commited on
Commit
a34fef5
Β·
verified Β·
1 Parent(s): d1ad87a

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +92 -0
README.md CHANGED
@@ -1,3 +1,95 @@
1
  ---
2
  license: apache-2.0
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
+ language:
4
+ - en
5
+ base_model: microsoft/Phi-3.5-mini-instruct
6
+ pipeline_tag: text-generation
7
+ tags:
8
+ - finance
9
+ - accounts-payable
10
+ - invoice-audit
11
+ - fraud-detection
12
+ - qlora
13
+ - phi3
14
  ---
15
+
16
+ # AP Auditor β€” Accounts Payable Fraud Detector
17
+
18
+ Fine-tuned **Phi-3.5-mini-instruct** for Accounts Payable invoice auditing.
19
+ Detects fraud, duplicates, pricing errors, and compliance violations instantly.
20
+
21
+ ![Evaluation Results](ap_auditor_evaluation.png)
22
+
23
+ ## Evaluation Results
24
+
25
+ | Metric | Score |
26
+ |---|---|
27
+ | JSON Parse Success | 8/8 (100%) |
28
+ | Action Accuracy | 7/8 (87.5%) |
29
+ | Risk Level Accuracy | 7/8 (87.5%) |
30
+ | Flag Detection | 5/6 (83.3%) |
31
+ | Overall | 87.5% |
32
+
33
+ ## Model Details
34
+
35
+ | Property | Value |
36
+ |---|---|
37
+ | Base Model | Phi-3.5-mini-instruct |
38
+ | Parameters | 3.8B |
39
+ | Method | QLoRA (4-bit NF4 + double quantization) |
40
+ | LoRA Rank | r=64, alpha=128 |
41
+ | Training Samples | 1,219 |
42
+ | Real Data | CORD-v2 (400 receipts) |
43
+ | Synthetic Data | 600 AP audit scenarios |
44
+ | Epochs | 3 |
45
+ | Final Train Loss | 0.853 |
46
+ | Final Val Loss | 0.137 |
47
+
48
+ ## Detects
49
+
50
+ - `duplicate_invoice` β€” same invoice submitted twice
51
+ - `unapproved_vendor` β€” vendor not on approved list
52
+ - `missing_po_reference` β€” no PO number attached
53
+ - `tax_discrepancy` β€” wrong GST rate applied
54
+ - `round_number_fraud` β€” suspiciously round amounts
55
+ - `split_invoice` β€” invoices split to avoid approval threshold
56
+ - `price_mismatch` β€” amount exceeds contracted rate
57
+ - `weekend_submission` β€” invoice submitted on weekend
58
+
59
+ ## Usage
60
+
61
+ ```python
62
+ from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
63
+ import torch, json, re
64
+
65
+ model = AutoModelForCausalLM.from_pretrained(
66
+ "ratulsur/ap-auditor",
67
+ torch_dtype=torch.float16,
68
+ device_map="auto",
69
+ )
70
+ tok = AutoTokenizer.from_pretrained("ratulsur/ap-auditor")
71
+
72
+ SYSTEM_PROMPT = """You are a senior Accounts Payable Auditor AI.
73
+ Output ONLY a valid JSON audit result."""
74
+
75
+ def audit(invoice: dict) -> dict:
76
+ prompt = (
77
+ f"<|system|>\n{SYSTEM_PROMPT}<|end|>\n"
78
+ f"<|user|>\nAudit this invoice:\n\n{json.dumps(invoice, indent=2)}<|end|>\n"
79
+ f"<|assistant|>\n"
80
+ )
81
+ pipe = pipeline("text-generation", model=model, tokenizer=tok,
82
+ return_full_text=False)
83
+ out = pipe(prompt, max_new_tokens=512, do_sample=False)
84
+ raw = out[0]["generated_text"].strip()
85
+ match = re.search(r"\{.*\}", raw, re.DOTALL)
86
+ return json.loads(match.group()) if match else {"error": raw}
87
+ ```
88
+
89
+ ## Live Demo
90
+
91
+ Try it: [huggingface.co/spaces/ratulsur/ap-auditor-demo](https://huggingface.co/spaces/ratulsur/ap-auditor-demo)
92
+
93
+ ## License
94
+
95
+ Apache 2.0