-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* support paper rebuttal environment (#36) * fix review paper * fix review paper test * fix type errors (#36) * fix test errors * fix test errors * update decision making and paper rebuttal (#36) * fix test errors * support return bool decision and int score * fix ruff * support full testing * support full testing * fix one typo * fix mypy error * fix pre-commit error --------- Co-authored-by: timsanders256 <[email protected]> Co-authored-by: Haofei Yu <[email protected]>
- Loading branch information
1 parent
b1e8be1
commit ddba8ba
Showing
5 changed files
with
269 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,78 @@ | ||
from typing import Dict | ||
from typing import Dict, Tuple | ||
|
||
from .env_base import BaseMultiAgentEnv | ||
|
||
|
||
class PaperRebuttalMultiAgentEnv(BaseMultiAgentEnv): | ||
def __init__(self, agent_dict: Dict[str, str]) -> None: | ||
super().__init__(agent_dict) | ||
self.turn_number = 0 | ||
self.turn_max = 1 | ||
self.terminated = False | ||
self.roles: Dict[str, str] = {} | ||
self.submission: Dict[str, str] = {} | ||
self.review = "" | ||
self.decision = "" | ||
self.rebuttal = "" | ||
|
||
def assign_roles(self, role_dict: Dict[str, str]) -> None: | ||
self.roles = role_dict | ||
|
||
def initialize_submission(self, external_data: Dict[str, str]) -> None: | ||
self.submission = external_data | ||
|
||
def submit_review(self, review_dict: Dict[str, Tuple[int, str]]) -> None: | ||
review_serialize = [ | ||
f"Reviewer: {name}\nScore: {review[0]}\nReview: {review[1]}" for name, review in review_dict.items()] | ||
self.review = "\n\n".join(review_serialize) | ||
|
||
def submit_decision(self, decision_dict: Dict[str, Tuple[bool, str]]) -> None: | ||
decision_count = {"accept": 0, "reject": 0} | ||
for _, decision in decision_dict.items(): | ||
if decision[0]: | ||
decision_count["accept"] += 1 | ||
else: | ||
decision_count["reject"] += 1 | ||
count_max = 0 | ||
for d, count in decision_count.items(): | ||
if count > count_max: | ||
count_max = count | ||
self.decision = d | ||
|
||
def submit_rebuttal(self, rebuttal_dict: Dict[str, str]) -> None: | ||
rebuttal_serialize = [ | ||
f"Author: {name}\nRebuttal: {rebuttal}" for name, rebuttal in rebuttal_dict.items()] | ||
self.rebuttal = "\n\n".join(rebuttal_serialize) | ||
|
||
def step(self) -> None: | ||
external_data = self.kb.get_data(10, "machine learning") | ||
for agent_name, agent in self.agents.items(): | ||
agent.read_paper(external_data=external_data, domain="machine learning") | ||
agent.review_paper({}, {}) | ||
agent.make_review_decision({}, {}) | ||
# Paper Reviewing | ||
review_dict: Dict[str, Tuple[int, str]] = {} | ||
for name, role in self.roles.items(): | ||
if role == "reviewer": | ||
review_dict[name] = self.agents[name].review_paper( | ||
external_data=self.submission) | ||
self.submit_review(review_dict) | ||
|
||
# Decision Making | ||
decision_dict: Dict[str, Tuple[bool, str]] = {} | ||
for name, role in self.roles.items(): | ||
if role == "reviewer": | ||
decision_dict[name] = self.agents[name].make_review_decision( | ||
submission=self.submission, review=review_dict) | ||
self.submit_decision(decision_dict) | ||
|
||
self.submit_rebuttal() | ||
# Rebuttal Submitting | ||
rebuttal_dict: Dict[str, str] = {} | ||
for name, role in self.roles.items(): | ||
if role == "author": | ||
rebuttal_dict[name] = self.agents[name].rebut_review( | ||
submission=self.submission, | ||
review=review_dict, | ||
decision=decision_dict) | ||
self.submit_rebuttal(rebuttal_dict) | ||
|
||
def submit_rebuttal(self) -> None: | ||
pass | ||
self.turn_number += 1 | ||
if self.decision == "accept": | ||
self.terminated = True | ||
if self.turn_number >= self.turn_max: | ||
self.terminated = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.