Documentation Index
Fetch the complete documentation index at: https://docs.swarms.world/llms.txt
Use this file to discover all available pages before exploring further.
Overview
TheSwarmMatcher utilizes transformer-based embeddings to determine the best swarm architecture for a given task. By analyzing the semantic meaning of task descriptions and comparing them to known swarm types, it can intelligently select the optimal swarm configuration for any task.
Workflow
Installation
Attributes
SwarmMatcherConfig
The transformer model to use for generating embeddings.
The dimension of the embedding vectors.
SwarmType
The name of the swarm type.
A detailed description of the swarm type’s capabilities and ideal use cases.
The generated embedding vector for this swarm type (auto-populated).
Methods
__init__()
Initializes the SwarmMatcher with a configuration.config(SwarmMatcherConfig): Configuration object for the matcher
get_embedding()
Generates an embedding vector for a given text using the configured model.text(str): The text to embed
np.ndarray - The embedding vector
add_swarm_type()
Adds a swarm type to the matcher, generating an embedding for its description.swarm_type(SwarmType): The swarm type to add
find_best_match()
Finds the best matching swarm type for a given task.task(str): The task description
Tuple[str, float] - The name of the best matching swarm type and the similarity score
auto_select_swarm()
Automatically selects the best swarm type for a given task.task(str): The task description
str - The name of the selected swarm type
run_multiple()
Matches multiple tasks to swarm types in batch.tasks(List[str]): A list of task descriptions
List[str] - A list of selected swarm type names
save_swarm_types()
Saves the registered swarm types to a JSON file.filename(str): Path where the swarm types will be saved
load_swarm_types()
Loads swarm types from a JSON file.filename(str): Path to the JSON file containing swarm types
Available Swarm Types
SwarmMatcher comes with several pre-defined swarm types:| Swarm Type | Description |
|---|---|
| AgentRearrange | Optimize agent order and rearrange flow for multi-step tasks, ensuring efficient task allocation and minimizing bottlenecks. |
| MixtureOfAgents | Combine diverse expert agents for comprehensive analysis, fostering a collaborative approach to problem-solving and leveraging individual strengths. |
| SpreadSheetSwarm | Collaborative data processing and analysis in a spreadsheet-like environment, facilitating real-time data sharing and visualization. |
| SequentialWorkflow | Execute tasks in a step-by-step, sequential process workflow, ensuring a logical and methodical approach to task execution. |
| ConcurrentWorkflow | Process multiple tasks or data sources concurrently in parallel, maximizing productivity and reducing processing time. |
Usage Examples
Simple Matching
Batch Matching
Advanced Usage with Custom Configuration
Custom Swarm Types
How It Works
SwarmMatcher uses a transformer-based model to generate embeddings (vector representations) of both the task descriptions and the swarm type descriptions. It then calculates the similarity between these embeddings to determine which swarm type is most semantically similar to the given task. The matching process follows these steps:- The task description is converted to an embedding vector
- Each swarm type’s description is converted to an embedding vector
- The similarity between the task embedding and each swarm type embedding is calculated
- The swarm type with the highest similarity score is selected