Skip to content
गाइड4 मिनट में पढ़ें

Potato के डेटा प्रारूप समझना

Potato में JSON और JSONL प्रारूपों की विस्तार से पड़ताल: टेक्स्ट, इमेज, ऑडियो, वीडियो और मल्टीमॉडल एनोटेशन के लिए आइटम कैसे बनाएँ, असली config उदाहरणों के साथ।

Potato Team

Potato इनपुट डेटा JSON और JSONL में पढ़ता है और एनोटेशन भी उन्हीं में लिखता है। इसमें ज़्यादा कुछ है नहीं, पर जैसे ही डेटासेट बड़ा होता है या आप टेक्स्ट के साथ इमेज और ऑडियो मिलाने लगते हैं, ब्योरे मायने रखने लगते हैं। यह गाइड हर डेटा प्रकार के लिए चलते-फिरते उदाहरणों के साथ इन प्रारूपों से गुज़रती है।

इनपुट डेटा के प्रारूप

JSON Lines (JSONL)

हर पंक्ति पर एक JSON ऑब्जेक्ट। पहले इसी प्रारूप की तरफ़ हाथ बढ़ाइए:

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

JSONL क्यों: पूरी फ़ाइल मेमोरी में लादने के बजाय आप उसे पंक्ति-दर-पंक्ति पढ़ सकते हैं, नया रिकॉर्ड जोड़ना बस एक पंक्ति जोड़ना है, और एक बिगड़ी हुई पंक्ति से बाक़ी फ़ाइल नहीं गिरती।

JSON array

सामान्य JSON array:

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

कॉन्फ़िगरेशन:

yaml
data_files:
  - data/items.json

टेक्स्ट एनोटेशन का डेटा

सादा टेक्स्ट

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

मेटाडेटा के साथ

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

पहले से लगे एनोटेशन के साथ

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"}
    ]
  }
}

कॉन्फ़िगरेशन:

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

इमेज एनोटेशन का डेटा

अपनी मशीन पर रखी इमेज

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

दूर रखी इमेज

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

bounding box के साथ

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"}
    ]
  }
}

कॉन्फ़िगरेशन:

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

ऑडियो एनोटेशन का डेटा

अपनी मशीन पर रखा ऑडियो

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

सेगमेंट के साथ

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"}
  ]
}

कॉन्फ़िगरेशन:

yaml
data_files:
  - data/audio.json
 
item_properties:
  id_key: id
  text_key: transcript
 
instance_display:
  fields:
    - key: audio_path
      type: audio
      display_options:
        controls: true

मल्टीमॉडल डेटा

टेक्स्ट + इमेज

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

टेक्स्ट + ऑडियो

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

एनोटेशन का आउटपुट प्रारूप

सादा आउटपुट

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

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"}
    ]
  }
}

कई एनोटेटर

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
  }
}

कॉन्फ़िगरेशन संदर्भ

yaml
data_files:
  - data/items.json
 
item_properties:
  id_key: id
  text_key: text
  image_key: image_path
 
instance_display:
  fields:
    - key: audio_path
      type: audio

कुछ आदतें जो सिरदर्द बचाती हैं

हर आइटम को एक अनोखी ID दीजिए; जिस दिन किसी एनोटेशन को उसके स्रोत तक वापस खोजना पड़ेगा, उसी दिन उसकी ज़रूरत पड़ेगी। फ़ाइल बड़ी हो जाए तो JSONL पर चले जाइए। लोड करने से पहले JSON जाँच लीजिए, क्योंकि एक भटका हुआ कॉमा देर से और उलझा देने वाले ढंग से पकड़ में आता है। स्रोत, तारीख़ और लेखक जैसा मेटाडेटा साथ रखिए, भले ही अभी काम न आ रहा हो, क्योंकि बाद में ग़लती ढूँढ़ना उससे कहीं आसान हो जाता है। और फ़ील्ड के नाम एक बार तय करके उन्हीं पर टिकिए, ताकि आगे के स्क्रिप्ट को हर फ़ाइल के लिए अलग इंतज़ाम न करना पड़े।

समर्थित key की पूरी सूची के लिए डेटा प्रारूप दस्तावेज़ देखें।


डेटा प्रारूप के पूरे दस्तावेज़ डेटा प्रारूप पर हैं।