lihuigu commited on
Commit
b6336ac
·
1 Parent(s): 4117eaa

update idea generate by bs

Browse files
.gitignore CHANGED
@@ -13,7 +13,9 @@
13
  datasets
14
  **/*.log
15
  assets/data/scipip_neo4j_clean_backup.json
16
- assets/paper/
 
 
17
  tmp
18
  test/
19
  # configs
 
13
  datasets
14
  **/*.log
15
  assets/data/scipip_neo4j_clean_backup.json
16
+ src/utils/scipdf/pdf/pdffigures2/
17
+ assets/paper
18
+ assets/model
19
  tmp
20
  test/
21
  # configs
src/generator.py CHANGED
@@ -9,7 +9,7 @@ from loguru import logger
9
  import warnings
10
  import time
11
  import os
12
-
13
  warnings.filterwarnings("ignore")
14
 
15
 
@@ -198,10 +198,6 @@ class IdeaGenerator:
198
  "initial_idea": idea,
199
  "filtered_idea": idea_filtered,
200
  }
201
- print("=====")
202
- print(idea_modified)
203
- print("=====")
204
- exit()
205
  return message_input, idea_modified, median
206
 
207
  def generate_by_inspiration(
@@ -252,7 +248,7 @@ class IdeaGenerator:
252
  self.generate_with_cue_words_ins_bs(background)
253
  )
254
  else:
255
- logger.info("{} using brainstorm_{} with cue words.".format(mode_name, bs_mode))
256
  (
257
  message_input,
258
  problem,
@@ -308,14 +304,14 @@ def main(ctx):
308
  )
309
  @click.option(
310
  "--brainstorm-mode",
311
- default="mode_a",
312
  type=str,
313
  required=True,
314
  help="Choose your brainstorm mode (mode_a: no brainstorm, mode_b: brainstorm for idea generation, mode_c: brainstorm for idea generation and retrival)",
315
  )
316
  @click.option(
317
  "--use-cue-words",
318
- default=True,
319
  type=bool,
320
  required=True,
321
  help="Use cue words in generation",
@@ -327,27 +323,6 @@ def main(ctx):
327
  required=True,
328
  help="Use inspiration in generation",
329
  )
330
- @click.option(
331
- "--llms-api",
332
- default=None,
333
- type=str,
334
- required=False,
335
- help="The LLMS API alias used. If you do not have separate APIs for summarization and generation, you can use this unified setting. This option is ignored when setting the API to be used by summarization and generation separately",
336
- )
337
- @click.option(
338
- "--sum-api",
339
- default=None,
340
- type=str,
341
- required=False,
342
- help="The LLMS API aliases used for summarization. When used, it will invalidate --llms-api",
343
- )
344
- @click.option(
345
- "--gen-api",
346
- default=None,
347
- type=str,
348
- required=False,
349
- help="The LLMS API aliases used for generation. When used, it will invalidate --llms-api",
350
- )
351
  @click.option(
352
  "--num",
353
  default=100,
@@ -356,6 +331,8 @@ def main(ctx):
356
  help="The number of papers you want to process",
357
  )
358
  def backtracking(config_path, ids_path, retriever_name, brainstorm_mode, use_cue_words, use_inspiration, num, **kwargs):
 
 
359
  # Configuration
360
  config = ConfigReader.load(config_path, **kwargs)
361
  logger.add(
@@ -518,7 +495,7 @@ def backtracking(config_path, ids_path, retriever_name, brainstorm_mode, use_cue
518
  )
519
  @click.option(
520
  "--brainstorm-mode",
521
- default="mode_a",
522
  type=str,
523
  required=True,
524
  help="Choose your brainstorm mode (mode_a: no brainstorm, mode_b: brainstorm for idea generation, mode_c: brainstorm for idea generation and retrival)",
@@ -530,27 +507,6 @@ def backtracking(config_path, ids_path, retriever_name, brainstorm_mode, use_cue
530
  required=True,
531
  help="Use inspiration in generation",
532
  )
533
- @click.option(
534
- "--llms-api",
535
- default=None,
536
- type=str,
537
- required=False,
538
- help="The LLMS API alias used. If you do not have separate APIs for summarization and generation, you can use this unified setting. This option is ignored when setting the API to be used by summarization and generation separately",
539
- )
540
- @click.option(
541
- "--sum-api",
542
- default=None,
543
- type=str,
544
- required=False,
545
- help="The LLMS API aliases used for summarization. When used, it will invalidate --llms-api",
546
- )
547
- @click.option(
548
- "--gen-api",
549
- default=None,
550
- type=str,
551
- required=False,
552
- help="The LLMS API aliases used for generation. When used, it will invalidate --llms-api",
553
- )
554
  @click.option(
555
  "--num",
556
  default=100,
@@ -559,6 +515,8 @@ def backtracking(config_path, ids_path, retriever_name, brainstorm_mode, use_cue
559
  help="The number of data you want to process",
560
  )
561
  def new_idea(config_path, ids_path, retriever_name, brainstorm_mode, use_inspiration, num, **kwargs):
 
 
562
  logger.add(
563
  "log/generate_{}_{}.log".format(time.time(), retriever_name), level="DEBUG"
564
  ) # 添加文件输出
 
9
  import warnings
10
  import time
11
  import os
12
+ from utils.hash import check_env, check_embedding
13
  warnings.filterwarnings("ignore")
14
 
15
 
 
198
  "initial_idea": idea,
199
  "filtered_idea": idea_filtered,
200
  }
 
 
 
 
201
  return message_input, idea_modified, median
202
 
203
  def generate_by_inspiration(
 
248
  self.generate_with_cue_words_ins_bs(background)
249
  )
250
  else:
251
+ logger.info("{} using brainstorm_{} without cue words.".format(mode_name, bs_mode))
252
  (
253
  message_input,
254
  problem,
 
304
  )
305
  @click.option(
306
  "--brainstorm-mode",
307
+ default="mode_c",
308
  type=str,
309
  required=True,
310
  help="Choose your brainstorm mode (mode_a: no brainstorm, mode_b: brainstorm for idea generation, mode_c: brainstorm for idea generation and retrival)",
311
  )
312
  @click.option(
313
  "--use-cue-words",
314
+ default=False,
315
  type=bool,
316
  required=True,
317
  help="Use cue words in generation",
 
323
  required=True,
324
  help="Use inspiration in generation",
325
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
326
  @click.option(
327
  "--num",
328
  default=100,
 
331
  help="The number of papers you want to process",
332
  )
333
  def backtracking(config_path, ids_path, retriever_name, brainstorm_mode, use_cue_words, use_inspiration, num, **kwargs):
334
+ check_env()
335
+ check_embedding()
336
  # Configuration
337
  config = ConfigReader.load(config_path, **kwargs)
338
  logger.add(
 
495
  )
496
  @click.option(
497
  "--brainstorm-mode",
498
+ default="mode_c",
499
  type=str,
500
  required=True,
501
  help="Choose your brainstorm mode (mode_a: no brainstorm, mode_b: brainstorm for idea generation, mode_c: brainstorm for idea generation and retrival)",
 
507
  required=True,
508
  help="Use inspiration in generation",
509
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
510
  @click.option(
511
  "--num",
512
  default=100,
 
515
  help="The number of data you want to process",
516
  )
517
  def new_idea(config_path, ids_path, retriever_name, brainstorm_mode, use_inspiration, num, **kwargs):
518
+ check_env()
519
+ check_embedding()
520
  logger.add(
521
  "log/generate_{}_{}.log".format(time.time(), retriever_name), level="DEBUG"
522
  ) # 添加文件输出
src/pages/button_interface.py CHANGED
@@ -73,12 +73,13 @@ class Backend(object):
73
  res += "\n"
74
  return res, result["related_paper"]
75
 
76
- def literature2initial_ideas_callback(self, background, retrieved_literature, json_strs=None):
77
  if json_strs is not None:
78
  json_contents = json.loads(json_strs)
79
  return json_contents["median"]["filtered_idea"]
80
  else:
81
  self.idea_generator.paper_list = retrieved_literature
 
82
  if self.use_inspiration:
83
  message_input, idea_modified, median = (
84
  self.idea_generator.generate_by_inspiration(
 
73
  res += "\n"
74
  return res, result["related_paper"]
75
 
76
+ def literature2initial_ideas_callback(self, background, brainstorms, retrieved_literature, json_strs=None):
77
  if json_strs is not None:
78
  json_contents = json.loads(json_strs)
79
  return json_contents["median"]["filtered_idea"]
80
  else:
81
  self.idea_generator.paper_list = retrieved_literature
82
+ self.idea_generator.brainstorm = brainstorms
83
  if self.use_inspiration:
84
  message_input, idea_modified, median = (
85
  self.idea_generator.generate_by_inspiration(
src/pages/one_click_generation.py CHANGED
@@ -119,7 +119,7 @@ def generate_ideas(backend, background):
119
 
120
  with st.spinner(text="Generating initial ideas..."):
121
  msg = "My initial ideas are:"
122
- initial_ideas, final_ideas = backend.literature2initial_ideas_callback(background, related_works_intact)
123
  st.session_state.messages.append({"role": "assistant", "content": msg})
124
  st.chat_message("assistant").write(msg)
125
  st.session_state.messages.append({"role": "assistant", "content": initial_ideas})
 
119
 
120
  with st.spinner(text="Generating initial ideas..."):
121
  msg = "My initial ideas are:"
122
+ initial_ideas, final_ideas = backend.literature2initial_ideas_callback(background, brainstorms, related_works_intact)
123
  st.session_state.messages.append({"role": "assistant", "content": msg})
124
  st.chat_message("assistant").write(msg)
125
  st.session_state.messages.append({"role": "assistant", "content": initial_ideas})
src/pages/step_by_step_generation.py CHANGED
@@ -132,7 +132,7 @@ def genrate_mainpage(backend):
132
  if submitted:
133
  st.session_state["global_state_step"] = 5.0
134
  with st.spinner(text="Generating initial ideas..."):
135
- res = backend.literature2initial_ideas_callback(background, st.session_state["related_works_intact"])
136
  st.session_state["initial_ideas"] = res[0]
137
  st.session_state["final_ideas"] = res[1]
138
  # st.session_state["initial_ideas"] = "initial ideas"
 
132
  if submitted:
133
  st.session_state["global_state_step"] = 5.0
134
  with st.spinner(text="Generating initial ideas..."):
135
+ res = backend.literature2initial_ideas_callback(background, brainstorms, st.session_state["related_works_intact"])
136
  st.session_state["initial_ideas"] = res[0]
137
  st.session_state["final_ideas"] = res[1]
138
  # st.session_state["initial_ideas"] = "initial ideas"
src/retriever.py CHANGED
@@ -8,6 +8,7 @@ import click
8
  import json
9
  from loguru import logger
10
  import warnings
 
11
 
12
  warnings.filterwarnings("ignore")
13
 
@@ -55,30 +56,11 @@ def main(ctx):
55
  is_flag=True,
56
  help="Whether to use cluster-to-filter, defaults to False",
57
  )
58
- @click.option(
59
- "--llms-api",
60
- default=None,
61
- type=str,
62
- required=False,
63
- help="The LLMS API alias used. If you do not have separate APIs for summarization and generation, you can use this unified setting. This option is ignored when setting the API to be used by summarization and generation separately",
64
- )
65
- @click.option(
66
- "--sum-api",
67
- default=None,
68
- type=str,
69
- required=False,
70
- help="The LLMS API aliases used for summarization. When used, it will invalidate --llms-api",
71
- )
72
- @click.option(
73
- "--gen-api",
74
- default=None,
75
- type=str,
76
- required=False,
77
- help="The LLMS API aliases used for generation. When used, it will invalidate --llms-api",
78
- )
79
  def retrieve(
80
  config_path, ids_path, retriever_name, co_cite, cluster_to_filter, **kwargs
81
  ):
 
 
82
  config = ConfigReader.load(config_path, **kwargs)
83
  log_dir = config.DEFAULT.log_dir
84
  if not os.path.exists(log_dir):
 
8
  import json
9
  from loguru import logger
10
  import warnings
11
+ from utils.hash import check_env, check_embedding
12
 
13
  warnings.filterwarnings("ignore")
14
 
 
56
  is_flag=True,
57
  help="Whether to use cluster-to-filter, defaults to False",
58
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  def retrieve(
60
  config_path, ids_path, retriever_name, co_cite, cluster_to_filter, **kwargs
61
  ):
62
+ check_env()
63
+ check_embedding()
64
  config = ConfigReader.load(config_path, **kwargs)
65
  log_dir = config.DEFAULT.log_dir
66
  if not os.path.exists(log_dir):
src/utils/hash.py CHANGED
@@ -5,33 +5,42 @@ import struct
5
  from collections import Counter
6
  from huggingface_hub import hf_hub_download
7
 
 
 
 
8
  def check_embedding():
9
- # Define the repository and files to download
10
- repo_id = "sentence-transformers/all-MiniLM-L6-v2" # "BAAI/bge-small-en-v1.5"
11
- files_to_download = [
12
- "config.json",
13
- "pytorch_model.bin",
14
- "tokenizer_config.json",
15
- "vocab.txt",
16
- ]
17
- # Download each file and save it to the /model/bge directory
18
- for file_name in files_to_download:
19
- print("Checking for file: ", file_name)
20
- hf_hub_download(repo_id=repo_id, filename=file_name, local_dir=f"./assets/model/{repo_id}")
 
 
 
21
 
22
  def check_env():
23
- env_name_list = [
24
- "NEO4J_URL",
25
- "NEO4J_USERNAME",
26
- "NEO4J_PASSWD",
27
- "MODEL_NAME",
28
- "MODEL_TYPE",
29
- "MODEL_API_KEY",
30
- "BASE_URL",
31
- ]
32
- for env_name in env_name_list:
33
- if env_name not in os.environ or os.environ[env_name] == "":
34
- raise ValueError(f"{env_name} is not set...")
 
 
 
35
 
36
 
37
  def generate_hash_id(input_string):
 
5
  from collections import Counter
6
  from huggingface_hub import hf_hub_download
7
 
8
+ ENV_CHECKED = False
9
+ EMBEDDING_CHECKED = False
10
+
11
  def check_embedding():
12
+ global EMBEDDING_CHECKED
13
+ if not EMBEDDING_CHECKED:
14
+ # Define the repository and files to download
15
+ repo_id = "sentence-transformers/all-MiniLM-L6-v2" # "BAAI/bge-small-en-v1.5"
16
+ files_to_download = [
17
+ "config.json",
18
+ "pytorch_model.bin",
19
+ "tokenizer_config.json",
20
+ "vocab.txt",
21
+ ]
22
+ # Download each file and save it to the /model/bge directory
23
+ for file_name in files_to_download:
24
+ print("Checking for file: ", file_name)
25
+ hf_hub_download(repo_id=repo_id, filename=file_name, local_dir=f"./assets/model/{repo_id}")
26
+ EMBEDDING_CHECKED = True
27
 
28
  def check_env():
29
+ global ENV_CHECKED
30
+ if not ENV_CHECKED:
31
+ env_name_list = [
32
+ "NEO4J_URL",
33
+ "NEO4J_USERNAME",
34
+ "NEO4J_PASSWD",
35
+ "MODEL_NAME",
36
+ "MODEL_TYPE",
37
+ "MODEL_API_KEY",
38
+ "BASE_URL",
39
+ ]
40
+ for env_name in env_name_list:
41
+ if env_name not in os.environ or os.environ[env_name] == "":
42
+ raise ValueError(f"{env_name} is not set...")
43
+ ENV_CHECKED = True
44
 
45
 
46
  def generate_hash_id(input_string):
src/utils/llms_api.py CHANGED
@@ -49,6 +49,14 @@ class APIHelper(object):
49
  pass
50
 
51
  def __call__(self, title: str, abstract: str, introduction: str) -> dict:
 
 
 
 
 
 
 
 
52
  if title is None or abstract is None or introduction is None:
53
  return None
54
  try:
@@ -102,8 +110,8 @@ class APIHelper(object):
102
  few_shot_examples = []
103
  for example in common_examples:
104
  few_shot_examples.append(example)
105
-
106
- prompt_template_entity = '''
107
  ### Task Description:
108
  You are an AI researcher tasked with extracting the key entities from a given research paper content. These entities should represent the most important keywords or phrases that summarize the main topics or concepts discussed in the content.
109
 
@@ -130,7 +138,7 @@ class APIHelper(object):
130
  ### Format for Your Response:
131
  Please just give me the entities and spilt them by ",":
132
  <entity 1>,<entity2>,...
133
- '''
134
 
135
  if abstract is None:
136
  return None
@@ -192,6 +200,7 @@ class APIHelper(object):
192
  """
193
 
194
  if background is None:
 
195
  return None
196
  try:
197
  # Initial brainstorming to generate raw ideas
@@ -202,7 +211,6 @@ class APIHelper(object):
202
  prompt_first = "Now you are a researcher in the field of AI with innovative and pioneering abilities. You are good at generating creative and original ideas."
203
  message.append({"role": "system", "content": prompt_first})
204
  message.append({"role": "user", "content": brainstorming_prompt})
205
-
206
  # Call the API to generate brainstorming ideas
207
  response_brainstorming = self.generator.create(
208
  messages=message,
@@ -665,7 +673,7 @@ class APIHelper(object):
665
  traceback.print_exc()
666
  return None
667
  return idea
668
-
669
  def integrate_idea(self, background: str, brainstorm: str, idea: str) -> str:
670
  prompt_template_idea = """
671
  Task Description:
@@ -700,7 +708,8 @@ class APIHelper(object):
700
  system_input = "Now you are a researcher in the field of AI with innovative and pioneering abilities. You are good at generating innovative and original ideas to solve cutting-edge problems in the field of AI."
701
  message.append({"role": "system", "content": system_input})
702
  message_input = prompt_template_idea.format(
703
- background=background, brainstorm=brainstorm, idea=idea)
 
704
  message.append({"role": "user", "content": message_input})
705
  response = self.generator.create(
706
  messages=message,
@@ -851,7 +860,7 @@ class APIHelper(object):
851
  except Exception:
852
  traceback.print_exc()
853
  return ground_truth
854
-
855
  def transfer_form(self, idea: str):
856
  prompt_template_transfer = """
857
  ### Task Description:
@@ -973,7 +982,13 @@ class APIHelper(object):
973
  return score
974
 
975
  def novelty_eval(
976
- self, current_round: int, num_rounds: int, max_num_iterations: int, idea: str, last_query_results: str, msg_history: list
 
 
 
 
 
 
977
  ):
978
  novelty_system_msg = """You are an ambitious AI PhD student who is looking to publish a paper that will contribute significantly to the field.
979
  You have an idea and you want to check if it is novel or not. I.e., not overlapping significantly with existing literature or already well explored.
@@ -1018,13 +1033,13 @@ class APIHelper(object):
1018
  A query will work best if you are able to recall the exact name of the paper you are looking for, or the authors.
1019
  This JSON will be automatically parsed, so ensure the format is precise. (the JSON MUST contain the "Query" and the "Novelty Score")
1020
  In the last round, you should assign a "" value to the "Query" even if you don't need to generate it.'''
1021
- msg=novelty_prompt.format(
1022
  current_round=current_round,
1023
  num_rounds=max_num_iterations,
1024
  idea=idea,
1025
  last_query_results=last_query_results,
1026
  )
1027
- system_message=novelty_system_msg.format(
1028
  num_rounds=max_num_iterations,
1029
  )
1030
  if msg_history is None:
@@ -1043,14 +1058,18 @@ class APIHelper(object):
1043
  seed=0,
1044
  )
1045
  content = response.choices[0].message.content
1046
- new_msg_history = new_msg_history + [{"role": "assistant", "content": content}]
 
 
1047
 
1048
  except Exception:
1049
  traceback.print_exc()
1050
  return None
1051
  return content, new_msg_history
1052
 
1053
- def compare_same(self, idea1:str, idea2:str, idea3:str, idea4:str, idea5:str) -> str:
 
 
1054
  system_input = """
1055
  You are an artificial intelligence researcher with extensive knowledge in this field, and now you need to make a comprehensive comparison among five ideas.
1056
  You will obtain a comparison standard, compare every point on the standard.
@@ -1104,13 +1123,20 @@ class APIHelper(object):
1104
 
1105
  This JSON will be automatically parsed, so ensure the format is precise.
1106
  '''
1107
- if idea1 is None or idea2 is None or idea3 is None or idea4 is None or idea5 is None:
 
 
 
 
 
 
1108
  return None
1109
  try:
1110
  message = []
1111
  message.append({"role": "system", "content": system_input})
1112
  message_input = input_message.format(
1113
- idea1=idea1, idea2=idea2, idea3=idea3, idea4=idea4, idea5=idea5)
 
1114
  message.append({"role": "user", "content": message_input})
1115
  response = self.generator.create(
1116
  messages=message,
@@ -1121,7 +1147,7 @@ class APIHelper(object):
1121
  return None
1122
  return result
1123
 
1124
- def compare_all(self, idea1:str, idea2:str) -> str:
1125
  system_input = """
1126
  You are an artificial intelligence researcher with extensive knowledge in this field, and now you need to make a comprehensive comparison among five ideas.
1127
  You will obtain a comparison standard, compare every point on the standard, and make a overall ranking at the end.
@@ -1172,8 +1198,7 @@ class APIHelper(object):
1172
  try:
1173
  message = []
1174
  message.append({"role": "system", "content": system_input})
1175
- message_input = input_message.format(
1176
- idea1=idea1, idea2=idea2)
1177
  message.append({"role": "user", "content": message_input})
1178
  response = self.generator.create(
1179
  messages=message,
@@ -1184,7 +1209,7 @@ class APIHelper(object):
1184
  return None
1185
  return result
1186
 
1187
- def compare_novelty_and_feasibility(self, idea1:str, idea2:str) -> str:
1188
  system_input = """
1189
  You are an artificial intelligence researcher with extensive knowledge in this field, and now you need to make a comprehensive comparison between two ideas.
1190
  You will obtain a comparison standard, compare every point on the standard, and make a ranking at the end.
@@ -1229,8 +1254,7 @@ class APIHelper(object):
1229
  try:
1230
  message = []
1231
  message.append({"role": "system", "content": system_input})
1232
- message_input = input_message.format(
1233
- idea1=idea1, idea2=idea2)
1234
  message.append({"role": "user", "content": message_input})
1235
  response = self.generator.create(
1236
  messages=message,
@@ -1240,8 +1264,8 @@ class APIHelper(object):
1240
  traceback.print_exc()
1241
  return None
1242
  return result
1243
-
1244
- def compare_novelty(self, idea1:str, idea2:str) -> str:
1245
  system_input = """
1246
  You are an artificial intelligence researcher with extensive knowledge in this field, and now you need to make a comparison between two ideas.
1247
  You will obtain a comparison standard, compare the novelty between the ideas, and make a ranking at the end.
@@ -1284,8 +1308,7 @@ class APIHelper(object):
1284
  try:
1285
  message = []
1286
  message.append({"role": "system", "content": system_input})
1287
- message_input = input_message.format(
1288
- idea1=idea1, idea2=idea2)
1289
  message.append({"role": "user", "content": message_input})
1290
  response = self.generator.create(
1291
  messages=message,
@@ -1296,7 +1319,7 @@ class APIHelper(object):
1296
  return None
1297
  return result
1298
 
1299
- def compare_feasibility(self, idea1:str, idea2:str) -> str:
1300
  system_input = """
1301
  You are an artificial intelligence researcher with extensive knowledge in this field, and now you need to make a comparison between two ideas.
1302
  You will obtain a comparison standard, compare the feasibility between the ideas, and make a ranking at the end.
@@ -1339,8 +1362,7 @@ class APIHelper(object):
1339
  try:
1340
  message = []
1341
  message.append({"role": "system", "content": system_input})
1342
- message_input = input_message.format(
1343
- idea1=idea1, idea2=idea2)
1344
  message.append({"role": "user", "content": message_input})
1345
  response = self.generator.create(
1346
  messages=message,
 
49
  pass
50
 
51
  def __call__(self, title: str, abstract: str, introduction: str) -> dict:
52
+ if os.environ["MODEL_NAME"] not in [
53
+ "glm4",
54
+ "glm4-air",
55
+ "qwen-max",
56
+ "qwen-plus",
57
+ ]:
58
+ raise ValueError(f"Check model name...")
59
+
60
  if title is None or abstract is None or introduction is None:
61
  return None
62
  try:
 
110
  few_shot_examples = []
111
  for example in common_examples:
112
  few_shot_examples.append(example)
113
+
114
+ prompt_template_entity = """
115
  ### Task Description:
116
  You are an AI researcher tasked with extracting the key entities from a given research paper content. These entities should represent the most important keywords or phrases that summarize the main topics or concepts discussed in the content.
117
 
 
138
  ### Format for Your Response:
139
  Please just give me the entities and spilt them by ",":
140
  <entity 1>,<entity2>,...
141
+ """
142
 
143
  if abstract is None:
144
  return None
 
200
  """
201
 
202
  if background is None:
203
+ print("Input background is empty ...")
204
  return None
205
  try:
206
  # Initial brainstorming to generate raw ideas
 
211
  prompt_first = "Now you are a researcher in the field of AI with innovative and pioneering abilities. You are good at generating creative and original ideas."
212
  message.append({"role": "system", "content": prompt_first})
213
  message.append({"role": "user", "content": brainstorming_prompt})
 
214
  # Call the API to generate brainstorming ideas
215
  response_brainstorming = self.generator.create(
216
  messages=message,
 
673
  traceback.print_exc()
674
  return None
675
  return idea
676
+
677
  def integrate_idea(self, background: str, brainstorm: str, idea: str) -> str:
678
  prompt_template_idea = """
679
  Task Description:
 
708
  system_input = "Now you are a researcher in the field of AI with innovative and pioneering abilities. You are good at generating innovative and original ideas to solve cutting-edge problems in the field of AI."
709
  message.append({"role": "system", "content": system_input})
710
  message_input = prompt_template_idea.format(
711
+ background=background, brainstorm=brainstorm, idea=idea
712
+ )
713
  message.append({"role": "user", "content": message_input})
714
  response = self.generator.create(
715
  messages=message,
 
860
  except Exception:
861
  traceback.print_exc()
862
  return ground_truth
863
+
864
  def transfer_form(self, idea: str):
865
  prompt_template_transfer = """
866
  ### Task Description:
 
982
  return score
983
 
984
  def novelty_eval(
985
+ self,
986
+ current_round: int,
987
+ num_rounds: int,
988
+ max_num_iterations: int,
989
+ idea: str,
990
+ last_query_results: str,
991
+ msg_history: list,
992
  ):
993
  novelty_system_msg = """You are an ambitious AI PhD student who is looking to publish a paper that will contribute significantly to the field.
994
  You have an idea and you want to check if it is novel or not. I.e., not overlapping significantly with existing literature or already well explored.
 
1033
  A query will work best if you are able to recall the exact name of the paper you are looking for, or the authors.
1034
  This JSON will be automatically parsed, so ensure the format is precise. (the JSON MUST contain the "Query" and the "Novelty Score")
1035
  In the last round, you should assign a "" value to the "Query" even if you don't need to generate it.'''
1036
+ msg = novelty_prompt.format(
1037
  current_round=current_round,
1038
  num_rounds=max_num_iterations,
1039
  idea=idea,
1040
  last_query_results=last_query_results,
1041
  )
1042
+ system_message = novelty_system_msg.format(
1043
  num_rounds=max_num_iterations,
1044
  )
1045
  if msg_history is None:
 
1058
  seed=0,
1059
  )
1060
  content = response.choices[0].message.content
1061
+ new_msg_history = new_msg_history + [
1062
+ {"role": "assistant", "content": content}
1063
+ ]
1064
 
1065
  except Exception:
1066
  traceback.print_exc()
1067
  return None
1068
  return content, new_msg_history
1069
 
1070
+ def compare_same(
1071
+ self, idea1: str, idea2: str, idea3: str, idea4: str, idea5: str
1072
+ ) -> str:
1073
  system_input = """
1074
  You are an artificial intelligence researcher with extensive knowledge in this field, and now you need to make a comprehensive comparison among five ideas.
1075
  You will obtain a comparison standard, compare every point on the standard.
 
1123
 
1124
  This JSON will be automatically parsed, so ensure the format is precise.
1125
  '''
1126
+ if (
1127
+ idea1 is None
1128
+ or idea2 is None
1129
+ or idea3 is None
1130
+ or idea4 is None
1131
+ or idea5 is None
1132
+ ):
1133
  return None
1134
  try:
1135
  message = []
1136
  message.append({"role": "system", "content": system_input})
1137
  message_input = input_message.format(
1138
+ idea1=idea1, idea2=idea2, idea3=idea3, idea4=idea4, idea5=idea5
1139
+ )
1140
  message.append({"role": "user", "content": message_input})
1141
  response = self.generator.create(
1142
  messages=message,
 
1147
  return None
1148
  return result
1149
 
1150
+ def compare_all(self, idea1: str, idea2: str) -> str:
1151
  system_input = """
1152
  You are an artificial intelligence researcher with extensive knowledge in this field, and now you need to make a comprehensive comparison among five ideas.
1153
  You will obtain a comparison standard, compare every point on the standard, and make a overall ranking at the end.
 
1198
  try:
1199
  message = []
1200
  message.append({"role": "system", "content": system_input})
1201
+ message_input = input_message.format(idea1=idea1, idea2=idea2)
 
1202
  message.append({"role": "user", "content": message_input})
1203
  response = self.generator.create(
1204
  messages=message,
 
1209
  return None
1210
  return result
1211
 
1212
+ def compare_novelty_and_feasibility(self, idea1: str, idea2: str) -> str:
1213
  system_input = """
1214
  You are an artificial intelligence researcher with extensive knowledge in this field, and now you need to make a comprehensive comparison between two ideas.
1215
  You will obtain a comparison standard, compare every point on the standard, and make a ranking at the end.
 
1254
  try:
1255
  message = []
1256
  message.append({"role": "system", "content": system_input})
1257
+ message_input = input_message.format(idea1=idea1, idea2=idea2)
 
1258
  message.append({"role": "user", "content": message_input})
1259
  response = self.generator.create(
1260
  messages=message,
 
1264
  traceback.print_exc()
1265
  return None
1266
  return result
1267
+
1268
+ def compare_novelty(self, idea1: str, idea2: str) -> str:
1269
  system_input = """
1270
  You are an artificial intelligence researcher with extensive knowledge in this field, and now you need to make a comparison between two ideas.
1271
  You will obtain a comparison standard, compare the novelty between the ideas, and make a ranking at the end.
 
1308
  try:
1309
  message = []
1310
  message.append({"role": "system", "content": system_input})
1311
+ message_input = input_message.format(idea1=idea1, idea2=idea2)
 
1312
  message.append({"role": "user", "content": message_input})
1313
  response = self.generator.create(
1314
  messages=message,
 
1319
  return None
1320
  return result
1321
 
1322
+ def compare_feasibility(self, idea1: str, idea2: str) -> str:
1323
  system_input = """
1324
  You are an artificial intelligence researcher with extensive knowledge in this field, and now you need to make a comparison between two ideas.
1325
  You will obtain a comparison standard, compare the feasibility between the ideas, and make a ranking at the end.
 
1362
  try:
1363
  message = []
1364
  message.append({"role": "system", "content": system_input})
1365
+ message_input = input_message.format(idea1=idea1, idea2=idea2)
 
1366
  message.append({"role": "user", "content": message_input})
1367
  response = self.generator.create(
1368
  messages=message,