Preparare i dati di addestramento del testo per l'estrazione delle entità
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Questa pagina descrive come preparare i dati di testo da utilizzare in un set di dati Vertex AI per addestrare un modello di estrazione di entità.
I dati di addestramento per l'estrazione delle entità consistono in documenti annotati con le etichette che identificano i tipi di entità che vuoi che il modello identifichi. Ad esempio, potresti creare un modello di estrazione di entità per identificare la terminologia specializzata in documenti legali o brevetti. Le annotazioni specificano
le posizioni delle entità che stai etichettando e le etichette stesse.
Se annoti documenti strutturati o semistrutturati per un set di dati utilizzato per addestrare i modelli AutoML, come fatture o contratti, Vertex AI può considerare la posizione di un'annotazione sulla pagina come un fattore che contribuisce alla sua etichetta corretta. Ad esempio, un contratto immobiliare ha sia una data di accettazione sia una data di chiusura. Vertex AI può imparare a distinguere le entità in base alla posizione spaziale dell'annotazione.
Requisiti dei dati
Devi fornire almeno 50 e non più di 100.000 documenti di addestramento.
Devi fornire almeno 1 etichetta univoca e non più di 100 per annotare le entità che vuoi estrarre.
Puoi utilizzare un'etichetta per annotare da 1 a 10 parole.
I nomi delle etichette possono avere una lunghezza compresa tra 2 e 30 caratteri.
Puoi includere le annotazioni nei file JSON Lines oppure aggiungerle più tardi utilizzando la Google Cloud console dopo aver caricato i documenti.
Puoi includere documenti in linea o file TXT di riferimento che si trovano
nei bucket Cloud Storage.
Best practice per i dati di testo utilizzati per addestrare i modelli AutoML
I seguenti consigli si applicano ai set di dati utilizzati per addestrare i modelli AutoML.
Utilizza ogni etichetta almeno 200 volte nel set di dati di addestramento.
Annota ogni occorrenza delle entità che vuoi che il modello identifichi.
File di input
I tipi di file di input per l'estrazione delle entità devono essere JSON Lines. Il formato, i nomi dei campi e i tipi di valore per i file JSON Lines sono determinati da un file schema, ovvero file YAML accessibili pubblicamente.
L'esempio seguente mostra come utilizzare lo schema per creare il tuo
file JSON Lines. L'esempio include interruzioni di riga per favorire la leggibilità. Nei file JSON, includi gli a capo solo dopo ogni documento. Il campo dataItemResourceLabels specifica, ad esempio, ml_use ed è facoltativo.
Puoi anche aggiungere annotazioni ai documenti utilizzando la Google Cloud console. Crea un
file righe JSON contenente solo i contenuti (senza il campo textSegmentAnnotations);
i documenti vengono caricati su Vertex AI senza alcuna annotazione.
[[["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."],[],[],null,["# Prepare text training data for entity extraction\n\n| Starting on September 15, 2024, you can only customize classification, entity extraction, and sentiment analysis objectives by moving to Vertex AI Gemini prompts and tuning. Training or updating models for Vertex AI AutoML for Text classification, entity extraction, and sentiment analysis objectives will no longer be available. You can continue using existing Vertex AI AutoML Text models until June 15, 2025. For a comparison of AutoML text and Gemini, see [Gemini for AutoML text users](/vertex-ai/docs/start/automl-gemini-comparison). For more information about how Gemini offers enhanced user experience through improved prompting capabilities, see [Introduction to tuning](/vertex-ai/generative-ai/docs/models/tune-gemini-overview). To get started with tuning, see [Model tuning for Gemini text models](/vertex-ai/generative-ai/docs/models/tune_gemini/tune-gemini-learn)\n\nThis page describes how to prepare text data for use in a Vertex AI\ndataset to train a entity extraction model.\n\nEntity extraction training data consists of documents that are annotated with\nthe labels that identify the types of entities that you want your model to\nidentify. For example, you might create an entity extraction model to identify\nspecialized terminology in legal documents or patents. Annotations specify\nthe locations of the entities that you're labeling and the labels themselves.\n\nIf you're annotating structured or semi-structure documents for a dataset used\nto train AutoML models, such as invoices or contracts,\nVertex AI can consider an annotation's\nposition on the page as a factor contributing to its proper label. For\nexample, a real estate contract has both an acceptance date and a closing\ndate. Vertex AI can learn to distinguish between the entities\nbased on the spatial position of the annotation.\n\nData requirements\n-----------------\n\n- You must supply at least 50, and no more than 100,000, training documents.\n- You must supply at least 1, and no more than 100, unique labels to annotate entities that you want to extract.\n- You can use a label to annotate between 1 and 10 words.\n- Label names can be between 2 and 30 characters.\n- You can include annotations in your JSON Lines files, or you can add annotations later by using the Google Cloud console after uploading documents.\n- You can include documents inline or reference TXT files that are in Cloud Storage buckets.\n\nBest practices for text data used to train AutoML models\n--------------------------------------------------------\n\nThe following recommendations apply to datasets used to train\nAutoML models.\n\n- Use each label at least 200 times in your training dataset.\n- Annotate every occurrence of entities that you want your model to identify.\n\nInput files\n-----------\n\nInput file types for entity extraction must be JSON Lines. The format, field\nnames, and value types for JSON Lines files are determined by a schema file,\nwhich\nare publicly accessible YAML files.\n\nYou can download the schema file for entity extraction from the following\nCloud Storage location: \n\n[gs://google-cloud-aiplatform/schema/dataset/ioformat/text_extraction_io_format_1.0.0.yaml](https://storage.cloud.google.com/google-cloud-aiplatform/schema/dataset/ioformat/text_extraction_io_format_1.0.0.yaml).\n\nThe following example shows how you might use the schema to create your\nown JSON Lines file. The example includes line breaks for readability. In your\nJSON files, include line breaks only after each document. The\n`dataItemResourceLabels` field specifies, for example, [ml_use](/vertex-ai/docs/general/ml-use) and is\noptional. \n\n```\n{\n \"textSegmentAnnotations\": [\n {\n \"startOffset\":number,\n \"endOffset\":number,\n \"displayName\": \"label\"\n },\n ...\n ],\n \"textContent\": \"inline_text\",\n \"dataItemResourceLabels\": {\n \"aiplatform.googleapis.com/ml_use\": \"training|test|validation\"\n }\n}\n{\n \"textSegmentAnnotations\": [\n {\n \"startOffset\":number,\n \"endOffset\":number,\n \"displayName\": \"label\"\n },\n ...\n ],\n \"textGcsUri\": \"gcs_uri_to_file\",\n \"dataItemResourceLabels\": {\n \"aiplatform.googleapis.com/ml_use\": \"training|test|validation\"\n }\n}\n```\n\nYou can also annotate documents by using the Google Cloud console. Create a\nJSON Lines file with content only (without the `textSegmentAnnotations` field);\ndocuments are uploaded to Vertex AI without any annotations."]]