Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
BigQuery si integra con Document AI per aiutarti a creare casi d'uso di analisi dei documenti e AI generativa. Con l'accelerazione della trasformazione digitale, le organizzazioni generano grandi quantità di testo e altri dati dei documenti, tutti con un enorme potenziale per approfondimenti e per alimentare nuovi casi d'uso dell'AI generativa. Per sfruttare al meglio questi dati,
siamo felici di annunciare un'integrazione tra BigQuery
e Document AI, che ti consente di estrarre insight dai dati dei documenti e creare
nuove applicazioni di modelli linguistici di grandi dimensioni (LLM).
Panoramica
I clienti BigQuery ora possono creare estrattori personalizzati Document AI, basati sui
foundation model all'avanguardia di Google, che possono personalizzare in base ai propri documenti
e metadati. Questi modelli personalizzati possono poi essere richiamati da BigQuery per estrarre dati strutturati dai documenti in modo sicuro e controllato, utilizzando la semplicità e la potenza di SQL.
Prima di questa integrazione, alcuni clienti hanno tentato di creare pipeline Document AI indipendenti, il che comportava la cura manuale della logica di estrazione e dello schema. La
mancanza di funzionalità di integrazione integrate ha portato allo sviluppo di un'infrastruttura personalizzata
per sincronizzare e mantenere la coerenza dei dati. In questo modo, ogni progetto di analisi dei documenti
si è trasformato in un'impresa sostanziale che ha richiesto un investimento significativo.
Ora, con questa integrazione, i clienti possono creare modelli remoti in BigQuery
per i propri estrattori personalizzati in Document AI e utilizzarli per eseguire analisi dei documenti
e AI generativa su larga scala, aprendo una nuova era di innovazione e approfondimenti basati sui dati.
Un'esperienza unificata e controllata dai dati all'AI
Puoi creare un estrattore personalizzato in Document AI in tre passaggi:
Definisci i dati da estrarre dai documenti. Questo viene chiamato
document schema, archiviato con ogni versione dell'estrattore personalizzato e accessibile da BigQuery.
(Facoltativo) Fornisci documenti aggiuntivi con annotazioni come esempi dell'estrazione.
Addestra il modello per l'estrattore personalizzato in base ai foundation model forniti in Document AI.
Oltre agli estrattori personalizzati che richiedono l'addestramento manuale, Document AI fornisce anche estrattori pronti all'uso per spese, scontrini, fatture, moduli fiscali, documenti di identità rilasciati dal governo e una moltitudine di altri scenari nella galleria dei processori.
Una volta pronto l'estrattore personalizzato, puoi passare a BigQuery Studio
per analizzare i documenti utilizzando SQL nei quattro passaggi seguenti:
Registra un modello remoto BigQuery per l'estrattore utilizzando SQL. Il modello può
comprendere lo schema del documento (creato sopra), richiamare l'estrattore personalizzato
e analizzare i risultati.
Crea tabelle di oggetti utilizzando SQL per i documenti archiviati in Cloud Storage. Puoi
governare i dati non strutturati nelle tabelle impostando criteri di accesso a livello di riga,
che limitano l'accesso degli utenti a determinati documenti e quindi limitano la potenza dell'AI per
la privacy e la sicurezza.
Utilizza la funzione ML.PROCESS_DOCUMENT nella tabella degli oggetti per estrarre i campi pertinenti
effettuando chiamate di inferenza all'endpoint API. Puoi anche filtrare i documenti per le estrazioni con una clausola WHERE al di fuori della funzione.
La funzione restituisce una tabella strutturata, in cui ogni colonna è un campo estratto.
Unisci i dati estratti ad altre tabelle BigQuery per combinare dati strutturati e non strutturati e produrre valori aziendali.
L'esempio seguente illustra l'esperienza utente:
# Create an object table in BigQuery that maps to the document files stored in Cloud Storage.CREATEORREPLACEEXTERNALTABLE`my_dataset.document`WITHCONNECTION`my_project.us.example_connection`OPTIONS(object_metadata='SIMPLE',uris=['gs://my_bucket/path/*'],metadata_cache_mode='AUTOMATIC',max_staleness=INTERVAL1HOUR);# Create a remote model to register your Doc AI processor in BigQuery.CREATEORREPLACEMODEL`my_dataset.layout_parser`REMOTEWITHCONNECTION`my_project.us.example_connection`OPTIONS(remote_service_type='CLOUD_AI_DOCUMENT_V1',document_processor='PROCESSOR_ID');# Invoke the registered model over the object table to parse PDF documentSELECTuri,total_amount,invoice_dateFROMML.PROCESS_DOCUMENT(MODEL`my_dataset.layout_parser`,TABLE`my_dataset.document`,PROCESS_OPTIONS=> (JSON'{"layout_config": {"chunking_config": {"chunk_size": 250}}}'))WHEREcontent_type='application/pdf';
Tabella dei risultati
Analisi del testo, riepilogo e altri casi d'uso dell'analisi dei documenti
Una volta estratto il testo dai documenti, puoi eseguire l'analisi dei documenti in diversi modi:
Utilizza BigQuery ML per eseguire l'analisi del testo: BigQuery ML supporta l'addestramento e
il deployment di modelli di incorporamento in vari modi. Ad esempio, puoi utilizzare BigQuery ML
per identificare il sentiment dei clienti nelle chiamate di assistenza o per classificare il feedback sui prodotti
in diverse categorie. Se utilizzi Python, puoi anche utilizzare BigQuery DataFrames
per pandas e API simili a scikit-learn per l'analisi del testo sui tuoi dati.
Utilizza l'LLM text-embedding-004 per generare incorporamenti dai documenti suddivisi in blocchi: BigQuery ha una funzione ML.GENERATE_EMBEDDING che chiama il modello text-embedding-004 per generare incorporamenti. Ad esempio, puoi utilizzare Document AI per estrarre il feedback dei clienti e riassumerlo utilizzando PaLM 2, il tutto con BigQuery SQL.
Unisci i metadati dei documenti ad altri dati strutturati archiviati nelle tabelle BigQuery:
Ad esempio, puoi generare embedding utilizzando i documenti suddivisi in blocchi e utilizzarli per la ricerca vettoriale.
# Example 1: Parse the chunked dataCREATEORREPLACETABLEdocai_demo.demo_result_parsedAS(SELECTuri,JSON_EXTRACT_SCALAR(json,'$.chunkId')ASid,JSON_EXTRACT_SCALAR(json,'$.content')AScontent,JSON_EXTRACT_SCALAR(json,'$.pageFooters[0].text')ASpage_footers_text,JSON_EXTRACT_SCALAR(json,'$.pageSpan.pageStart')ASpage_span_start,JSON_EXTRACT_SCALAR(json,'$.pageSpan.pageEnd')ASpage_span_endFROMdocai_demo.demo_result,UNNEST(JSON_EXTRACT_ARRAY(ml_process_document_result.chunkedDocument.chunks,'$'))json)# Example 2: Generate embeddingCREATEORREPLACETABLE`docai_demo.embeddings`ASSELECT*FROMML.GENERATE_EMBEDDING(MODEL`docai_demo.embedding_model`,TABLE`docai_demo.demo_result_parsed`);
Implementare casi d'uso della ricerca e dell'AI generativa
Una volta estratto il testo strutturato dai documenti, puoi creare indici
ottimizzati per le query di ricerca di un ago in un pagliaio, resi possibili dalle funzionalità di ricerca
e indicizzazione di BigQuery, sbloccando una potente funzionalità di ricerca.
Questa integrazione consente inoltre di sbloccare nuove applicazioni LLM generative come l'esecuzione
dell'elaborazione di file di testo per il filtraggio della privacy, i controlli di sicurezza dei contenuti e la suddivisione in token
utilizzando SQL e modelli Document AI personalizzati. Il testo estratto, combinato con altri metadati,
semplifica la cura del corpus di addestramento necessario per mettere a punto modelli
di grandi dimensioni. Inoltre, stai creando casi d'uso LLM su dati aziendali controllati
che sono stati fondati tramite le funzionalità di gestione dell'indice vettoriale e di generazione di embedding di BigQuery. Se sincronizzi questo indice con Vertex AI, puoi
implementare casi d'uso di generazione aumentata dal recupero, per un'esperienza di AI più controllata e
semplificata.
Applicazione di esempio
Per un esempio di applicazione end-to-end con il connettore Document AI:
Guarda la demo relativa al report sulle spese su GitHub.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 UTC."],[[["\u003cp\u003eBigQuery now integrates with Document AI, enabling users to extract insights from document data and create new large language model (LLM) applications.\u003c/p\u003e\n"],["\u003cp\u003eCustomers can create custom extractors in Document AI, powered by Google's foundation models, and then invoke these models from BigQuery to extract structured data using SQL.\u003c/p\u003e\n"],["\u003cp\u003eThis integration simplifies document analytics projects by eliminating the need for manually building extraction logic and schemas, thus reducing the investment needed.\u003c/p\u003e\n"],["\u003cp\u003eBigQuery's \u003ccode\u003eML.PROCESS_DOCUMENT\u003c/code\u003e function, along with remote models, object tables, and SQL, facilitates the extraction of relevant fields from documents and the combination of this data with other structured data.\u003c/p\u003e\n"],["\u003cp\u003ePost-extraction, BigQuery ML and the \u003ccode\u003etext-embedding-004\u003c/code\u003e model can be leveraged for text analytics, generating embeddings, and building indexes for advanced search and generative AI applications.\u003c/p\u003e\n"]]],[],null,["# BigQuery integration\n====================\n\nBigQuery integrates with Document AI to help build document analytics and generative AI\nuse cases. As digital transformation accelerates, organizations are generating vast\namounts of text and other document data, all of which holds immense potential for\ninsights and powering novel generative AI use cases. To help harness this data,\nwe're excited to announce an integration between [BigQuery](/bigquery)\nand [Document AI](/document-ai), letting you extract insights from document data and build\nnew large language model (LLM) applications.\n\nOverview\n--------\n\nBigQuery customers can now create Document AI [custom extractors](/blog/products/ai-machine-learning/document-ai-workbench-custom-extractor-and-summarizer), powered by Google's\ncutting-edge foundation models, which they can customize based on their own documents\nand metadata. These customized models can then be invoked from BigQuery to\nextract structured data from documents in a secure, governed manner, using the\nsimplicity and power of SQL.\nPrior to this integration, some customers tried to construct independent Document AI\npipelines, which involved manually curating extraction logic and schema. The\nlack of built-in integration capabilities left them to develop bespoke infrastructure\nto synchronize and maintain data consistency. This turned each document analytics\nproject into a substantial undertaking that required significant investment.\nNow, with this integration, customers can create remote models in BigQuery\nfor their custom extractors in Document AI, and use them to perform document analytics\nand generative AI at scale, unlocking a new era of data-driven insights and innovation.\n\nA unified, governed data to AI experience\n-----------------------------------------\n\nYou can build a custom extractor in the Document AI with three steps:\n\n1. Define the data you need to extract from your documents. This is called `document schema`, stored with each version of the custom extractor, accessible from BigQuery.\n2. Optionally, provide extra documents with annotations as samples of the extraction.\n3. Train the model for the custom extractor, based on the foundation models provided in Document AI.\n\nIn addition to custom extractors that require manual training, Document AI also\nprovides ready to use extractors for expenses, receipts, invoices, tax forms,\ngovernment ids, and a multitude of other scenarios, in the processor gallery.\n\nThen, once you have the custom extractor ready, you can move to BigQuery Studio\nto analyze the documents using SQL in the following four steps:\n\n1. Register a BigQuery remote model for the extractor using SQL. The model can understand the document schema (created above), invoke the custom extractor, and parse the results.\n2. Create object tables using SQL for the documents stored in Cloud Storage. You can govern the unstructured data in the tables by setting row-level access policies, which limits users' access to certain documents and thus restricts the AI power for privacy and security.\n3. Use the function `ML.PROCESS_DOCUMENT` on the object table to extract relevant fields by making inference calls to the API endpoint. You can also filter out the documents for the extractions with a `WHERE` clause outside of the function. The function returns a structured table, with each column being an extracted field.\n4. Join the extracted data with other BigQuery tables to combine structured and unstructured data, producing business values.\n\nThe following example illustrates the user experience:\n\n # Create an object table in BigQuery that maps to the document files stored in Cloud Storage.\n CREATE OR REPLACE EXTERNAL TABLE `my_dataset.document`\n WITH CONNECTION `my_project.us.example_connection`\n OPTIONS (\n object_metadata = 'SIMPLE',\n uris = ['gs://my_bucket/path/*'],\n metadata_cache_mode= 'AUTOMATIC',\n max_staleness= INTERVAL 1 HOUR\n );\n\n # Create a remote model to register your Doc AI processor in BigQuery.\n CREATE OR REPLACE MODEL `my_dataset.layout_parser`\n REMOTE WITH CONNECTION `my_project.us.example_connection`\n OPTIONS (\n remote_service_type = 'CLOUD_AI_DOCUMENT_V1', \n document_processor='\u003cvar translate=\"no\"\u003ePROCESSOR_ID\u003c/var\u003e'\n );\n\n # Invoke the registered model over the object table to parse PDF document\n SELECT uri, total_amount, invoice_date\n FROM ML.PROCESS_DOCUMENT(\n MODEL `my_dataset.layout_parser`,\n TABLE `my_dataset.document`,\n PROCESS_OPTIONS =\u003e (\n JSON '{\"layout_config\": {\"chunking_config\": {\"chunk_size\": 250}}}')\n )\n WHERE content_type = 'application/pdf';\n\nTable of results\n\nText analytics, summarization and other document analysis use cases\n-------------------------------------------------------------------\n\nOnce you have extracted text from your documents, you can then perform document\nanalytics in a few ways:\n\n- Use BigQuery ML to perform text-analytics: BigQuery ML supports training and deploying embedding models in a variety of ways. For example, you can use BigQuery ML to identify customer sentiment in support calls, or to classify product feedback into different categories. If you are a Python user, you can also use BigQuery DataFrames for pandas, and scikit-learn-like APIs for text analysis on your data.\n- Use `text-embedding-004` LLM to generate embeddings from the chunked documents: BigQuery has a `ML.GENERATE_EMBEDDING` function that calls the `text-embedding-004` model to generate embeddings. For example, you can use a Document AI to extract customer feedback and summarize the feedback using PaLM 2, all with BigQuery SQL.\n- Join document metadata with other structured data stored in BigQuery tables:\n\nFor example, you can generate embeddings using the chunked documents and use it for vector search. \n\n # Example 1: Parse the chunked data\n\n CREATE OR REPLACE TABLE docai_demo.demo_result_parsed AS (SELECT\n uri,\n JSON_EXTRACT_SCALAR(json , '$.chunkId') AS id,\n JSON_EXTRACT_SCALAR(json , '$.content') AS content,\n JSON_EXTRACT_SCALAR(json , '$.pageFooters[0].text') AS page_footers_text,\n JSON_EXTRACT_SCALAR(json , '$.pageSpan.pageStart') AS page_span_start,\n JSON_EXTRACT_SCALAR(json , '$.pageSpan.pageEnd') AS page_span_end\n FROM docai_demo.demo_result, UNNEST(JSON_EXTRACT_ARRAY(ml_process_document_result.chunkedDocument.chunks, '$')) json)\n\n # Example 2: Generate embedding\n\n CREATE OR REPLACE TABLE `docai_demo.embeddings` AS\n SELECT * FROM ML.GENERATE_EMBEDDING(\n MODEL `docai_demo.embedding_model`,\n TABLE `docai_demo.demo_result_parsed`\n );\n\nImplement search and generative AI use cases\n--------------------------------------------\n\nOnce you've extracted structured text from your documents, you can build indexes\noptimized for needle in the haystack queries, made possible by BigQuery's search\nand indexing capabilities, unlocking powerful search capability.\nThis integration also helps unlock new generative LLM applications like executing\ntext-file processing for privacy filtering, content safety checks, and token chunking\nusing SQL and custom Document AI models. The extracted text, combined with other metadata,\nsimplifies the curation of the training corpus required to fine-tune large language\nmodels. Moreover, you're building LLM use cases on governed, enterprise data\nthat's been grounded through BigQuery's embedding generation and vector index\nmanagement capabilities. By synchronizing this index with Vertex AI, you can\nimplement retrieval-augmented generation use cases, for a more governed and\nstreamlined AI experience.\n\nSample application\n------------------\n\nFor an example of an end-to-end application using the Document AI Connector:\n\n- Refer to this expense report demo on [GitHub](https://github.com/GoogleCloudPlatform/smart-expenses).\n- Read the companion [blog post](/blog/topics/developers-practitioners/smarter-applications-document-ai-workflows-and-cloud-functions).\n- Watch a deep dive [video](https://www.youtube.com/watch?v=Bnac6JnBGQg&t=1s) from Google Cloud Next 2021."]]