使用LangExtract的医疗文本处理功能可以快速实现这一目标。具体操作步骤如下:
- 准备提示词:明确指定需要提取的字段,例如
"Extract medication names, dosages, and administration routes from clinical notes."
- 输入医疗文本:将包含药物信息的临床笔记作为输入
- 调用提取函数:
result = lx.extract(text, prompt=prompt, model="gemini-2.5-pro")
(推荐使用性能更强的pro模型)
执行后输出结果将包含结构化数据,如:{"entity": "Metformin", "dosage": "500 mg", "route": "orally"}
。对于批量处理,可保存为JSONL格式文件,或生成HTML可视化文件便于查看。
This answer comes from the articleLangExtract: open source tools to extract structured data from textThe