|
@@ -11,13 +11,13 @@ from tqdm import tqdm
|
|
|
image_tag = "<image>"
|
|
image_tag = "<image>"
|
|
|
|
|
|
|
|
system = """
|
|
system = """
|
|
|
-根据用户在社交平台上的姓名/昵称和头像,分析用户的性别倾向;
|
|
|
|
|
|
|
+根据中老年用户在社交平台上的姓名/昵称和头像,分析其性别倾向;
|
|
|
先基于姓名/昵称分析,再基于头像分析;
|
|
先基于姓名/昵称分析,再基于头像分析;
|
|
|
当头像不可用时,仅基于姓名/昵称分析;
|
|
当头像不可用时,仅基于姓名/昵称分析;
|
|
|
直接返回[男性|女性|未知],不要返回多余的信息。
|
|
直接返回[男性|女性|未知],不要返回多余的信息。
|
|
|
"""
|
|
"""
|
|
|
system = system.replace("\n", "")
|
|
system = system.replace("\n", "")
|
|
|
-prompt = "姓名/昵称:%s,头像:%s"
|
|
|
|
|
|
|
+prompt = "姓名/昵称:%s, 头像:%s"
|
|
|
|
|
|
|
|
|
|
|
|
|
# LLaMA-Factory 训练模版
|
|
# LLaMA-Factory 训练模版
|
|
@@ -54,10 +54,10 @@ def get_conversation(row):
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-def process(input_file, output_file):
|
|
|
|
|
|
|
+def process(input_file, output_file, random_state):
|
|
|
conversation_list = []
|
|
conversation_list = []
|
|
|
df = pd.read_csv(input_file)
|
|
df = pd.read_csv(input_file)
|
|
|
- df = shuffle(df)
|
|
|
|
|
|
|
+ df = shuffle(df, random_state=random_state)
|
|
|
for index, row in tqdm(df.iterrows(), total=len(df)):
|
|
for index, row in tqdm(df.iterrows(), total=len(df)):
|
|
|
conversation_list.append(get_conversation(row))
|
|
conversation_list.append(get_conversation(row))
|
|
|
if conversation_list:
|
|
if conversation_list:
|
|
@@ -69,10 +69,11 @@ if __name__ == '__main__':
|
|
|
parser = argparse.ArgumentParser()
|
|
parser = argparse.ArgumentParser()
|
|
|
parser.add_argument('--input_file', required=True, help='input files')
|
|
parser.add_argument('--input_file', required=True, help='input files')
|
|
|
parser.add_argument('--output_file', required=True, help='output file')
|
|
parser.add_argument('--output_file', required=True, help='output file')
|
|
|
|
|
+ parser.add_argument('--random_state', default=42, type=int, help='random state')
|
|
|
args = parser.parse_args()
|
|
args = parser.parse_args()
|
|
|
print('\n\n')
|
|
print('\n\n')
|
|
|
print(args)
|
|
print(args)
|
|
|
print('\n\n')
|
|
print('\n\n')
|
|
|
|
|
|
|
|
#
|
|
#
|
|
|
- process(args.input_file, args.output_file)
|
|
|
|
|
|
|
+ process(args.input_file, args.output_file, args.random_state)
|