GPT-4o extracts structured evidence. A deterministic Python rule engine decides eligibility. Every criterion verdict is criterion-level explainable with source-page citations and a SHA-256 hash-chained audit trail.
PyMuPDF · pdfplumber · GPT-4o Vision · Jaccard NER · GSTN/PAN/CVC KYC · ReportLab · SHA-256
Core Separation of Concerns
GPT-4o Extracts
Structured evidence from unstructured docs
Normaliser
Entity resolution · INR units · Date parsing
Rule Engine Decides
100% deterministic Python — never AI direct
KYC Validates
GSTN · PAN · CVC · MCA21 registries
Human Reviews
Low-confidence cases auto-escalated
Audit Seals
SHA-256 hash-chain on every event
Technical Methodology
Every evaluation traverses a deterministic sequence. No stage can be skipped. Each stage writes to the audit trail before the next begins.
PyMuPDF + pdfplumber + GPT-4o Vision
Native PDFs are parsed with PyMuPDF for text and pdfplumber for table extraction. Scanned pages are detected via a text-density heuristic (< 50 chars + embedded images) and routed to GPT-4o Vision at 300 dpi. Tables are serialised to GitHub-Flavoured Markdown before chunking so no financial schedule is silently dropped.
Regex + Jaccard token similarity + Indian unit normalisers
Company names are stripped of legal suffixes (Pvt Ltd, LLP, Corp) and reduced to canonical uppercase tokens. Jaccard similarity across token sets resolves aliases ("TCS", "Tata Consultancy Services Ltd", "T.C.S. Pvt. Ltd."). Financial amounts are normalised to absolute INR via Crore/Lakh/Million multipliers. Dates are parsed across 15+ Indian government formats.
GPT-4o · JSON mode · Jinja2 prompt templates
A Jinja2 template constructs a domain-specific prompt that instructs GPT-4o to return a strict JSON array of criterion objects — each with category, threshold_json, mandatory_status, required_document, source_clause, and extraction_confidence. Output is validated, markdown fences stripped, and parsed deterministically. Ambiguity flags are stored for every criterion.
Keyword scoring · Sliding window chunking · Overlap 400 chars
Bidder documents are chunked with a 3,000-char window and 400-char overlap. For each criterion, chunks are scored by keyword overlap with the criterion description and the top-k are selected as context. Each chunk carries its page number and OCR confidence so evidence citations are source-traceable.
Python rules · Confidence gates · Near-threshold logic
GPT-4o never makes eligibility decisions. A pure Python rule engine dispatches to category-specific functions (financial.py, technical.py, compliance.py) that apply threshold comparisons, date-validity checks, and GSTIN/PAN format validation. Any verdict within 10% of a numeric threshold AND below the confidence floor is auto-escalated to NEEDS_MANUAL_REVIEW.
GSTN API · ITD PAN API · CVC Debarment · MCA21 (sandbox)
Bidder identifiers are cross-checked against four government registries: GSTN (GST registration status), ITD NSDL (PAN active/deactivated), CVC debarment orders, and MCA21 company status (Active / Struck-off / Under Liquidation). Runs in sandbox mode during evaluation; production endpoints are credential-swappable without logic changes.
SHA-256 · Append-only · Tamper-evident
Every system and human action — OCR completion, criterion extraction, verdict emission, manual override, report generation — is written as an AuditEvent row with SHA-256(payload + prev_hash). The chain can be verified end-to-end by any auditor; a broken link unambiguously identifies the tampered record.
OCR Deep Dive
Financial eligibility tables in government tenders — annual turnover schedules, project completion registers, EMD payment confirmations — are the most data-dense and legally critical content in the entire document. Generic OCR systems flatten them to prose and lose column structure. TenderGraph AI+ has a four-stage table resolution pipeline:
# pdfplumber extract → GFM serialisation
| Project Name | Value (Cr) | Year |
|---|---|---|
| National Highway 48 | 45.20 | 2022 |
| DMRC Phase IV | 120.00 | 2023 |
| Kochi Metro Ext | 68.50 | 2021 |
# chunk text sent to GPT-4o includes table
# → extracted_value: 233.7, unit: "Crore"
# → normalised INR: ₹2,337,000,000
pdfplumber uses PDF character bounding-box geometry to reconstruct table borders without relying on visible grid lines. This correctly handles the borderless and lightly-ruled tables common in NIT annexures and financial schedule forms.
Extracted tables are converted to GitHub-Flavoured Markdown (pipe-delimited rows + header separator) and appended to the page text before chunking. This means table rows survive the sliding-window chunker and are visible to GPT-4o during evidence extraction.
For scanned pages, a specialised prompt instructs GPT-4o to return a JSON object with a 'tables_markdown' array alongside prose text. The model is explicitly told to preserve every cell, row, and column header — unlike a generic OCR prompt that would flatten the table into prose.
Some government PDFs use whitespace alignment instead of borders. We detect these via a numeric-density heuristic: if > 30% of lines contain Indian numeric patterns (comma-separated figures, Crore/Lakh keywords), the page is flagged for table-aware GPT-4o processing even if pdfplumber finds no formal table.
A priority-ordered regex strips all legal entity suffixes before comparison: Private Limited, Pvt. Ltd., LLP, Corporation, Inc., Co. Ltd. — so the canonical form used for deduplication contains only the trading name.
After normalisation, each name is tokenised on whitespace. Jaccard similarity (|A ∩ B| / |A ∪ B|) between token sets identifies aliases regardless of word order. Threshold ≥ 0.72 triggers a deduplication merge.
Amounts are parsed with a regex that captures the numeric value and unit, then multiplied: × 10,000,000 for Crore/Cr, × 100,000 for Lakh/Lac, × 1,000,000 for Million. Currency symbols (₹, Rs., INR) are stripped. All figures land in absolute INR for threshold comparison.
15+ date formats common in Indian government documents are attempted in order: DD/MM/YYYY, DD-MM-YYYY, DD.MM.YYYY, DD Mon YYYY, YYYY-MM-DD, DD-Mon-YY. Ordinal suffixes (1st, 22nd) are stripped before parsing. The resolved date is stored as ISO-8601 and compared against the tender closing date for certificate expiry checks.
Normalisation Engine
Government documents — especially self-prepared bidder submissions — contain the same entity in dozens of inconsistent representations. Without normalisation, a rule engine comparing "INR 5,00,000" with a threshold of "Five Lakhs" will fail. The normalisation layer resolves these mismatches before a single rule runs.
# Company name resolution
"T.C.S. Private Limited"
"Tata Consultancy Services Ltd."
"TCS Pvt. Ltd"
→ strip suffixes → tokenise → Jaccard
canonical: "TATA CONSULTANCY SERVICES"
similarity: 1.0 (same entity)
# Financial normalisation
"Rs. 2.5 Crore" → 25,000,000 INR
"₹ 50,00,000/-" → 5,000,000 INR
KYC Integration
Before any eligibility verdict is issued, bidder identifiers are cross-verified against four Indian government registries. Running in sandbox mode — production endpoints are credential-swappable without any logic changes.
Validates GSTIN against the CBIC 15-character specification (2-digit state code + PAN + entity code + Z + checksum). Queries GSTN registry for Active / Cancelled / Suspended status and registration date.
Validates PAN format (AAAAA9999A) and queries ITD NSDL for Active / Deactivated status. Entity type (Individual / Company / HUF) is verified against the company's legal form.
Company canonical name (after suffix stripping) is SHA-256 hashed and checked against the Central Vigilance Commission debarment list. Debarred companies immediately trigger a FAIL verdict regardless of financial/technical scores.
Checks the Ministry of Corporate Affairs21 registry for company status: Active, Struck Off, Under Liquidation, or Dormant. Struck-off companies cannot legally enter government contracts.
# POST /api/kyc/full-check → composite KYC result
overall_kyc_status: "PASS"
gstin_check.status: "Active" // GSTN registry
pan_check.status: "Active" // ITD NSDL
debarment.debarred: false // CVC debarment list
company_status: "Active" // MCA21 registry
issues: []
Zero Silent Disqualifications
Three thresholds gate automatic verdict emission. Every gate miss routes to human review — never to silent rejection.
If the OCR engine returns a page confidence below 0.60, none of the text from that page is used in rule evaluation. The entire criterion is escalated to NEEDS_MANUAL_REVIEW.
If GPT-4o returns an evidence extraction confidence below 0.75, the rule engine ignores the extracted value and routes to manual review regardless of whether the extracted figure would pass.
If an extracted financial value is within 10% of the pass/fail threshold AND extraction confidence is below 0.80, the verdict is NEEDS_MANUAL_REVIEW even though the raw figure would have passed.
Access Control
JWT-signed roles enforced at every API endpoint via FastAPI dependency injection.
Tamper Evidence
Every system event and human action is written to the audit_events table as an append-only row. Each row's hash is computed over the event payload concatenated with the prev_hash of the preceding row. The chain can be verified by any external auditor using the GET /api/audit/verify-chain endpoint. A broken hash unambiguously identifies the tampered record.
# Audit event row (append-only)
event_type: "VERDICT_EMITTED"
actor_id: "SYSTEM"
payload: { verdict: "ELIGIBLE", rule: "check_financial_criterion:meets_threshold" }
prev_hash: "a3f9c2d1..."
this_hash: SHA256(payload + prev_hash)
# Verification walk
for event in chain:
expected = SHA256(event.payload + prev)
assert event.this_hash == expected
→ chain_valid: true, events_verified: 1,847
Sign in to your procurement workspace or create an account to run your first tender evaluation.