생물.컴퓨터.통계

chatGPT와 대화로 풀어가는 PubMed 맞춤형 검색

프로페서 H 2024. 1. 11. 07:07

 

안녕하세요, 여러분! 오늘은 지난글 (아래 링크)에 이어 ChatGPT Action을 이용해 PubMed 검색을 어떻게 혁신할 수 있는지에 대해 이야기해보려 합니다. chatGPT를 이용한 PubMed 데이터 검색에 관심이 있는 분이라면 이 글이 정말 흥미로울 거예요!

https://medtalk.tistory.com/entry/당신만의-AI-친구-만들기-ChatGPT를-활용한-my-GPT-생성-가이드

 

당신만의 AI 친구 만들기: ChatGPT를 활용한 'my GPT' 생성 가이드

혁신적인 기술의 발전은 우리의 일상과 업무 방식을 변화시키고 있습니다. 그 중심에는 인공지능(AI)이 자리 잡고 있으며, 특히 개인화된 AI 경험을 제공하는 'my GPT'가 주목받고 있습니다. 이번

medtalk.tistory.com

 

 

대화로 풀어가는 PubMed 맞춤형 검색: 당신의 ChatGPT 가이드

PubMed와 ChatGPT의 새로운 만남

의학 연구의 보고인 PubMed와 최첨단 인공지능 기술인 ChatGPT가 어떻게 만나 새로운 가능성을 탐험할 수 있는지에 대해 이야기해보려고 합니다. 지금부터 PubMed 데이터베이스를 효율적으로 검색할 수 있는 맞춤형 ChatGPT 액션을 만드는 과정을 단계별로 살펴보겠습니다. 

PubMed API의 기본 이해

그럼 PubMed에 대해서도 알아볼까요?

PubMed는 미국 국립 보건원(NIH) 산하 국립생물공학정보센터(NCBI)가 운영하는 무료 데이터베이스입니다. 이곳은 의학, 간호학, 치과학, 수의학, 헬스케어 시스템, 예방의학 등 다양한 생명 과학 분야에 걸쳐 3천만 건이 넘는 참고 문헌과 요약문을 제공합니다.

  • 최신 연구 동향 파악: PubMed를 정기적으로 확인하면, 해당 분야에서의 최신 연구 동향과 발전을 쉽게 파악할 수 있습니다.
  • 문헌 검토 및 연구 기반 마련: 연구를 계획하거나 수행할 때 PubMed에서 이전 연구들을 검토하여 연구의 기반을 마련할 수 있습니다.
  • PubMed 공식 웹사이트: https://pubmed.ncbi.nlm.nih.gov
  • 국립생물공학정보센터(NCBI) 소개

chatGPT와 PubMed를 결합한다면, 사용자가 PubMed 데이터베이스에서 필요한 정보를 마치 대화하듯 찾을 수 있도록 도와줄 수 있습니다.

자, 이제 구현하고 싶은 chatGPT를 통해 대화형 PubMed 검색 프로젝트의 요구 사항을 정의해 봅시다!

사용자가 '암 치료'와 같은 특정 키워드로 PubMed를 검색할 때, 관련 논문의 제목, 저자, 출판년도, 내용 요약 등의 정보를 마치 대화하듯 쉽게 얻을 수 있도록 하는 것입니다. 이를 위해, ChatGPT가 PubMed API와 통신하여 필요한 정보를 추출하고, 사용자에게 친숙한 형태로 제공하는 것입니다. 다음 그림과 같이요.

 

단계 1: PubMed와 연동하기 위한 OpenAPI 스키마 설계: GPT 생성 화면 에서 "Create New Action"을 클릭합니다.

"Create GPT"를 선택하면 새로운 GPT를 만들기 위한 설정 화면에서 보이는 여러 옵션들 중에 맨아래의  'Actions'가 있고 'Create New Actions'를 클릭하면 다음과 같은 action을 추가하는 화면이 보입니다.  

화면에서 보이는 순서대로 Authentication, Shema에 대한 정보를 입력해야합니다.

 

1. API Key 구하기

 

우선, Authentication을 클릭하면 우측화면과 같이 API Key를 입력해야하며 PubMed API Key가 필요합니다.

PubMed API Key는 PubMed 홈페이지의 우측 상단 Log in을 합니다. 

 

로그인 후 우측상단 사람 아이콘을 클릭하면 Account setting으로 들어갈 수 있습니다.

 

 

Account Setting의 맨 아래 다음과 같이 API Key Management 아래 API Key 정보가 있습니다. 이를 복사합니다. 

API Key Management

E-utils users are allowed 3 requests/second without an API key. Create an API key to increase your e-utils limit to 10 requests/second. Contact our helpdesk if you need higher throughput. Only one API Key per user. Replacing or deleting will inactivate the current key. Use this key by passing it with api_key=API_key parameter. Refer to documentation for more information.

this key by passing it with api_key=API_key parameter. Refer to documentation for more information.


     
API Key Replace Remove
본인 API key    

 

2. PubMed API Key 붙여넣기

다시 chatGPT의 action 화면으로 돌아가서 Authentication을 클릭합니다. 

복사한 PubMed API Key를 붙여넣고 저장하면 PubMed을 호출하기 위한 준비는 끝났습니다.

 

3. Schema 설계하기

이제 OpenAPI 스키마를 설계해야 합니다. OpenAPI 스키마는 API의 기능과 구조를 명시하는 중요한 도구입니다. 이를 통해 ChatGPT가 PubMed API와 어떻게 통신할지, 어떤 정보를 주고받을지를 정의할 수 있습니다. PubMed 검색에 특화된 ChatGPT 액션을 위해서는, PubMed 데이터베이스의 구조를 이해하고, 이를 ChatGPT 통해 어떤 정보를 반환할지 고안해야 합니다.

 

우선 저는 키워드나 검색어를 대화창에 입력하면, PubMed API를 통해 PubMed 데이터를 검색하게 하고, 저널 제목, 저널명, 연도, 호, 페이지, 그리고 PubMed ID를 포함하도록 OpenAPI 스키마를 구성하도록 했습니다. 이를 위해, 응답 스키마에 이러한 정보들이 포함되도록 정의해야 합니다.

4. 최종 PubMed Schema 구성

 

 

최종적으로 다음과 같이 구성하였습니다(YAML 형식이고, 저도 컴퓨터 언어에는 초보라 이상해도 이해바랍니다). 이를 schema에 복사 붙여넣고 저장하면 준비가 끝납니다. 자동으로 스키마 아래 test 버튼이 생기는데 클릭해서 테스트 해보시기 바랍니다. 대화창에 검색어를 입력해서 테스트 해볼 수 있습니다. 

 

openapi: 3.0.0
info:
  title: NCBI PubMed E-utilities API
  description: Provides access to various NCBI databases including PubMed for bibliographic data.
  version: 1.0.0
servers:
  - url: https://eutils.ncbi.nlm.nih.gov/entrez/eutils/
    description: NCBI E-utilities API server
paths:
  # Existing esearch.fcgi endpoint
  /esearch.fcgi:
    get:
      operationId: pubmedESearch
      summary: Search PubMed database with a keyword and return journals with detailed information
      parameters:
        - name: db
          in: query
          required: true
          schema:
            type: string
            default: pubmed
            description: Database for the search. Use 'pubmed' for PubMed data.
        - name: term
          in: query
          required: true
          schema:
            type: string
            description: Search keyword or phrase.
        - name: sort
          in: query
          schema:
            type: string
            default: pub date
            description: Sort order of the results.
        - name: apiKey
          in: query
          schema:
            type: string
            description: API key for authenticated access.
      responses:
        "200":
          description: Successful response with search results
          content:
            application/xml:
              schema:
                type: object
                properties:
                  result:
                    type: array
                    items:
                      $ref: "#/components/schemas/Journal"
# New esummary.fcgi endpoint
  /esummary.fcgi:
    get:
      operationId: pubmedESummary
      summary: Retrieve detailed information of PubMed articles using their PubMed IDs
      parameters:
        - name: db
          in: query
          required: true
          schema:
            type: string
            default: pubmed
            description: Database for the summary. Use 'pubmed' for PubMed data.
        - name: id
          in: query
          required: true
          schema:
            type: string
            description: Comma-separated list of PubMed IDs to retrieve detailed information.
        - name: retmode
          in: query
          schema:
            type: string
            default: xml
            description: Format of the return data. Defaults to XML.
        - name: apiKey
          in: query
          schema:
            type: string
            description: API key for authenticated access.
      responses:
        "200":
          description: Successful response with detailed article information
          content:
            application/xml:
              schema:
                type: object
                properties:
                  result:
                    type: object
                    additionalProperties:
                      $ref: "#/components/schemas/ArticleDetail"
components:
  schemas:
    Journal:
      type: object
      properties:
        title:
          type: string
          description: Title of the journal article.
        year:
          type: string
          description: Publication year of the journal article.
        issue:
          type: string
          description: Issue number of the journal.
        pages:
          type: string
          description: Page numbers of the journal article.
        # Removed the abstract property
    # New ArticleDetail schema
    ArticleDetail:
      type: object
      properties:
        title:
          type: string
          description: Title of the journal article.
        pubdate:
          type: string
          description: Publication date of the journal article.
        source:
          type: string
          description: Journal name.
        volume:
          type: string
          description: Volume number of the journal.
        issue:
          type: string
          description: Issue number of the journal.
        pages:
          type: string
          description: Page numbers of the journal article.

 

이 OpenAPI 스키마는 NCBI PubMed E-utilities API를 정의하고 있습니다. 이 API는 NCBI(미국 국립 보건원 산하 국립생물공학정보센터)의 데이터베이스에 대한 접근을 제공합니다. 주요 목적은 PubMed 데이터베이스에서 학술 저널의 정보를 검색하고 이를 사용자에게 제공하는 것입니다.

스키마 구성요소

  1. 기본 정보 (Info)
    • title: "NCBI PubMed E-utilities API"
    • description: PubMed를 포함한 NCBI 데이터베이스에 대한 접근을 제공한다고 설명합니다.
    • version: API 버전을 1.0.0으로 명시합니다.
  2. 서버 (Servers)
  3. 경로 (Paths)
    • /esearch.fcgi: PubMed 데이터베이스에서 키워드를 사용한 검색을 실행하는 엔드포인트입니다.
      • parameters: 검색에 사용될 데이터베이스(db), 검색어(term), 정렬방식(sort), API 키(apiKey) 등을 정의합니다.
      • responses: 성공적인 검색 결과를 XML 형식으로 반환합니다.
    • /esummary.fcgi: PubMed ID를 사용하여 상세한 문서 정보를 검색하는 엔드포인트입니다.
      • parameters: 요약할 데이터베이스(db), PubMed ID(id), 반환 데이터 형식(retmode), API 키(apiKey) 등을 정의합니다.
      • responses: 상세한 문서 정보를 XML 형식으로 반환합니다.
  4. 컴포넌트 (Components)
    • schemas: 데이터 구조를 정의하는 스키마입니다.
      • Journal: 저널 문서의 제목, 출판년도, 권, 페이지 정보를 포함합니다.
      • ArticleDetail: 저널 문서의 상세 정보를 포함하며, 제목, 출판일, 저널 이름, 권, 호, 페이지 정보를 제공합니다.

사용 방식

  • 사용자는 /esearch.fcgi 엔드포인트를 통해 PubMed 데이터베이스에서 키워드 기반으로 저널을 검색할 수 있습니다.
  • 검색된 PubMed ID를 /esummary.fcgi 엔드포인트에 입력하여 해당 문서의 상세 정보를 조회할 수 있습니다.

이 API 스키마는 PubMed 데이터에 대한 접근과 검색, 상세 정보 조회를 가능하게 하여 의학 및 생명과학 연구자들에게 유용한 도구를 제공합니다.

 

 

5. 실제 구동 사례

aucte myeloid leukemia에 대한 저널을 찾아보라고 했습니다

 

이렇게 반환한 정보  중에서 하나의 저널에 대해 다시 정보를 호출하면 다음과 같이 깔끔히 정보를 요약해줍니다.

 

실제 원문은 다음과 같습니다. 

 

 

도움이 되셨을까요?