Questa è una versione PDF del contenuto. Per la versione completa e aggiornata, visita:
Verrai reindirizzato automaticamente...
Processing a real estate loan has traditionally been one of the slowest, most costly, and error-prone tasks for lending institutions. In 2026, the integration of AI into mortgage processing is radically transforming this landscape, enabling the analysis of dozens of complex documents in mere seconds. Payslips, tax returns, bank statements, and property valuations are no longer bottlenecks, but structured data ready for automated processing.
In this technical tutorial, led by engineer Francesco Zinghinì —an expert in Fintech systems and CRM development for credit management—we will explore how advanced prompt engineering and Large Language Models (LLMs) are revolutionizing financial back-office operations. We will build an enterprise-grade document processing pipeline using Retrieval-Augmented Generation (RAG) techniques on leading cloud platforms such as Google Cloud Vertex AI and AWS Bedrock . The goal? To reduce approval times from weeks to just a few hours, while ensuring maximum security and privacy for sensitive data (PII).
Before writing the first line of code or the first prompt, it is essential to define a robust architecture. Analyzing financial documents requires a deterministic approach: we cannot afford AI model hallucinations when assessing an applicant's income.
The tools and prerequisites for implementing this solution include:
According to official AWS Bedrock documentation, using Agents for Amazon Bedrock enables the orchestration of complex workflows, securely invoking enterprise APIs (such as a CRM) only after validating the extracted data. On the Google side, Vertex AI Search serves as an optimized retrieval backend, ensuring that the LLM (such as Gemini 1.5 Pro) bases its responses exclusively on the documents uploaded for the specific mortgage application.
RAG is the beating heart of our pipeline. Generic language models do not know the details of "Mr. Rossi's" mortgage application. RAG solves this problem by injecting specific context directly into the model's prompt.
In the context of mortgage underwriting, the RAG process comprises three critical phases:
"The most common mistake when implementing AI for mortgages is treating financial documents as simple continuous text. Tables, merged cells, and data hierarchies require advanced OCR and RAG that is aware of the document's spatial structure." – Francesco Zinghinì
Let's see how to build the pipeline step by step, simulating an architecture based on AWS Bedrock and Lambda functions (or their Cloud Run equivalents on GCP).
The client uploads a batch of mixed PDFs via the web portal. The AI's first task is document classification . We use a fast LLM (such as Claude 3 Haiku on Bedrock or Gemini 1.5 Flash) to analyze the first page of each document and categorize it.
The system will label the files as: BUSTA_PAGA , ESTRATTO_CONTO , CARTA_IDENTITA , COMPROMESSO . If a mandatory document is missing, the system immediately sends a notification to the client, eliminating back-office downtime.
Once classified, the documents proceed to the extraction module. Here, we use more capable models (Claude 3.5 Sonnet or Gemini 1.5 Pro) configured with a temperature of 0 to ensure maximum determinism and eliminate creativity (and, consequently, hallucinations).
AI does not simply read one document at a time; its true added value lies in cross-referencing . The system verifies that the net salary credited to the bank statement (e.g., €2,150 on April 27) exactly matches the net pay shown on the payslip for the same month. Any discrepancy triggers a flag for the human analyst.
The secret to perfect extraction lies in prompt engineering . It is not enough to simply ask the LLM, "What is the income?" We must provide rigorous system instructions, define the output format (JSON Schema), and supply examples (few-shot prompting).
Here is an example of a system prompt optimized for extraction from an Italian payslip:
Sei un analista del credito senior specializzato in mutui ipotecari italiani. Il tuo compito è estrarre dati finanziari chiave dal testo OCR di una busta paga fornita nel tag <document>. REGOLE TASSATIVE: 1. Estrai SOLO i dati esplicitamente presenti nel documento. 2. Se un dato non è presente o è illeggibile, restituisci null. NON indovinare o calcolare valori mancanti. 3. Formatta tutti gli importi monetari come numeri decimali (es. 2150.50), rimuovendo il simbolo dell'Euro ei separatori delle migliaia. 4. L'output DEVE essere un JSON valido conforme al seguente schema: { "mese_competenza": "MM/YYYY", "datore_di_lavoro": "Nome Azienda", "tipo_contratto": "Indeterminato | Determinato | Apprendistato | Altro", "netto_in_busta": 0.00, "trattenute_cessione_quinto": 0.00 }#Sei un analista del credito senior specializzato in mutui ipotecari italiani. Il tuo compito è estrarre dati finanziari chiave dal testo OCR di una busta paga fornita nel tag <document>. REGOLE TASSATIVE: 1. Estrai SOLO i dati esplicitamente presenti nel documento. 2. Se un dato non è presente o è illeggibile, restituisci null. NON indovinare o calcolare valori mancanti. 3. Formatta tutti gli importi monetari come numeri decimali (es. 2150.50), rimuovendo il simbolo dell'Euro ei separatori delle migliaia. 4. L'output DEVE essere un JSON valido conforme al seguente schema: { "mese_competenza": "MM/YYYY", "datore_di_lavoro": "Nome Azienda", "tipo_contratto": "Indeterminato | Determinato | Apprendistato | Altro", "netto_in_busta": 0.00, "trattenute_cessione_quinto": 0.00 }
By providing this prompt to a model that supports JSON Mode (such as the Vertex AI or Bedrock APIs), we obtain a structured payload ready to be injected into the CRM's relational database.
One of the key parameters for mortgage approval is the Debt-to-Income (DTI) ratio —specifically, the ratio between total monthly debt payments (including the new mortgage) and net monthly income. Italian banking policies typically set the maximum sustainability threshold at around 30–35%.
AI can automatically calculate this value by aggregating data extracted from payslips and CRIF (Credit Bureau) reports. Below is an interactive widget simulating the calculation logic implemented in the CRM frontend for analysts:
Enter the data extracted from the LLM to verify the viability of the mortgage application against standard banking policies.
Beyond mathematical calculations, AI excels at anomaly detection (fraud detection). A specific prompt can be configured to compare the employment start date declared by the client with the one shown on their payslip, or to flag recurring outgoing transfers on the bank statement that might indicate a loan not reported to the Central Credit Register.
Data extraction is useless unless it is seamlessly integrated into business processes. Modern architecture entails sending the JSON output generated by the LLM directly to the banking CRM via webhooks or REST APIs.
However, full automation (Straight-Through Processing) for mortgage approval is still not recommended due to regulatory and risk management considerations. The correct approach is the Human-in-the-Loop (HITL) model :
Working with Large Language Models in the financial sector requires rigorous error management. "Hallucinations" (when the model invents data) are the number one enemy.
How can these risks be mitigated according to Google Cloud and AWS best practices?
Applying prompt engineering and generative AI to mortgage application analysis represents a quantum leap for the banking sector. As demonstrated in this technical guide, the combined use of advanced OCR, RAG architectures on AWS Bedrock or Google Cloud Vertex AI, and rigorously structured prompts makes it possible to transform a manual process taking weeks into a digital workflow completed in just a few hours.
The goal is not to replace the credit analyst, but to empower them. By eliminating the tedious tasks of data entry and document verification, credit professionals can focus on complex risk analysis and client advisory services. Banks and credit brokers adopting these technologies in 2026 will not only slash operating costs but also deliver an unprecedented customer experience, ensuring fast, transparent, and secure approvals.
Working with advanced language models and optical recognition systems makes it possible to analyze dozens of complex documents in seconds. This technology automates data extraction from payslips and tax returns, reducing decision-making times from several weeks to just a few hours and minimizing human error.
Retrieval-Augmented Generation is a technique that provides generative models with the specific context of a case file. In the credit sector, documents are fragmented and stored in vector databases, enabling the system to retrieve only the information relevant to calculating net income without fabricating data.
Modern enterprise architectures rely primarily on leading services such as Google Cloud Platform (via Vertex AI) and Amazon Web Services (with Bedrock). These environments offer secure document processing engines and enable the orchestration of complex workflows while ensuring maximum privacy for applicants' sensitive data.
Despite a high level of automation, human oversight remains essential for regulatory and risk management reasons. The system pre-approves optimal cases, but in the event of anomalies or illegible documents, the final decision always rests with a senior analyst who evaluates the discrepancies flagged by the technology.
To prevent the models from generating inaccurate information, developers set creativity parameters to zero and employ techniques to anchor the output to real data. Furthermore, validation scripts are implemented to verify the mathematical consistency of the extracted figures before they are sent to the bank's management system.