-
-
Notifications
You must be signed in to change notification settings - Fork 688
An attempt to implement the paper(AgentsNet: Coordination and Collaborative Reasoning in Multi-Agent LLMs) #962
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| # 如果所有候选者得票相同,只淘汰一半(避免全部淘汰) | ||
| if len(to_eliminate) == len(vote_counts): | ||
| import random | ||
| to_eliminate = random.sample(to_eliminate, len(to_eliminate) // 2 + 1) |
Check failure
Code scanning / Bearer
Usage of weak Pseudo-Random Number Generator (PRNG) Error
| # 没有候选者被淘汰(可能逻辑错误),为避免死循环,强制淘汰一个 | ||
| if remaining_candidates: | ||
| import random | ||
| new_remaining.remove(random.choice(remaining_candidates)) |
Check failure
Code scanning / Bearer
Usage of weak Pseudo-Random Number Generator (PRNG) Error
| """ | ||
| if self.tie_breaking_method == "random": | ||
| import random | ||
| return random.choice(tied_responses) |
Check failure
Code scanning / Bearer
Usage of weak Pseudo-Random Number Generator (PRNG) Error
| except: | ||
| # If judge response couldn't be interpreted, fall back to random | ||
| import random | ||
| return random.choice(tied_responses) |
Check failure
Code scanning / Bearer
Usage of weak Pseudo-Random Number Generator (PRNG) Error
|
|
||
| # Default fallback | ||
| import random | ||
| return random.choice(tied_responses) |
Check failure
Code scanning / Bearer
Usage of weak Pseudo-Random Number Generator (PRNG) Error
| from swarms import Agent | ||
| from swarms.utils.formatter import formatter | ||
| from swarms.structs.election_swarm_agent import ElectionSwarm | ||
| from dotenv import load_dotenv |
Check failure
Code scanning / Pyre
Undefined import Error
| import uuid | ||
| from typing import Dict, List, Optional, Union, Any, Callable | ||
| from concurrent.futures import ThreadPoolExecutor | ||
| from loguru import logger |
Check failure
Code scanning / Pyre
Undefined import Error
| Which response best addresses the original task? Respond only with the number of your choice. | ||
| """ | ||
|
|
||
| judge_decision = self.judge_agent.run(judge_task) |
Check failure
Code scanning / Pyre
Undefined attribute Error
|
|
||
| # Extract numeric decision from judge response | ||
| try: | ||
| decision_num = int(''.join(filter(str.isdigit, judge_decision))) |
Check failure
Code scanning / Pyre
Incompatible parameter type Error
example video:https://www.loom.com/share/f87f67d881bd4e1da24050ce96ac6c95?sid=d4e8a531-f2d9-4035-80f5-efd856afdaf1
This PR implements the ElectionSwarm class, a collective decision-making system based on multi-agent voting mechanisms. It runs multiple agents in parallel and integrates their responses through various voting strategies, thereby enhancing the performance quality and consistency of large language models in complex tasks.
Research Background
This implementation builds on research in "collective intelligence" and "multi-agent collaboration," particularly focusing on:
Integration of Diverse Perspectives: By aggregating responses from multiple different agents, the system synthesizes varied viewpoints and expertise
Mitigation of Agent Bias: Reduces bias or errors from individual agents through mechanisms like majority voting
Enhanced Result Robustness: Ensures final outputs reflect consensus among multiple agents, increasing result reliability
Core Features
ElectionSwarm implements multiple voting mechanisms, including:
Majority Voting: Selects the response that receives the most votes
Unanimous Voting: Requires consensus from all agents
Quorum Voting: Requires reaching a preset threshold percentage of responses
Ranked Choice Voting: Implements a simplified ranked choice voting system that eliminates candidates with the lowest votes through multiple rounds
Additionally, the system supports:
Parallel processing for improved efficiency
Flexible tiebreaking methods for handling tied scenarios
Comprehensive logging to track decision processes
Technical Implementation
Key technical highlights of this implementation include:
Parallel Execution: Utilizes ThreadPoolExecutor to achieve parallel agent processing
Response Normalization: Ensures consistent comparison of responses via the _normalize_response method
Multi-round Voting Mechanisms: Implements complex multi-round decision processes, particularly in ranked choice voting
Robust Design: Handles various edge cases to ensure the system produces valid results under all circumstances
Research Significance
This implementation aligns with current research trends demonstrating that integrating outputs from multiple language models can significantly reduce hallucinations, improve factual accuracy, and enhance performance on complex reasoning tasks.
📚 Documentation preview 📚: https://swarms--962.org.readthedocs.build/en/962/