Spaces:
Runtime error
Runtime error
File size: 953 Bytes
66786b8 |
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 |
# -*-coding:utf-8 -*-
"""
Run SELF
"""
import numpy as np
from self.generate import SELF
threshold = 0.7 # 当最近几个指令相似度都很高的时候停止
def main(seed_file, output_file, openai_key, n_human, n_machine, n_instruct, max_iter, max_gen):
instance = SELF(seed_file, openai_key, n_human, n_machine, n_instruct, None)
n_iter = 0
while n_iter < max_iter and instance.n_keep < max_gen:
instance.step()
n_iter +=1
print(f'已生成{instance.n_gen} 可用{instance.n_keep}')
if n_iter >3 and np.average([i['avg_similarity_score'] for i in instance.machine_instruction_data[-5:]] )> threshold:
break
# dump file
instance.dump_file(output_file)
if __name__ == '__main__':
seed_file = './ape/data/seed_task.json'
openai_key ='a'
n_human=2
n_machine=1
n_instruct=5
instance = SELF(seed_file, openai_key, n_human, n_machine, n_instruct, None)
|