能力标签
双重织者
🛠
AI工具

双重织者

基于 Python · 开源免费,本地部署,数据完全自主可控
英文名:TwinWeaver
⭐ 16 Stars 🍴 6 Forks 💻 Python 📄 Apache-2.0 🏷 AI 7.5分
7.5AI 综合评分
EHRLLMPython
✦ AI Skill Hub 推荐

经 AI Skill Hub 精选评估,双重织者 获评「推荐使用」。这款AI工具在功能完整性、社区活跃度和易用性方面表现出色,AI 评分 7.5 分,适合有一定技术背景的用户使用。

📚 深度解析

双重织者 是一款基于 Python 的开源工具,在 GitHub 上收获 0k+ Star,是EHR、LLM、Python领域中的优质开源项目。开源工具的最大优势在于代码完全透明,你可以审计每一行代码的安全性,也可以根据自身需求进行二次开发和定制。

**为什么要使用开源工具而非商业 SaaS?**
对于个人开发者和有隐私需求的用户,本地部署的开源工具意味着数据不离本机,不受第三方服务商的数据政策约束。同时,开源工具通常没有使用次数限制和月度费用,一次安装即可长期使用,对于高频使用场景的总拥有成本(TCO)远低于订阅制商业工具。

**安装与环境准备**
双重织者 依赖 Python 运行环境。建议通过 pyenv(Python)或 nvm(Node.js)管理 Python 版本,避免全局环境污染。对于新手用户,推荐先创建虚拟环境(python -m venv venv && source venv/bin/activate),再安装依赖,这样即使出现问题也可以随时删除虚拟环境重新开始,不影响系统稳定性。

**社区与维护**
GitHub Issue 和 Discussion 是获取帮助的最快渠道。在提问前建议先检查 Closed Issues(已关闭的问题),大多数常见问题都已有解答。遇到 Bug 时,提供 pip list 的输出、完整错误堆栈和最小可复现示例,能显著提高开发者响应速度。AI Skill Hub 将持续追踪 双重织者 的版本更新,及时通知重要功能变化。

📋 工具概览

双重织者 是一款基于 Python 开发的开源工具,专注于 EHR、LLM、Python 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。

GitHub Stars
⭐ 16
开发语言
Python
支持平台
Windows / macOS / Linux
维护状态
轻量级项目,按需更新
开源协议
Apache-2.0
AI 综合评分
7.5 分
工具类型
AI工具
Forks
6

📖 中文文档

以下内容由 AI Skill Hub 根据项目信息自动整理,如需查看完整原始文档请访问底部「原始来源」。

双重织者 是一款基于 Python 开发的开源工具,专注于 EHR、LLM、Python 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。

📌 核心特色
  • 开源免费,支持本地部署,数据完全自主可控
  • 活跃的 GitHub 开源社区,持续迭代更新
  • 提供详细文档和使用示例,新手友好
  • 支持自定义配置,灵活适配不同使用环境
  • 可作为基础组件集成进现有技术栈或进行二次开发
🎯 主要使用场景
  • 本地部署运行,保护数据隐私,满足合规要求
  • 自定义集成到现有系统,扩展技术栈能力
  • 作为开源基础组件进行商业化二次开发
以下安装命令基于项目开发语言和类型自动生成,实际以官方 README 为准。
安装命令
# 方式一:pip 安装(推荐)
pip install twinweaver

# 方式二:虚拟环境安装(推荐生产环境)
python -m venv .venv
source .venv/bin/activate  # Windows: .venv\Scripts\activate
pip install twinweaver

# 方式三:从源码安装(获取最新功能)
git clone https://github.com/MendenLab/TwinWeaver
cd TwinWeaver
pip install -e .

# 验证安装
python -c "import twinweaver; print('安装成功')"
📋 安装步骤说明
  1. 访问 GitHub 仓库页面
  2. 按照 README 文档完成依赖安装
  3. 根据系统环境完成初始化配置
  4. 参考官方示例或文档开始使用
  5. 遇到问题可在 GitHub Issues 中查找解答
以下用法示例由 AI Skill Hub 整理,涵盖最常见的使用场景。
常用命令 / 代码示例
# 命令行使用
twinweaver --help

# 基本用法
twinweaver input_file -o output_file

# Python 代码中调用
import twinweaver

# 示例
result = twinweaver.process("input")
print(result)
以下配置示例基于典型使用场景生成,具体参数请参照官方文档调整。
配置示例
# twinweaver 配置文件示例(config.yml)
app:
  name: "twinweaver"
  debug: false
  log_level: "INFO"

# 运行时指定配置文件
twinweaver --config config.yml

# 或通过环境变量配置
export TWINWEAVER_API_KEY="your-key"
export TWINWEAVER_OUTPUT_DIR="./output"
📑 README 深度解析 真实文档 完整度 75/100 查看 GitHub 原文 →
以下内容由系统直接从 GitHub README 解析整理,保留代码块、表格与列表结构。

简介

<p align="center"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/MendenLab/TwinWeaver/refs/heads/main/docs/images/candidate_dark_bg_jpg.jpg"> <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/MendenLab/TwinWeaver/refs/heads/main/docs/images/candidate_jpg.jpg"> <img alt="TwinWeaver Logo" src="https://raw.githubusercontent.com/MendenLab/TwinWeaver/refs/heads/main/docs/images/candidate_jpg.jpg" width="40%" title="Title"> </picture> </p>

License Python 3.8+ Documentation arXiv

TwinWeaver is a longitudinal framework for LLM-based Patient Digital Twins. It serializes longitudinal patient histories into text, enabling unified event prediction as well as forecasting with large language models (LLMs). This framework transforms structured patient history—including demographics, labs, treatments, and genetics—into a single, human-readable text prompt, enabling LLMs to jointly forecast continuous biomarkers and predict discrete clinical events, initially presented in our preprint "TwinWeaver: An LLM-Based Foundation Model Framework for Pan-Cancer Digital Twins.".

This project is a collaboration between Roche and Helmholtz Munich, as part of the Munich School of Data Science (MUDS) program.

🏗️ Framework Overview

TwinWeaver addresses the challenge of modeling sparse, multi-modal clinical time series by leveraging the generative capabilities of LLMs.

Load your patient data <----- assuming your data is in df_events, df_constant and df_constant_description

dm = DataManager(config=config) dm.load_indication_data(df_events=df_events, df_constant=df_constant, df_constant_description=df_constant_description) dm.process_indication_data() dm.setup_unique_mapping_of_events() dm.setup_hold_out_sets(validation_split=0.1, test_split=0.1) dm.infer_var_types()

Requirements

  • Python 3.8 or higher
  • Core dependencies: pandas, numpy, transformers, scikit-learn

The following sections will explain the tutorials/examples and afterwards the quick start guide.

⚙️ Installation

Install from PyPi

To install the package:

pip install twinweaver

Development Setup

1. Clone the repository and install dependencies:

    git clone https://github.com/MendenLab/TwinWeaver
    cd twinweaver
    pip install -e .
    pip install -r examples/requirements.txt
    pip install pre-commit pytest pytest-cov
    pip install -r docs/requirements.txt
    

2. Install pre-commit hooks: We use pre-commit to ensure code formatting and quality checks run before you commit.

    pip install pre-commit
    pre-commit install
    

Building Documentation

The documentation is built with mkdocs. To preview it locally:

mkdocs serve

💡 Tutorials & Examples

The examples/ directory provides comprehensive tutorials to help you get up and running.

🔰 Core Tutorials

These notebooks cover the primary workflows for most users:

  • 0. Raw Data Preprocessing: examples/data_preprocessing/raw_data_preprocessing.ipynb
  • Start here if you have raw clinical data (e.g., EHR exports). Shows how to transform raw data into the three TwinWeaver dataframes (df_events, df_constant, df_constant_description), including handling death events and other time-to-event outcomes.
  • 1. Basics Overview: examples/01_data_preparation_for_training.ipynb
  • Demonstrates how to convert raw patient data (events, constants, genetics) into the instruction-tuning text format used by TwinWeaver. This is the core step for preparing data for fine-tuning.
  • 2. Inference: examples/02_inference_prompt_preparation.ipynb
  • Shows how to run inference using the TwinWeaver framework, including setting up the data manager and generating prompts.
  • 3. End-to-End Workflow: examples/03_end_to_end_llm_finetuning.ipynb
  • A complete guide covering the entire pipeline from data ingestion to LLM fine-tuning.
  • NOTE: please install the packages required via the exact following line pip install twinweaver[fine-tuning-example] (torch CUDA version might need to be adapted to your system)

🚀 Advanced Usage & Integrations

For users needing custom behavior or specific integrations:

🚀 Quick Start

Here's a minimal example to get you started with TwinWeaver:

```python import pandas as pd

from twinweaver import ( DataManager, Config, DataSplitterForecasting, DataSplitterEvents, ConverterInstruction, DataSplitter, )

Initialize config and set up splitting/prediction variables

config = Config()

<---------------------- CRITICAL CONFIGURATION ---------------------->

We will also use the easier interface that combines both data splitters

data_splitter = DataSplitter(data_splitter_events, data_splitter_forecasting)

Core Components

1. Text Serialization: Transforms multi-modal inputs (diagnoses, laboratory measurements, genetic mutation panels) into a structured textual representation of longitudinal patient trajectories. 2. Unified Task Support: Time-Series Forecasting: Forecasting frequently measured values such as blood biomarkers or vital signs. Landmark Event Prediction: Predicting patient event status (e.g., survival, disease progression) at future time points using a landmarking framework. 3. Flexible Horizon: Supports sampling split times and prediction horizons to avoid overfitting to specific canonical time points.

Contribution Workflow

1. Create a New Branch: Always create a new branch for your feature or fix.

    git checkout -b feature/my-new-feature
    
2. Make Changes: Implement your feature or fix. 3. Run Tests & Linting: Ensure your code passes all tests and pre-commit hooks. 4. Submit a Merge Request: Push your branch to the repository. Open a Merge Request (Pull Request) against the main branch. * Describe your changes clearly in the MR description.

📂 Dataset Types: Instruction vs. Pretraining

TwinWeaver supports two primary data formats, each serving a distinct stage in the model training pipeline:

1. Pretraining Data: Purpose: Continued Pretraining (CPT) to adapt a general-purpose LLM to the clinical domain. Format: A narrative-style serialization of the entire patient history. It does not contain specific questions or answers but rather presents the patient's chronological journey as a continuous text. Goal: Enables the model to learn medical terminology, clinical relationships, and temporal dynamics in an unsupervised manner (next-token prediction). Converter: twinweaver.pretrain.converter_manual_template.ConverterPretrain

2. Instruction Data: Purpose: Supervised Fine-Tuning (SFT) to teach the model to perform specific clinical tasks. Format: Structured into "Input" (Prompt) and "Target" (Completion) pairs. Input: Patient history up to a specific time point + a list of specific questions (e.g., "Forecast the next 3 weeks of hemoglobin values"). Target: The ground truth answers to those questions. Goal: Optimizes the model for specific downstream applications like forecasting and risk stratification. Converter: twinweaver.instruction.converter_manual_instruction.ConverterInstruction

Further details at https://mendenlab.github.io/TwinWeaver/framework/.

🇨🇳 中文文档镜像 AI 翻译 2026-06-10
英文原文章节由系统翻译为中文摘要,便于快速理解。完整原文见上方 "📑 README 深度解析"。
📌 简介

TwinWeaver 是一个用于建模稀疏多模态临床时间序列的框架,利用大语言模型(LLMs)的生成能力来解决这一挑战。

📋 环境依赖

TwinWeaver 需要 Python 3.8 或更高版本,核心依赖项包括 `pandas`、`numpy`、`transformers` 和 `scikit-learn`。

🛠 安装步骤(Docker/pip/源码)

安装 TwinWeaver 可以使用 pip:`pip install twinweaver`。开发环境设置包括克隆仓库、安装依赖项和安装预提交钩子等步骤。

🚀 使用教程

TwinWeaver 提供了多个教程和示例,帮助用户快速上手。核心教程包括原始数据预处理、预训练数据转换等。

⚙️ 配置说明(含 MCP / env)

配置文件包括 MCP、环境变量和关键参数等。初始化配置文件使用 `Config()` 函数。

🔌 API 说明

TwinWeaver 提供了一个易用的接口,用于数据划分和预测等任务。数据划分器使用 `DataSplitter` 类实现。

🔄 工作流/模块

TwinWeaver 的核心组件包括文本序列化和统一任务支持。文本序列化将多模态输入转换为结构化的文本表示,用于描述患者的长期轨迹。统一任务支持包括时间序列预测等功能。

🎯 aiskill88 AI 点评 A 级 2026-06-07

高质量的医疗数据处理工具

📚 实用指南(长尾问题)
适合谁
  • 构建企业知识库 / RAG 检索应用的团队
最佳实践
  • 先在测试环境跑通最小用例,再接入生产数据
常见错误
  • API key 直接提交到 git 仓库(请用 .env 并加入 .gitignore)
  • Python 依赖冲突:建议用 venv / uv 隔离环境
部署方案
  • 云端托管:可放在 Vercel / Railway / Fly.io 等 PaaS 平台
相关搜索
TwinWeaver 中文教程TwinWeaver 安装报错怎么办TwinWeaver 与同类工具对比TwinWeaver 最佳实践TwinWeaver 适合谁用

⚡ 核心功能

👥 适合谁
  • 构建企业知识库 / RAG 检索应用的团队
⭐ 最佳实践
  • 先在测试环境跑通最小用例,再接入生产数据
⚠️ 常见错误
  • API key 直接提交到 git 仓库(请用 .env 并加入 .gitignore)
  • Python 依赖冲突:建议用 venv / uv 隔离环境

👥 适合人群

AI 技术爱好者研究人员和学生开发者和工程师技术创业者

🎯 使用场景

  • 本地部署运行,保护数据隐私,满足合规要求
  • 自定义集成到现有系统,扩展技术栈能力
  • 作为开源基础组件进行商业化二次开发

⚖️ 优点与不足

✅ 优点
  • +Apache-2.0 协议,可免费商用
  • +完全开源免费,无授权费用
  • +本地部署,数据完全自主可控
  • +开发者社区支持,遇问题可查可问
⚠️ 不足
  • 安装和初始配置可能需要一定技术基础
  • 功能完整性通常不如成熟商业产品
  • 技术支持主要依赖开源社区,响应速度不稳定
⚠️ 使用须知

AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。

建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。

📄 License 说明

✅ Apache 2.0 — 宽松开源协议,可商用,需保留版权声明和 NOTICE 文件,含专利授权条款。

🔗 相关工具推荐

📚 相关教程推荐
📰 相关 AI 新闻
🗺️ 相关解决方案
🧩 你可能还需要
基于当前 Skill 的能力图谱,自动补全的工具组合

❓ 常见问题 FAQ

TwinWeaver 是一款Python开发的AI辅助工具。开源AI工具:A library for converting EHR data into LLM ingestible text.。⭐16 · Python 主要应用场景包括:医疗数据处理。
💡 AI Skill Hub 点评

AI Skill Hub 点评:双重织者 的核心功能完整,质量良好。对于AI 技术爱好者来说,这是一个值得纳入个人工具库的选择。建议先在非生产环境试用,再逐步推广。

📚 深入学习 双重织者
查看分步骤安装教程和完整使用指南,快速上手这款工具
🌐 原始信息
原始名称 TwinWeaver
原始描述 开源AI工具:A library for converting EHR data into LLM ingestible text.。⭐16 · Python
Topics EHRLLMPython
GitHub https://github.com/MendenLab/TwinWeaver
License Apache-2.0
语言 Python
🔗 原始来源
🐙 GitHub 仓库  https://github.com/MendenLab/TwinWeaver 🌐 官方网站  https://mendenlab.github.io/TwinWeaver/

收录时间:2026-06-07 · 更新时间:2026-06-08 · License:Apache-2.0 · AI Skill Hub 不对第三方内容的准确性作法律背书。