HarshilDaGoat commited on
Commit
3550cc6
·
verified ·
1 Parent(s): d8bc38b

Upload extraction model

Browse files
README.md ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language: en
4
+ library_name: transformers
5
+ pipeline_tag: token-classification
6
+ base_model: distilbert-base-cased
7
+ tags: [token-classification, document-understanding, procurement, india, gem, synthetic-data]
8
+ ---
9
+
10
+ # GeM certificate field extractor
11
+
12
+ Token-classification model that reads the OCR text of Indian business certificates submitted with
13
+ Government e-Marketplace (GeM) bids and extracts the fields a compliance officer cross-checks:
14
+ GSTIN, PAN, Udyam number, CIN, EPFO establishment code, DPIIT number, legal and trade name,
15
+ activity, enterprise category, certified local-content % and validity-until date.
16
+
17
+ Part of an automated bid-compliance platform; it replaces a regex parser in the document stage,
18
+ and its output is cross-verified against government portal data by an auditable rule engine.
19
+
20
+ ## Intended use
21
+
22
+ Input: plain text from a certificate (PDF text layer or OCR). Output: one value per field, with a
23
+ confidence. Covered document types: GST registration certificate (REG-06), Udyam certificate,
24
+ Make in India local-content self-certificate, PAN card, EPFO compliance certificate, DPIIT startup
25
+ recognition, OEM authorization letter, CA turnover certificate, NSIC registration.
26
+
27
+ It is an extraction aid, not a verifier: a correctly extracted GSTIN says nothing about whether
28
+ that GSTIN is active — that comes from the GST portal.
29
+
30
+ ## Training data
31
+
32
+ Generated by `ml/extraction/generate.py`: 54,000 train, 3,000 validation, 3,000 test examples.
33
+
34
+ The generator deliberately includes look-alikes a regex gets wrong: the OEM's own GSTIN beside the
35
+ bidder's in authorization letters, a "minimum local content of N%" threshold restated before the
36
+ certified figure, validity *start* dates, PANs embedded in GSTINs, past-year Udyam classifications,
37
+ and UDIN/FRN/ESIC numbers — plus OCR-style character confusions (O/0, S/5, I/1) and merged lines.
38
+
39
+ **All training data is synthetic.** Identifiers follow real formats (GSTINs carry a valid check
40
+ character) but correspond to no real entity. Accuracy on real, scanned certificates with layouts
41
+ unlike the templates will be lower than the figures below; evaluate on your own documents first.
42
+
43
+ ## Evaluation (held-out synthetic test set)
44
+
45
+ Entity-level, exact span match:
46
+
47
+ | Field | Precision | Recall | F1 | Support |
48
+ |---|---|---|---|---|
49
+ | ACTIVITY | 100.0% | 100.0% | 100.0% | 902 |
50
+ | CATEGORY | 100.0% | 100.0% | 100.0% | 902 |
51
+ | CIN | 100.0% | 100.0% | 100.0% | 124 |
52
+ | DPIIT | 100.0% | 100.0% | 100.0% | 312 |
53
+ | EPFO | 100.0% | 100.0% | 100.0% | 311 |
54
+ | GSTIN | 100.0% | 100.0% | 100.0% | 1174 |
55
+ | LEGAL_NAME | 100.0% | 100.0% | 100.0% | 3000 |
56
+ | LOCAL_CONTENT | 100.0% | 99.7% | 99.8% | 296 |
57
+ | PAN | 100.0% | 100.0% | 100.0% | 593 |
58
+ | TRADE_NAME | 100.0% | 100.0% | 100.0% | 296 |
59
+ | UDYAM | 100.0% | 100.0% | 100.0% | 902 |
60
+ | VALID_UNTIL | 100.0% | 100.0% | 100.0% | 789 |
61
+ | **All (micro)** | 100.0% | 100.0% | **100.0%** | 9601 |
62
+
63
+ ## Usage
64
+
65
+ ```python
66
+ from transformers import pipeline
67
+ extract = pipeline("token-classification", model="HarshilDaGoat/gem-certificate-extractor", aggregation_strategy="simple")
68
+ extract("Registration Number: 27AABCN1234A1Z5\nLegal Name of Business: Nova Electro Systems Private Limited")
69
+ ```
70
+
71
+ For field values normalised exactly as the platform uses them (dates as ISO, local content as a
72
+ number, one value per field), use `ml/extraction/infer.py` from the project repository.
config.json ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "activation": "gelu",
3
+ "architectures": [
4
+ "DistilBertForTokenClassification"
5
+ ],
6
+ "attention_dropout": 0.1,
7
+ "bos_token_id": null,
8
+ "dim": 768,
9
+ "dropout": 0.1,
10
+ "dtype": "float32",
11
+ "eos_token_id": null,
12
+ "hidden_dim": 3072,
13
+ "id2label": {
14
+ "0": "O",
15
+ "1": "B-GSTIN",
16
+ "2": "I-GSTIN",
17
+ "3": "B-PAN",
18
+ "4": "I-PAN",
19
+ "5": "B-UDYAM",
20
+ "6": "I-UDYAM",
21
+ "7": "B-CIN",
22
+ "8": "I-CIN",
23
+ "9": "B-EPFO",
24
+ "10": "I-EPFO",
25
+ "11": "B-DPIIT",
26
+ "12": "I-DPIIT",
27
+ "13": "B-TRADE_NAME",
28
+ "14": "I-TRADE_NAME",
29
+ "15": "B-LEGAL_NAME",
30
+ "16": "I-LEGAL_NAME",
31
+ "17": "B-ACTIVITY",
32
+ "18": "I-ACTIVITY",
33
+ "19": "B-CATEGORY",
34
+ "20": "I-CATEGORY",
35
+ "21": "B-LOCAL_CONTENT",
36
+ "22": "I-LOCAL_CONTENT",
37
+ "23": "B-VALID_UNTIL",
38
+ "24": "I-VALID_UNTIL"
39
+ },
40
+ "initializer_range": 0.02,
41
+ "label2id": {
42
+ "B-ACTIVITY": 17,
43
+ "B-CATEGORY": 19,
44
+ "B-CIN": 7,
45
+ "B-DPIIT": 11,
46
+ "B-EPFO": 9,
47
+ "B-GSTIN": 1,
48
+ "B-LEGAL_NAME": 15,
49
+ "B-LOCAL_CONTENT": 21,
50
+ "B-PAN": 3,
51
+ "B-TRADE_NAME": 13,
52
+ "B-UDYAM": 5,
53
+ "B-VALID_UNTIL": 23,
54
+ "I-ACTIVITY": 18,
55
+ "I-CATEGORY": 20,
56
+ "I-CIN": 8,
57
+ "I-DPIIT": 12,
58
+ "I-EPFO": 10,
59
+ "I-GSTIN": 2,
60
+ "I-LEGAL_NAME": 16,
61
+ "I-LOCAL_CONTENT": 22,
62
+ "I-PAN": 4,
63
+ "I-TRADE_NAME": 14,
64
+ "I-UDYAM": 6,
65
+ "I-VALID_UNTIL": 24,
66
+ "O": 0
67
+ },
68
+ "max_position_embeddings": 512,
69
+ "model_type": "distilbert",
70
+ "n_heads": 12,
71
+ "n_layers": 6,
72
+ "output_past": true,
73
+ "pad_token_id": 0,
74
+ "qa_dropout": 0.1,
75
+ "seq_classif_dropout": 0.2,
76
+ "sinusoidal_pos_embds": false,
77
+ "tie_weights_": true,
78
+ "tie_word_embeddings": true,
79
+ "transformers_version": "5.17.0",
80
+ "use_cache": false,
81
+ "vocab_size": 28996
82
+ }
field_eval.json ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model": {
3
+ "overall_accuracy": 0.9999,
4
+ "overall_false_positive_rate": 0.0,
5
+ "per_field": {
6
+ "gstin": {
7
+ "accuracy": 1.0,
8
+ "false_positive_rate": 0.0,
9
+ "support": 1174
10
+ },
11
+ "pan": {
12
+ "accuracy": 1.0,
13
+ "false_positive_rate": 0.0,
14
+ "support": 593
15
+ },
16
+ "udyam_number": {
17
+ "accuracy": 1.0,
18
+ "false_positive_rate": 0.0,
19
+ "support": 902
20
+ },
21
+ "cin": {
22
+ "accuracy": 1.0,
23
+ "false_positive_rate": 0.0,
24
+ "support": 124
25
+ },
26
+ "establishment_code": {
27
+ "accuracy": 1.0,
28
+ "false_positive_rate": 0.0,
29
+ "support": 311
30
+ },
31
+ "dpiit_number": {
32
+ "accuracy": 1.0,
33
+ "false_positive_rate": 0.0,
34
+ "support": 312
35
+ },
36
+ "trade_name": {
37
+ "accuracy": 1.0,
38
+ "false_positive_rate": 0.0,
39
+ "support": 296
40
+ },
41
+ "legal_name": {
42
+ "accuracy": 1.0,
43
+ "false_positive_rate": null,
44
+ "support": 3000
45
+ },
46
+ "activity": {
47
+ "accuracy": 1.0,
48
+ "false_positive_rate": 0.0,
49
+ "support": 902
50
+ },
51
+ "enterprise_category": {
52
+ "accuracy": 1.0,
53
+ "false_positive_rate": 0.0,
54
+ "support": 901
55
+ },
56
+ "local_content_pct": {
57
+ "accuracy": 0.9966,
58
+ "false_positive_rate": 0.0,
59
+ "support": 296
60
+ },
61
+ "valid_until": {
62
+ "accuracy": 1.0,
63
+ "false_positive_rate": 0.0,
64
+ "support": 784
65
+ }
66
+ }
67
+ }
68
+ }
metrics.json ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "test": {
3
+ "micro": {
4
+ "precision": 1.0,
5
+ "recall": 0.9999,
6
+ "f1": 0.9999,
7
+ "support": 9601
8
+ },
9
+ "per_label": {
10
+ "ACTIVITY": {
11
+ "precision": 1.0,
12
+ "recall": 1.0,
13
+ "f1": 1.0,
14
+ "support": 902
15
+ },
16
+ "CATEGORY": {
17
+ "precision": 1.0,
18
+ "recall": 1.0,
19
+ "f1": 1.0,
20
+ "support": 902
21
+ },
22
+ "CIN": {
23
+ "precision": 1.0,
24
+ "recall": 1.0,
25
+ "f1": 1.0,
26
+ "support": 124
27
+ },
28
+ "DPIIT": {
29
+ "precision": 1.0,
30
+ "recall": 1.0,
31
+ "f1": 1.0,
32
+ "support": 312
33
+ },
34
+ "EPFO": {
35
+ "precision": 1.0,
36
+ "recall": 1.0,
37
+ "f1": 1.0,
38
+ "support": 311
39
+ },
40
+ "GSTIN": {
41
+ "precision": 1.0,
42
+ "recall": 1.0,
43
+ "f1": 1.0,
44
+ "support": 1174
45
+ },
46
+ "LEGAL_NAME": {
47
+ "precision": 1.0,
48
+ "recall": 1.0,
49
+ "f1": 1.0,
50
+ "support": 3000
51
+ },
52
+ "LOCAL_CONTENT": {
53
+ "precision": 1.0,
54
+ "recall": 0.9966,
55
+ "f1": 0.9983,
56
+ "support": 296
57
+ },
58
+ "PAN": {
59
+ "precision": 1.0,
60
+ "recall": 1.0,
61
+ "f1": 1.0,
62
+ "support": 593
63
+ },
64
+ "TRADE_NAME": {
65
+ "precision": 1.0,
66
+ "recall": 1.0,
67
+ "f1": 1.0,
68
+ "support": 296
69
+ },
70
+ "UDYAM": {
71
+ "precision": 1.0,
72
+ "recall": 1.0,
73
+ "f1": 1.0,
74
+ "support": 902
75
+ },
76
+ "VALID_UNTIL": {
77
+ "precision": 1.0,
78
+ "recall": 1.0,
79
+ "f1": 1.0,
80
+ "support": 789
81
+ }
82
+ }
83
+ },
84
+ "args": {
85
+ "data": "/content/repo/ml/data/extraction",
86
+ "out": "/content/repo/ml/models/extraction",
87
+ "base_model": "distilbert-base-cased",
88
+ "epochs": 3.0,
89
+ "batch_size": 16,
90
+ "lr": 5e-05,
91
+ "max_length": 512,
92
+ "limit": null,
93
+ "seed": 13
94
+ }
95
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:963dbdd68a515c36e88c86e77da10ee8f842709b748ded1ff9841294b52fbee1
3
+ size 260852884
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "backend": "tokenizers",
3
+ "cls_token": "[CLS]",
4
+ "do_lower_case": false,
5
+ "is_local": false,
6
+ "local_files_only": false,
7
+ "mask_token": "[MASK]",
8
+ "model_max_length": 512,
9
+ "pad_token": "[PAD]",
10
+ "sep_token": "[SEP]",
11
+ "strip_accents": null,
12
+ "tokenize_chinese_chars": true,
13
+ "tokenizer_class": "BertTokenizer",
14
+ "unk_token": "[UNK]"
15
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5f98a77b89a5a75458f58e8ff6427bfd9d7e513bad0562966d01d1f0c5fbe3bd
3
+ size 5265