Interaction Protocols (nip.protocols
)#
Overview#
Interaction protocols define the way agents interact with each other. In particular, a protocol specifies the following:
Agents. The names of the agents involved.
Channels. The communication channels between agents.
Order of play. Which agents are active in each turn.
Rewards. The reward signal for each agent in each turn.
Creating a New Protocol#
See Creating a New Protocol for a guide on how to create a new protocol.
Base Classes#
|
Base class for protocol handlers. |
Base class for protocol handlers with a single verifier. |
|
|
Base class for handlers of deterministic protocols with a single verifier. |
Built-In Protocols#
|
Handler for the NIP protocol. |
|
Implementation of the Abstract Decision Problem (ADP) protocol [AZWG21]. |
|
Implementation of the Debate protocol [ICA18]. |
|
Implementation of the Merlin-Arthur Classifier (MAC) protocol [WSZP24]. |
|
Implementation of the MNIP protocol. |
|
Implementation of the Solo Verifier protocol. |
A protocol for testing multi-channel communication between agents. |
Zero-Knowledge Protocols#
All protocols can be converted to zero-knowledge protocols by setting the
protocol_common.zero_knowledge
hyper-parameter to
True
. The way this is implemented is that a ZeroKnowledgeProtocol
meta-handler is used as the protocol handler for
the experiment. This handler creates a child handler for the actual protocol, and runs
the zero-knowledge protocol on top of it.
Meta-handler for zero-knowledge protocols. |
Code Validation Protocols#
In order for protocols to be used in code validation scenarios, some additional configuration is required:
Various configuration options should be specified, such as the human-readable names of the agents.
System prompt templates should be defined for each agent.
The first item is done by creating and registering a
nip.code_validation.protocols.CodeValidationProtocolHandler
class, which
subclasses the desired protocol handler, and provides a
nip.code_validation.protocols.CodeValidationAgentSpec
specification for each
agent. The second is done by creating files of the form
nip/code_validation/prompt_templates/system_prompts/{protocol_name}/{agent_name}.txt
.
See Creating a New Protocol for more information.
Protocol Registry#
The following methods handle registering and building protocol handlers:
- nip.protocols.registry.register_protocol_handler(protocol_handler: Literal['nip', 'adp', 'debate', 'merlin_arthur', 'mnip', 'solo_verifier', 'multi_channel_test'], scenario_type: Literal['graph_isomorphism', 'image_classification', 'code_validation'] | None = None) Callable[[type[P]], type[P]] [source]#
Register a protocol handler.
- nip.protocols.registry.build_protocol_handler(hyper_params: HyperParameters, settings: ExperimentSettings) ProtocolHandler [source]#
Build a trainer from the parameters.
- Parameters:
hyper_params (HyperParameters) – The parameters of the experiment.