File size: 858 Bytes
259f28d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import json
import sys
import os

# 要删除的字段
fields_to_remove = [
    "corda_config",
    "eva_config",
    "exclude_modules",
    "trainable_token_indices",
    "lora_bias"
]

def clean_config(file_path):
    if not os.path.exists(file_path):
        print(f"❌ 文件不存在: {file_path}")
        return

    with open(file_path, "r", encoding="utf-8") as f:
        config = json.load(f)

    for field in fields_to_remove:
        config.pop(field, None)

    with open(file_path, "w", encoding="utf-8") as f:
        json.dump(config, f, indent=2, ensure_ascii=False)

    print(f"✅ 已清理并保存: {file_path}")

if __name__ == "__main__":
    if len(sys.argv) < 2:
        print("用法: python clean_adapter_config.py <路径/adapter_config.json>")
        sys.exit(1)

    config_path = sys.argv[1]
    clean_config(config_path)