feat: Embedding FP16 开关 + 团队成员信息完善 + gitignore 更新
- infer.py: 新增 emb_fp16 CONFIG 选项(默认 False),Embedding 权重可 FP16 省查表带宽 - CLAUDE.md: 补充团队成员表(AI Studio 用户名→真实姓名) - README.md: 新增团队区块,标注三人参赛身份 - .gitignore: 排除 DVC/HF 工具自动生成的元数据文件 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -18,5 +18,11 @@ eval.zip
|
||||
.vscode/
|
||||
.idea/
|
||||
|
||||
# DVC & 工具自动生成
|
||||
.msc
|
||||
.mv
|
||||
dataset_infos.json
|
||||
.codegraph/
|
||||
|
||||
# 密钥
|
||||
.env
|
||||
|
||||
@@ -219,8 +219,16 @@ Baseline 数据:推理 229s,AUC 0.759,PCOC 1.110,得分 25.85。
|
||||
| 06/14 | 16 | 55.19 | 0.7526 | 1.059 | 102.2s | + Expert 合并 th=0.97 | 阈值过高 |
|
||||
| 06/12 | 3 | 43.55 | 0.7525 | 1.059 | 152s | + FP16 量化 | |
|
||||
|
||||
### 团队成员
|
||||
|
||||
| AI Studio 用户名 | 真实姓名 |
|
||||
|------------------|----------|
|
||||
| qianban139 | 张君硕 |
|
||||
| sidny1988 | 谢松熹 |
|
||||
| (队长账号) | 刘航宇 |
|
||||
|
||||
### 竞品参考
|
||||
|
||||
| 用户 | 最高分 | 耗时 | AUC | PCOC |
|
||||
|------|--------|------|-----|------|
|
||||
| qianban139 | **67.87** | 47.9s | 0.7525 | 1.059 |
|
||||
| qianban139(张君硕) | **67.87** | 47.9s | 0.7525 | 1.059 |
|
||||
|
||||
@@ -4,6 +4,14 @@
|
||||
|
||||
[](https://gitea.liuhangyv.top/Serendipity/CTI-Inference-Opt)
|
||||
|
||||
## 团队
|
||||
|
||||
| 成员 | AI Studio 用户名 | 角色 |
|
||||
|------|------------------|------|
|
||||
| 刘航宇 | — | 队长 |
|
||||
| 张君硕 | qianban139 | 队员 |
|
||||
| 谢松熹 | sidny1988 | 队员 |
|
||||
|
||||
## 赛题
|
||||
|
||||
> [比赛主页](https://aistudio.baidu.com/competition/detail/1461) · [大赛官网](http://cti.baidu.com) · [提交结果](https://aistudio.baidu.com/competition/detail/1461/0/submit-result) · [比赛规则](https://aistudio.baidu.com/competition/detail/1461/0/rules)
|
||||
|
||||
+9
-4
@@ -34,6 +34,7 @@ except Exception:
|
||||
# ============================================================
|
||||
CONFIG = {
|
||||
"fp16": True, # True=半精度推理;False=FP32 参考跑(确立 AUC 天花板)
|
||||
"emb_fp16": False, # True=Embedding 也 FP16(省 ~10GB 显存带宽,AUC 可能微降)
|
||||
"keep_fp32_modules": (), # fp16 下仍保留 FP32 的子模块名前缀,如 ("linear",)
|
||||
"expert_merge": True, # 是否做 expert 权重相似度合并
|
||||
"merge_threshold": 0.90, # 合并的余弦相似度阈值
|
||||
@@ -700,14 +701,18 @@ def load_model(ckpt_path, device='cuda:0'):
|
||||
|
||||
if CONFIG["fp16"]:
|
||||
model = model.half()
|
||||
# Embedding 始终保留 FP32(int 索引查表,不受浮点精度影响)
|
||||
model.rep_encoder.emb = model.rep_encoder.emb.to(torch.float32)
|
||||
# Embedding FP16:省 ~50% 查表带宽(5M×512: 10GB→5GB),AUC 可能微降
|
||||
if not CONFIG.get("emb_fp16", False):
|
||||
model.rep_encoder.emb = model.rep_encoder.emb.to(torch.float32)
|
||||
# 额外保留 FP32 的精度敏感模块(输入/输出自动转换)
|
||||
for name, module in model.named_modules():
|
||||
if name and any(name.startswith(p) for p in CONFIG["keep_fp32_modules"]):
|
||||
_force_fp32_io(module)
|
||||
print(f"[INFO] FP16 on; FP32-kept: "
|
||||
f"{('rep_encoder.emb',) + tuple(CONFIG['keep_fp32_modules'])}")
|
||||
kept = []
|
||||
if not CONFIG.get("emb_fp16", False):
|
||||
kept.append("rep_encoder.emb")
|
||||
kept.extend(CONFIG["keep_fp32_modules"])
|
||||
print(f"[INFO] FP16 on; FP32-kept: {tuple(kept)}")
|
||||
else:
|
||||
model = model.float()
|
||||
print("[INFO] FP32 reference (no half)")
|
||||
|
||||
Reference in New Issue
Block a user