Modelli di estrazione delle entità per il settore sanitario

AutoML Entity Extraction for Healthcare è un punto di partenza per addestrare modelli Healthcare Natural Language personalizzati.

Preparazione dei dati di addestramento

Per addestrare un modello AutoML Entity Extraction for Healthcare, fornisci esempi rappresentativi del tipo di testo medico da analizzare e annotati con etichette che identificano i tipi di entità che vuoi che il tuo modello personalizzato identifichi. Considera i seguenti suggerimenti quando compili i dati di addestramento:

  • Devi fornire tra 50 e 100.000 esempi di testo medico per addestrare il tuo modello personalizzato.
  • Puoi etichettare il testo medico con un numero di etichette univoche compreso tra 1 e 100 per annotare le entità che vuoi che il modello impari a estrarre.
  • Ogni annotazione è un intervallo di testo con un'etichetta associata.
  • I nomi delle etichette possono contenere da 2 a 30 caratteri.
  • Ogni etichetta può aggiungere annotazioni da una a dieci parole.
  • Per addestrare in modo efficace un modello, il set di dati di addestramento deve utilizzare ogni etichetta almeno 200 volte.

Se stai annotando un tipo di documento strutturato o semistrutturato, ad esempio una fattura medica o un modulo di consenso, AutoML Natural Language può considerare la posizione di un'annotazione nella pagina come un fattore che contribuisce alla sua etichetta corretta.

Formattazione dei documenti di addestramento

Per formattare i documenti di addestramento, carica i dati di addestramento in AutoML Natural Language come file JSONL che contengono il testo di esempio e i documenti. Ogni riga del file è un singolo documento di addestramento, specificato in uno dei seguenti formati:

  • L'intero contenuto del documento, di lunghezza compresa tra 10 e 10.000 byte (con codifica UTF-8)
  • L'URI di un file PDF da un bucket Cloud Storage associato al tuo progetto

Puoi annotare i documenti di testo direttamente prima di caricarli, nell'interfaccia utente di AutoML Natural Language dopo aver caricato documenti non annotati, oppure aggiungere annotazioni a documenti annotati in precedenza nell'interfaccia utente.

Documenti JSONL

Per aiutarti a creare file di addestramento JSONL, AutoML Natural Language offre uno script Python che converte i file di testo normale in file JSONL con formato appropriato. Per informazioni dettagliate, leggi i commenti nello script.

Ogni documento nel file JSONL ha uno dei seguenti formati:

Per i documenti non annotati:

{
  "text_snippet":
    {"content": string}
}

Per i documenti annotati:

{
  "annotations": [
     {
      "text_extraction": {
         "text_segment": {
            "end_offset": number, "start_offset": number
          }
       },
       "display_name": string
     },
     {
       "text_extraction": {
          "text_segment": {
             "end_offset": number, "start_offset": number
           }
        },
        "display_name": string
     },
   ...
  ],
  "text_snippet":
    {"content": string}
}

Nei file JSONL di esempio:

  • Ogni elemento text_extraction identifica un'annotazione all'interno di text_snippet.content. text_extraction indica la posizione del testo annotato specificando il numero di caratteri dall'inizio di text_snippet.content all'inizio (start_offset) e alla fine (end_offset) del testo.
  • display_name è l'etichetta dell'entità.
  • start_offset e end_offset sono offset di caratteri e non offset di byte. Il carattere in corrispondenza di end_offset non è incluso nel testo

Per maggiori informazioni, consulta TextSegment.

Gli elementi text_extraction sono facoltativi; puoi ometterli se prevedi di annotare il documento utilizzando l'interfaccia utente di AutoML Natural Language. Ogni annotazione può coprire fino a dieci token, in genere parole. Non possono sovrapporsi, ossia il valore start_offset di un'annotazione non può essere compreso tra start_offset e end_offset di un'altra annotazione nello stesso documento.

Il seguente documento di addestramento di esempio identifica le malattie specifiche menzionate in un estratto del corpus dell'NCBI:

{
  "annotations": [
    {
      "text_extraction": {
        "text_segment": {
          "end_offset": 67,
          "start_offset": 62
        }
      },
      "display_name": "Modifier"
    },
    {
      "text_extraction": {
        "text_segment": {
          "end_offset": 158,
          "start_offset": 141
        }
      },
      "display_name": "SpecificDisease"
    },
    {
      "text_extraction": {
        "text_segment": {
          "end_offset": 330,
          "start_offset": 290
        }
      },
      "display_name": "SpecificDisease"
    },
    {
      "text_extraction": {
        "text_segment": {
          "end_offset": 337,
          "start_offset": 332
        }
      },
      "display_name": "SpecificDisease"
    },
    {
      "text_extraction": {
        "text_segment": {
          "end_offset": 627,
          "start_offset": 610
        }
      },
      "display_name": "Modifier"
    },
    {
      "text_extraction": {
        "text_segment": {
          "end_offset": 754,
          "start_offset": 749
        }
      },
      "display_name": "Modifier"
    },
    {
      "text_extraction": {
        "text_segment": {
          "end_offset": 875,
          "start_offset": 865
        }
      },
      "display_name": "Modifier"
    },
    {
      "text_extraction": {
        "text_segment": {
          "end_offset": 968,
          "start_offset": 951
        }
      },
      "display_name": "Modifier"
    },
    {
      "text_extraction": {
        "text_segment": {
          "end_offset": 1553,
          "start_offset": 1548
        }
      },
      "display_name": "Modifier"
    },
    {
      "text_extraction": {
        "text_segment": {
          "end_offset": 1652,
          "start_offset": 1606
        }
      },
      "display_name": "CompositeMention"
    },
    {
      "text_extraction": {
        "text_segment": {
          "end_offset": 1833,
          "start_offset": 1826
        }
      },
      "display_name": "DiseaseClass"
    },
    {
      "text_extraction": {
        "text_segment": {
          "end_offset": 1860,
          "start_offset": 1843
        }
      },
      "display_name": "SpecificDisease"
    },
    {
      "text_extraction": {
        "text_segment": {
          "end_offset": 1930,
          "start_offset": 1913
        }
      },
      "display_name": "SpecificDisease"
    },
    {
      "text_extraction": {
        "text_segment": {
          "end_offset": 2129,
          "start_offset": 2111
        }
      },
      "display_name": "SpecificDisease"
    },
    {
      "text_extraction": {
        "text_segment": {
          "end_offset": 2188,
          "start_offset": 2160
        }
      },
      "display_name": "SpecificDisease"
    },
    {
      "text_extraction": {
        "text_segment": {
          "end_offset": 2260,
          "start_offset": 2243
        }
      },
      "display_name": "Modifier"
    },
    {
      "text_extraction": {
        "text_segment": {
          "end_offset": 2356,
          "start_offset": 2339
        }
      },
      "display_name": "Modifier"
    }
  ],
  "text_snippet": {
    "content": "10051005\tA common MSH2 mutation in English and North American HNPCC families:
      origin, phenotypic expression, and sex specific differences in colorectal cancer .\tThe
      frequency , origin , and phenotypic expression of a germline MSH2 gene mutation previously
      identified in seven kindreds with hereditary non-polyposis cancer syndrome (HNPCC) was
      investigated . The mutation ( A-- > T at nt943 + 3 ) disrupts the 3 splice site of exon 5
      leading to the deletion of this exon from MSH2 mRNA and represents the only frequent MSH2
      mutation so far reported . Although this mutation was initially detected in four of 33
      colorectal cancer families analysed from eastern England , more extensive analysis has
      reduced the frequency to four of 52 ( 8 % ) English HNPCC kindreds analysed . In contrast ,
      the MSH2 mutation was identified in 10 of 20 ( 50 % ) separately identified colorectal
      families from Newfoundland . To investigate the origin of this mutation in colorectal cancer
      families from England ( n = 4 ) , Newfoundland ( n = 10 ) , and the United States ( n = 3 ) ,
      haplotype analysis using microsatellite markers linked to MSH2 was performed . Within the
      English and US families there was little evidence for a recent common origin of the MSH2
      splice site mutation in most families . In contrast , a common haplotype was identified
      at the two flanking markers ( CA5 and D2S288 ) in eight of the Newfoundland families .
      These findings suggested a founder effect within Newfoundland similar to that reported by
      others for two MLH1 mutations in Finnish HNPCC families . We calculated age related risks
      of all , colorectal , endometrial , and ovarian cancers in nt943 + 3 A-- > T MSH2 mutation
      carriers ( n = 76 ) for all patients and for men and women separately . For both sexes combined ,
      the penetrances at age 60 years for all cancers  and for colorectal cancer were 0 . 86 and 0 . 57 ,
      respectively . The risk of colorectal cancer was significantly higher  in males
      than females ( 0 . 63 v 0 . 30 and 0 . 84 v 0 . 44 at ages 50 and 60 years , respectively ) .
      For females there was a high risk of endometrial cancer ( 0 . 5 at age 60 years ) and premenopausal
      ovarian cancer ( 0 . 2 at 50 years ) . These intersex differences in colorectal cancer risks
      have implications for screening programmes and for attempts to identify colorectal cancer
      susceptibility modifiers .\n "
  }
}

Documenti PDF

Ogni documento deve essere costituito da una riga del file JSONL. Il seguente esempio include interruzioni di riga per la leggibilità; devi rimuoverle nel file JSONL. Per ulteriori informazioni, visita il sito jsonlines.org. Per caricare un file PDF come documento, aggrega il percorso del file all'interno di un elemento document JSONL come mostrato nell'esempio seguente:

{
  "document": {
    "input_config": {
      "gcs_source": {
        "input_uris": [ "gs://cloud-ml-data/NL-entity/sample.pdf" ]
      }
    }
  }
}

Il valore dell'elemento input_uris è il percorso di un file PDF in un bucket Cloud Storage associato al progetto. La dimensione massima del file PDF è 2 MB.