forked from datawhalechina/self-llm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontributors_tool.py
39 lines (30 loc) · 977 Bytes
/
contributors_tool.py
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
38
39
import json
import re
import pprint
with open('./README.md', 'r') as f:
readme = f.read()
with open('./contributors.json', 'r') as f:
contributors = json.load(f)
# task清零
keys = contributors.keys()
for key in keys:
contributors[key]['task_num'] = 0
tasks = readme.split('\n')
tasks = [task for task in tasks if '@' in task][:-1]
# 微调任务+2,普通任务+1
for task in tasks:
name = task.split('@')[1]
if name not in keys:
continue
if "Lora" in task:
contributors[name]['task_num'] += 2
else:
contributors[name]['task_num'] += 1
contributors['不要葱姜蒜']['task_num'] += 300
contributors['Logan Zou']['task_num'] += 300
# 排序
contributors = dict(sorted(contributors.items(), key=lambda x: x[1]['task_num'], reverse=True))
with open('./contributors.json', 'w') as f:
json.dump(contributors, f, indent=4, ensure_ascii=False)
for key, value in contributors.items():
print(f'- {value["info"]}')