Prepara datos de entrenamiento de texto para el análisis de opiniones
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
En esta página, se describe cómo preparar datos de texto para usarlos en un conjunto de datos
de Vertex AI para entrenar un modelo de análisis de opiniones.
Los datos de entrenamiento de análisis de opiniones se componen de documentos asociados con un valor que indica la opinión del contenido. Por ejemplo, es posible que tengas tuits sobre un dominio en particular, como Air travel. Cada tuit se asocia con un valor de opinión que indica si el tuit es positivo, negativo o neutral.
Requisitos de los datos
Debes proporcionar entre 10 y 100,000 documentos de entrenamiento en total.
Un valor de opinión debe ser un número entero entre 0 y 10. El valor máximo de opiniones es tu elección. Por ejemplo, si deseas identificar si la opinión es negativa, positiva o neutra, puedes etiquetar los datos de entrenamiento con puntuaciones de opinión de 0 (negativo), 1 (neutral) y 2 (positivo). La puntuación máxima de las opiniones para este conjunto de datos es de 2. Si deseas lograr un mayor nivel de detalle, como cinco niveles de opinión, puedes etiquetar los documentos de 0 (más negativo) a 4 (más positivo).
Debes aplicar cada valor de opinión, por lo menos, a 10 documentos.
Los valores de la puntuación de opinión deben ser números enteros consecutivos a partir de cero. Si tienes brechas en las puntuaciones o no comienzas desde cero, reasigna las puntuaciones para que sean números enteros consecutivos a partir de cero.
Puedes incluir documentos intercalados o hacer referencia a archivos TXT que están en buckets de Cloud Storage.
Prácticas recomendadas para los datos de texto que se usan a fin de entrenar los modelos de AutoML
Los siguientes requisitos se aplican a los conjuntos de datos que se usan para entrenar modelos de AutoML.
Proporciona al menos 100 documentos por valor de opinión.
Usa una cantidad similar de documentos para cada puntuación de opiniones. Tener más ejemplos para puntuaciones de opinión específicas puede ingresar sesgos en el modelo.
Archivos de entrada
Los tipos de archivo de entrada para el análisis de opiniones pueden ser líneas JSON o CSV.
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Información o código de muestra incorrectos","incorrectInformationOrSampleCode","thumb-down"],["Faltan la información o los ejemplos que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-09-02 (UTC)"],[],[],null,["# Prepare text training data for sentiment analysis\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 sentiment analysis model.\n\nSentiment analysis training data consists of documents that are associated\nwith a sentiment value that indicates the sentiment of the content. For\nexample, you might have tweets about a particular domain such as air\ntravel. Each tweet is associated with sentiment value that indicates if the\ntweet is positive, negative, or neutral.\n\nData requirements\n-----------------\n\n- You must supply at least 10, but no more than 100,000, total training documents.\n- A sentiment value must be an integer from 0 to 10. The maximum sentiment value is your choice. For example, if you want to identify whether the sentiment is negative, positive, or neutral, you can label the training data with sentiment scores of 0 (negative), 1 (neutral), and 2 (positive). The maximum sentiment score for this dataset is 2. If you want to capture more granularity, such as five levels of sentiment, you can label documents from 0 (most negative) to 4 (most positive).\n- You must apply each sentiment value to at least 10 documents.\n- Sentiment score values must be consecutive integers starting from zero. If you have gaps in scores or don't start from zero, remap your scores to be consecutive integers starting from zero.\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- Provide at least 100 documents per sentiment value.\n- Use a balanced number of documents for each sentiment score. Having more examples for particular sentiment scores can introduce bias into the model.\n\nInput files\n-----------\n\nInput file types for sentiment analysis can be JSON Lines or CSV. \n\n### JSON Lines\n\nThe format, field names, value types for JSON Lines files are determined\nby a schema file, which are publicly accessible YAML files.\n\nYou can download the schema file for sentiment analysis from the\nfollowing Cloud Storage location: \n\n[gs://google-cloud-aiplatform/schema/dataset/ioformat/text_sentiment_io_format_1.0.0.yaml](https://storage.cloud.google.com/google-cloud-aiplatform/schema/dataset/ioformat/text_sentiment_io_format_1.0.0.yaml)\n\n**JSON Lines example**\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.\nIn your JSON Lines 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 \"sentimentAnnotation\": {\n \"sentiment\": number,\n \"sentimentMax\": number\n },\n \"textContent\": \"inline_text\",\n \"dataItemResourceLabels\": {\n \"aiplatform.googleapis.com/ml_use\": \"training|test|validation\"\n }\n}\n{\n \"sentimentAnnotation\": {\n \"sentiment\": number,\n \"sentimentMax\": number\n },\n \"textGcsUri\": \"gcs_uri_to_file\",\n \"dataItemResourceLabels\": {\n \"aiplatform.googleapis.com/ml_use\": \"training|test|validation\"\n }\n}\n```\n\n### CSV\n\nEach line in a CSV file refers to a single document. The following\nexample shows the general format of a valid CSV file. The [ml_use](/vertex-ai/docs/general/ml-use) column\nis optional. \n\n```\n [ml_use],gcs_file_uri|\"inline_text\",sentiment,sentimentMax\n \n```\n\nThe following snippet is an example of an input CSV file. \n\n```\n test,gs://path_to_file,sentiment_value,sentiment_max_value\n test,\"inline_text\",sentiment_value,sentiment_max_value\n training,gs://path_to_file,sentiment_value,sentiment_max_value\n validation,gs://path_to_file,sentiment_value,sentiment_max_value\n \n```"]]