(question, entity_candidates_id, entity_candidates, score, relation, args)
| 125 | |
| 126 | |
| 127 | def entity_score(question, entity_candidates_id, entity_candidates, score, relation, args): |
| 128 | if len(entity_candidates) == 1: |
| 129 | return [score], entity_candidates, entity_candidates_id |
| 130 | if len(entity_candidates) == 0: |
| 131 | return [0.0], entity_candidates, entity_candidates_id |
| 132 | |
| 133 | # make sure the id and entity are in the same order |
| 134 | zipped_lists = sorted(zip(entity_candidates, entity_candidates_id)) |
| 135 | entity_candidates, entity_candidates_id = zip(*zipped_lists) |
| 136 | entity_candidates = list(entity_candidates) |
| 137 | entity_candidates_id = list(entity_candidates_id) |
| 138 | |
| 139 | prompt = construct_entity_score_prompt(question, relation, entity_candidates) |
| 140 | |
| 141 | result = run_llm(prompt, args.temperature_exploration, args.max_length, args.opeani_api_keys, args.LLM_type) |
| 142 | entity_scores = clean_scores(result, entity_candidates) |
| 143 | if all_zero(entity_scores): |
| 144 | return [1/len(entity_candidates) * score] * len(entity_candidates), entity_candidates, entity_candidates_id |
| 145 | else: |
| 146 | return [float(x) * score for x in entity_scores], entity_candidates, entity_candidates_id |
| 147 | |
| 148 | |
| 149 | def update_history(entity_candidates, entity, scores, entity_candidates_id, total_candidates, total_scores, total_relations, total_entities_id, total_topic_entities, total_head, value_flag): |
no test coverage detected