189 lines
4.4 KiB
Markdown
Executable File
189 lines
4.4 KiB
Markdown
Executable File
# V14 迁移计划与问答
|
|
|
|
**日期**: 2026-04-18 20:27
|
|
**版本**: V14 → V14.1
|
|
|
|
---
|
|
|
|
## 问题1: 数据层加载目的和使用方式
|
|
|
|
### 1.1 加载目的
|
|
|
|
| 数据文件 | 加载目的 | 使用场景 |
|
|
|:---|:---|:---|
|
|
| `scientific_chunks.json` (43,561别名) | **实体标准化** | 将不同写法的同一实体统一为标准名 |
|
|
| `gene_alias.json` (17,618基因) | **基因别名扩展** | 识别基因的所有可能写法 |
|
|
| `relationships_by_category_final.json` (788模式) | **关系抽取** | 扩展关系匹配能力 |
|
|
| `all_dic.json` (238万实体) | **实体验证** | 验证识别的实体是否有效 |
|
|
|
|
### 1.2 使用方式
|
|
|
|
**场景1: 实体标准化**
|
|
```python
|
|
# 原文: "sucrose transporter 5 was expressed in leaves"
|
|
# 识别到实体: "sucrose transporter 5"
|
|
|
|
# 使用scientific_chunks.json标准化
|
|
alias_map = {
|
|
'sucrose transporter 5': 'SUC5',
|
|
'suc transporter 5': 'SUC5',
|
|
'at1g71890': 'SUC5',
|
|
}
|
|
|
|
# 标准化后
|
|
entity.name = "sucrose transporter 5"
|
|
entity.name_resolved = "SUC5" # 标准名
|
|
```
|
|
|
|
**场景2: 基因别名扩展**
|
|
```python
|
|
# 识别到基因: "SUC5"
|
|
|
|
# 使用gene_alias.json扩展别名
|
|
gene_aliases = {
|
|
'SUC5': ['ATSUC5', 'SUC5', 'AT1G71890']
|
|
}
|
|
|
|
# 扩展后
|
|
entity.aliases = ['ATSUC5', 'SUC5', 'AT1G71890']
|
|
```
|
|
|
|
**场景3: 关系抽取**
|
|
```python
|
|
# 使用788种PC模式匹配关系
|
|
patterns = [
|
|
'induced by', 'regulated by', 'activated by',
|
|
'localized to', 'expressed in', ... # 788种
|
|
]
|
|
|
|
# 匹配: "SUC5 was induced by drought"
|
|
# 结果: relation="induced_by"
|
|
```
|
|
|
|
### 1.3 是否与提取数据冲突?
|
|
|
|
**答案: 不会冲突,而是增强**
|
|
|
|
```
|
|
V14提取流程:
|
|
├─ 文本解析 (MinerU)
|
|
├─ 实体识别 (V14规则)
|
|
├─ **实体标准化 (PC数据层)** ← 增强
|
|
├─ 关系抽取 (V14规则 + PC模式) ← 增强
|
|
├─ **消歧 (PC别名)** ← 增强
|
|
└─ 输出
|
|
```
|
|
|
|
**示例**:
|
|
```
|
|
原文: "suc transporter 5 was up-regulated by stress"
|
|
|
|
V14基础识别:
|
|
- 实体: "suc transporter 5" (gene)
|
|
- 关系: "was up-regulated by"
|
|
|
|
PC数据层增强后:
|
|
- 实体: "suc transporter 5" → 标准化为 "SUC5"
|
|
- 别名: ["ATSUC5", "SUC5", "AT1G71890"]
|
|
- 关系: "was up-regulated by" → 标准化为 "up_regulated_by"
|
|
```
|
|
|
|
---
|
|
|
|
## 问题2: LLM定义生成基于什么?
|
|
|
|
### 2.1 当前V14实现
|
|
|
|
**基于模板** (非LLM):
|
|
```python
|
|
templates = {
|
|
'gene': "A gene encoding {name}, involved in biological processes.",
|
|
'tissue': "A plant tissue where {name} is expressed.",
|
|
}
|
|
|
|
# 生成: "A gene encoding SUC5, involved in biological processes."
|
|
```
|
|
|
|
### 2.2 PC的LLM实现
|
|
|
|
**基于检索到的上下文**:
|
|
```python
|
|
def generate_definition(entity_name, context):
|
|
"""
|
|
基于文本上下文调用LLM生成定义
|
|
不是基于LLM预训练知识,而是基于当前文献的上下文
|
|
"""
|
|
prompt = f"""
|
|
基于以下文本,生成"{entity_name}"的定义:
|
|
|
|
文本: {context}
|
|
|
|
要求: 基于文本内容生成,不要添加外部知识。
|
|
"""
|
|
return llm.generate(prompt)
|
|
|
|
# 示例:
|
|
# 文本: "SUC5 encodes a sucrose/H+ symporter that facilitates
|
|
# sucrose transport in phloem..."
|
|
#
|
|
# 生成: "SUC5 encodes a sucrose/H+ symporter involved in phloem loading."
|
|
```
|
|
|
|
### 2.3 关键区别
|
|
|
|
| 方式 | 基于 | 优点 | 缺点 |
|
|
|:---|:---|:---|:---|
|
|
| **V14模板** | 预定义模板 | 快速、确定、成本低 | 通用、无文献特异性 |
|
|
| **PC LLM** | 检索到的文本上下文 | 文献特异性、准确 | 慢、成本高 |
|
|
|
|
**建议**: V14可以升级为基于检索的LLM生成,但保持模板作为fallback。
|
|
|
|
---
|
|
|
|
## 问题3: 被动转主动映射迁移
|
|
|
|
### 3.1 我的建议: ✅ 直接迁移PC的
|
|
|
|
**原因**:
|
|
1. PC的映射已经经过验证
|
|
2. 14个规则覆盖常见情况
|
|
3. 无需重新发明轮子
|
|
|
|
### 3.2 PC的完整映射
|
|
|
|
```python
|
|
passive_to_active = {
|
|
# 调控关系
|
|
'induced by': 'induces',
|
|
'regulated by': 'regulates',
|
|
'is regulated by': 'regulates',
|
|
'activated by': 'activates',
|
|
'controlled by': 'controls',
|
|
'mediated by': 'mediates',
|
|
'inhibited by': 'inhibits',
|
|
|
|
# 因果关系
|
|
'caused by': 'causes',
|
|
'affected by': 'affects',
|
|
|
|
# 编码关系
|
|
'encoded by': 'encodes',
|
|
|
|
# 生产关系
|
|
'produced by': 'produces',
|
|
|
|
# 需求关系
|
|
'required for': 'requires',
|
|
|
|
# 定位关系
|
|
'localized to': 'localizes to',
|
|
|
|
# 表达关系
|
|
'expressed in': 'expressed in',
|
|
}
|
|
```
|
|
|
|
### 3.3 迁移实现
|
|
|
|
现在执行迁移到V14:
|