Skip to content
Guides4 min read

Entendiendo los Formatos de Datos de Potato

Una inmersión profunda en los formatos de datos JSON y JSONL, con ejemplos para anotación de texto, imagen, audio y multimodal.

Potato Team·

Entendiendo los Formatos de Datos de Potato

Potato utiliza formatos JSON y JSONL para datos de entrada y anotaciones de salida. Esta guía cubre las especificaciones de formato, ejemplos y mejores prácticas para todos los tipos de datos.

Formatos de Datos de Entrada

JSON Lines (JSONL) - Recomendado

Un objeto JSON por línea:

json
{"id": "001", "text": "First document text here."}
{"id": "002", "text": "Second document text here."}
{"id": "003", "text": "Third document text here."}

Ventajas:

  • Procesamiento en flujo (eficiente en memoria)
  • Fácil de agregar datos
  • Una línea corrupta no rompe el archivo

Array JSON

Array JSON estándar:

json
[
  {"id": "001", "text": "First document."},
  {"id": "002", "text": "Second document."},
  {"id": "003", "text": "Third document."}
]

Configuración:

yaml
data_files:
  - data/items.json

Datos de Anotación de Texto

Texto Básico

json
{"id": "doc_001", "text": "The product quality exceeded my expectations."}

Con Metadatos

json
{
  "id": "review_001",
  "text": "Great product, fast shipping!",
  "metadata": {
    "source": "amazon",
    "date": "2024-01-15",
    "author": "user123",
    "rating": 5
  }
}

Con Pre-anotaciones

json
{
  "id": "ner_001",
  "text": "Apple announced new products in Cupertino.",
  "pre_annotations": {
    "entities": [
      {"start": 0, "end": 5, "label": "ORG", "text": "Apple"},
      {"start": 31, "end": 40, "label": "LOC", "text": "Cupertino"}
    ]
  }
}

Configuración:

yaml
data_files:
  - data/texts.json
 
item_properties:
  id_key: id
  text_key: text

Datos de Anotación de Imágenes

Imágenes Locales

json
{
  "id": "img_001",
  "image_path": "/data/images/photo_001.jpg",
  "caption": "Street scene in Paris"
}

Imágenes Remotas

json
{
  "id": "img_002",
  "image_url": "https://example.com/images/photo.jpg"
}

Con Cuadros Delimitadores

json
{
  "id": "detection_001",
  "image_path": "/images/street.jpg",
  "pre_annotations": {
    "objects": [
      {"bbox": [100, 150, 200, 300], "label": "person"},
      {"bbox": [350, 200, 450, 280], "label": "car"}
    ]
  }
}

Configuración:

yaml
data_files:
  - data/images.json
 
item_properties:
  id_key: id
  image_key: image_path  # or image_url

Datos de Anotación de Audio

Audio Local

json
{
  "id": "audio_001",
  "audio_path": "/data/audio/recording.wav",
  "duration": 45.5,
  "transcript": "Hello, how are you today?"
}

Con Segmentos

json
{
  "id": "audio_002",
  "audio_path": "/audio/meeting.mp3",
  "segments": [
    {"start": 0.0, "end": 5.5, "speaker": "Speaker1"},
    {"start": 5.5, "end": 12.0, "speaker": "Speaker2"}
  ]
}

Configuración:

yaml
data_files:
  - data/audio.json
 
item_properties:
  audio_key: audio_path
  text_key: transcript

Datos Multimodales

Texto + Imagen

json
{
  "id": "mm_001",
  "text": "What is shown in this image?",
  "image_path": "/images/scene.jpg"
}

Texto + Audio

json
{
  "id": "mm_002",
  "text": "Transcribe this audio:",
  "audio_path": "/audio/clip.wav",
  "reference_transcript": "Expected transcription here"
}

Formato de Anotación de Salida

Salida Básica

json
{
  "id": "doc_001",
  "text": "Great product!",
  "annotations": {
    "sentiment": "Positive",
    "confidence": 5
  },
  "annotator": "user123",
  "timestamp": "2024-11-05T10:30:00Z"
}

Anotaciones de Span

json
{
  "id": "ner_001",
  "text": "Apple CEO Tim Cook visited Paris.",
  "annotations": {
    "entities": [
      {"start": 0, "end": 5, "label": "ORG", "text": "Apple"},
      {"start": 10, "end": 18, "label": "PERSON", "text": "Tim Cook"},
      {"start": 27, "end": 32, "label": "LOC", "text": "Paris"}
    ]
  }
}

Múltiples Anotadores

json
{
  "id": "item_001",
  "text": "Sample text",
  "annotations": [
    {
      "annotator": "ann1",
      "labels": {"sentiment": "Positive"},
      "timestamp": "2024-11-05T10:00:00Z"
    },
    {
      "annotator": "ann2",
      "labels": {"sentiment": "Positive"},
      "timestamp": "2024-11-05T11:00:00Z"
    }
  ],
  "aggregated": {
    "sentiment": "Positive",
    "agreement": 1.0
  }
}

Referencia de Configuración

yaml
data_files:
  - data/items.json
 
item_properties:
  id_key: id
  text_key: text
  image_key: image_path
  audio_key: audio_path

Mejores Prácticas

  1. Siempre incluir IDs: Identificadores únicos para rastreo
  2. Usar JSONL para conjuntos grandes: Mejor eficiencia de memoria
  3. Validar antes de cargar: Verificar la sintaxis JSON
  4. Incluir metadatos: Fuente, fecha, autor ayudan con la depuración
  5. Nombres de campo consistentes: Procesamiento más fácil posteriormente

Documentación completa de formatos de datos en /docs/core-concepts/data-formats.