A extração de entidades de Healthcare AutoML fornece um ponto de partida para você treinar modelos personalizados do Healthcare Natural Language.
Como preparar dados de treinamento
Para treinar um modelo de Extração de entidades de Healthcare AutoML, forneça amostras representativas do tipo de texto médico que você quer analisar, anotado com rótulos que identificam os tipos de entidades que você quer que seu modelo personalizado identifique. Considere as seguintes recomendações ao compilar dados de treinamento:
- Você precisa fornecer entre 50 e 100.000 amostras de texto médico para treinar seu modelo personalizado.
- É possível rotular o texto médico com 1 a 100 rótulos exclusivos para fazer anotações nas entidades que você quer que o modelo aprenda a extrair.
- Cada anotação é um período de texto e um rótulo associado.
- Os nomes dos rótulos podem ter entre dois e 30 caracteres.
- Cada rótulo pode anotar entre uma e 10 palavras.
- Para treinar um modelo com eficiência, o conjunto de dados de treinamento precisa usar cada rótulo pelo menos 200 vezes.
Se você estiver anotando um tipo de documento estruturado ou semiestruturado, como uma fatura médica ou um formulário de consentimento, o AutoML Natural Language poderá considerar a posição de uma anotação na página como um fator que contribui para o rótulo adequado.
Como formatar documentos de treinamento
Para formatar documentos de treinamento, faça upload dos dados de treinamento no AutoML Natural Language como arquivos JSONL (em inglês) que contêm o texto e os documentos de amostra. Cada linha no arquivo é um único documento de treinamento, especificado de uma das seguintes formas:
- O conteúdo completo do documento, entre dez e dez mil bytes de comprimento, codificado em UTF-8
- O URI de um arquivo PDF de um bucket do Cloud Storage associado ao projeto
É possível anotar os documentos de texto diretamente antes de fazer upload deles, na IU do AutoML Natural Language depois de enviar documentos não anotados ou adicionar anotações a documentos anotados anteriormente na IU.
Documentos JSONL
Para ajudá-lo a criar arquivos de treinamento em JSONL, o AutoML Natural Language oferece um script Python que converte arquivos de texto simples em arquivos JSONL formatados adequadamente. Veja os detalhes nos comentários do script.
Cada documento no arquivo JSONL tem um destes formatos:
Para documentos não anotados:
{ "text_snippet": {"content": string} }
Para documentos anotados:
{ "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} }
Nos arquivos JSONL de amostra:
- Cada elemento
text_extraction
identifica uma anotação dentro detext_snippet.content
.text_extraction
indica a posição do texto anotado especificando o número de caracteres desde o início detext_snippet.content
ao início (start_offset
) e final (end_offset
) do texto. display_name
é o rótulo da entidade.start_offset
eend_offset
são desvios de caracteres, não deslocamentos de bytes. O caractere emend_offset
não é incluído no texto
Para ver mais informações, consulte TextSegment
.
Os elementos text_extraction
são opcionais. Omita-os se planeja anotar
o documento usando a IU do AutoML Natural Language. Cada anotação pode cobrir
até dez tokens, normalmente palavras. Elas não podem se sobrepor, ou seja, o
start_offset
de uma anotação não pode estar entre start_offset
e
end_offset
de outra anotação no mesmo documento.
A amostra de documento de treinamento a seguir identifica as doenças específicas mencionadas em uma abstração do corpus 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 " } }
Documentos em PDF
Cada documento precisa ser uma linha no arquivo JSONL. A amostra a seguir
inclui quebras de linha para facilitar a leitura; você precisa removê-las no arquivo JSONL.
Para mais informações, consulte jsonlines.org (em inglês). Para
fazer upload de um arquivo PDF como um documento, coloque o caminho do arquivo
dentro de um elemento document
do JSONL conforme mostrado na amostra a seguir:
{ "document": { "input_config": { "gcs_source": { "input_uris": [ "gs://cloud-ml-data/NL-entity/sample.pdf" ] } } } }
O valor do elemento input_uris
é o caminho para um arquivo PDF em um
bucket do Cloud Storage associado ao projeto. O tamanho máximo
do arquivo PDF é de 2 MB.