본문으로 건너뛰기
Skillpedia
분석 및 스프레드시트5.8k · #14674

batch-processing-clinical-text

하는 일

이 스킬은 대량의 임상 노트를 사용자의 기기에서 일괄 처리하며, 진행 상황 추적과 저장된 체크포인트를 제공합니다. 수천 건의 문서에 대해 규모 있게 개체 추출이나 비식별화가 필요한 팀을 위한 스킬입니다.

사용하는 경우

  • ✓노트 한 건이 아니라 임상 노트 폴더나 데이터 세트를 처리해야 할 때.
  • ✓중간에 멈춰도 이어서 실행할 수 있는 긴 일괄 작업이 필요할 때.
  • ✓모든 결과를 메모리에 담지 않고 JSONL 출력 파일에 쓰고 싶을 때.

스킬 링크

https://github.com/maziyarpanahi/openmed/blob/master/skills/batch-processing-clinical-text/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/maziyarpanahi/openmed/blob/master/skills/batch-processing-clinical-text/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“이 폴더에 있는 퇴원 노트 5,000건을 제 컴퓨터에서 비식별화해 주세요. 작업이 중간에 멈추면 이어서 할 수 있게 해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트는 코퍼스를 샤드로 나누고, 로컬 모델로 각 노트를 처리하며, 체크포인트를 기록합니다. 재시작하면 이어서 쓸 수 있는 추가 전용(append-only) 파일에 결과를 씁니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Batch processing clinical text

openmed.processing runs OpenMed over many documents efficiently, with progress tracking, per-item error isolation, and streaming. It runs fully on-device: the corpus, the model, and the output never leave the host. This skill shows a resumable runner — sharded, checkpointed, append-only JSONL — that you can restart without reprocessing.

When to use this skill

For corpora, folders, or datasets — anything beyond a handful of notes. For a single note, just call openmed.analyze_text / deidentify directly (extracting-clinical-entities, deidentifying-clinical-text). For an always-on HTTP service, see serving-openmed-rest-api.

Quick start

from openmed import process_batch

texts = ["Patient has type 2 diabetes.", "No acute distress. BP 120/80."]
result = process_batch(texts, model_name="disease_detection_superclinical")

print(result.summary())          # PHI-safe counts + timing
print(result.successful_items, "/", result.total_items)
for item in result.get_successful_results():
    print(item.id, item.result.to_dict()["entities"])   # spans only; avoid raw text in logs

process_batch(...) is a thin wrapper over BatchProcessor. Real signatures (openmed/processing/batch.py):

  • process_batch(texts, model_name="disease_detection_superclinical", ids=None, config=None, progress_callback=None, on_progress=None, **kwargs) -> BatchResult
  • BatchProcessor(model_name=..., operation="analyze_text", batch_size=8, continue_on_error=True, **analyze_kwargs) with operation ∈ {"analyze_text", "extract_pii", "deidentify"}.
  • BatchItem(id, text, source=None, metadata=None)
  • BatchResult — .items, .total_items, .successful_items, .failed_items, .success_rate, .average_processing_time, .summary(), .to_dict(), .get_successful_results(), .get_failed_results().
  • BatchItemResult — .id, .result (a PredictionResult/DeidentificationResult), .error, .processing_time, .source, .success, .to_dict().

Choosing the operation

from openmed import BatchProcessor

# NER (default)
ner = BatchProcessor(model_name="disease_detection_superclinical")          # operation="analyze_text"
# Detect PHI spans
pii = BatchProcessor(operation="extract_pii", model_name="OpenMed/OpenMed-PII-SuperClinical-Small-44M-v1")
# De-identify (rewrites text)
deid = BatchProcessor(operation="deidentify", method="mask", confidence_threshold=0.7)

BatchProcessor reuses one model loader across items (and a cached privacy filter for PII ops), so a single processor over many texts is far cheaper than many one-off calls.

Streaming + PHI-safe progress

from openmed.processing import BatchProcessor, BatchProgress

proc = BatchProcessor(operation="deidentify", method="mask", batch_size=16)

def on_progress(p: BatchProgress) -> None:   # frozen record: completed/total/current_index/elapsed
    if p.completed % 500 == 0:
        print(f"{p.completed}/{p.total} ({p.elapsed:.1f}s)")   # NO PHI

for item in proc.iter_process(texts, ids=doc_ids, on_progress=on_progress):
    write_jsonl(item)   # one result at a time — constant memory for huge corpora

on_progress receives only counts/timing (never text), so it is safe to log. iter_process yields BatchItemResults without holding the whole corpus.

Workflow

  1. De-identify upstream if the corpus has PHI, or key everything by stable internal ids so logs/output never carry identifiers.
  2. Pick the operation + model — one BatchProcessor per operation (analyze_text / extract_pii / deidentify); reuse it across all items so the loader is shared.
  3. Shard the corpus into independent partitions writing to separate JSONL files; run shards as separate processes for parallelism.
  4. Stream with iter_process and append each BatchItemResult to JSONL (flush per item) — that append-only file is your checkpoint.
  5. Track progress with the PHI-safe on_progress callback (counts/timing only).
  6. Re-run to resume: skip ids already present in the output; with continue_on_error=True, failures are recorded, not raised.
  7. Reconcile via result.get_failed_results() / a failures pass, then hand JSONL to the downstream consumer.

A resumable batch runner

import json
from pathlib import Path
from openmed.processing import BatchProcessor

def run_resumable(texts, ids, out_path: Path, *, operation="deidentif
자주 묻는 질문

데이터가 컴퓨터 밖으로 나가나요?

아니요. 코퍼스, 모델, 출력이 모두 로컬 기기에 남습니다.

문서 한 건이 실패하면 어떻게 되나요?

일괄 처리는 항목별로 오류를 분리하므로, 문제가 있는 문서 한 건이 전체 실행을 멈추지 않습니다.

노트 한 건이면 더 간단한가요?

네. 노트 한 건에는 직접 분석이나 비식별화 호출이 더 알맞습니다.

상세 정보

작성자의 원본 설명

Run large-scale batch NER, PII extraction, or de-identification over many clinical notes on-device with OpenMed, with sharding, checkpointing, resumability, and append-only JSONL output. Use when the user needs to process a corpus or folder of notes, de-identify a dataset, run NER over thousands of documents, build a resumable batch pipeline, or stream results to JSONL without holding everything in memory. Covers process_batch / BatchProcessor / BatchItem / BatchResult, the operation= selector (analyze_text | extract_pii | deidentify), iter_process streaming, the PHI-safe on_progress callback,

repo: maziyarpanahi/openmed

인기도

GitHub 스타
5.8k
순위
#14674
라이선스
Apache-2.0
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬