-
-
Notifications
You must be signed in to change notification settings - Fork 162
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
Implement smart contract for model feedback signal #529
Comments
Since ChatGPT is down, here is Cohere.ai's response for the following prompt:
Here's an example implementation of a smart contract in Solidity that represents the feedback of a human to an output of a model via an agent: // FeedbackContract.sol
pragma solidity >=0.7.0;
interface Agent {
function getOutput() external view returns (bytes);
}
contract Feedback {
Event NewFeedback(address indexed human, address indexed agent, bytes feedback);
// Array to store feedback entries
mapping(address => bytes[]) public feedbackRecords;
// Array to store all agents
address[] public agents;
// Add an agent to the array of agents
function addAgent(address _agent) public {
agents.push(_agent);
}
// Remove an agent from the array of agents
function removeAgent(address _agent) public {
// Using delete to remove agent from agents array
agents.delete(_agent);
}
// Function for a human to give feedback on an agent's output
function giveFeedback(address _human, address _agent, bytes memory feedback) public {
require(_human != address(0)); // Check if the sender is a valid human
require(_agent != address(0)); // Check if the sender is a valid agent
require(agents.includes(_agent)); // Check if the agent is registered
// Store the feedback
feedbackRecords[_human].push(feedback);
// Emit the NewFeedback event
emit NewFeedback(_human, _agent, feedback);
}
// Function to retrieve feedback given by a human for a specific agent
function getFeedback(address _human, address _agent) external view returns (bytes[]) {
require(_human != address(0)); // Check if the input is a valid human address
require(_agent != address(0)); // Check if the input is a valid agent address
// Return the feedback bytes array for the given human and agent
return feedbackRecords[_human];
}
// Function to retrieve the number of feedback entries for a specific human and agent
function getFeedbackCount(address _human, address _agent) external view returns (uint) {
require(_human != address(0)); // Check if the input is a valid human address
require(_agent != address(0)); // Check if the input is a valid agent address
// Return the length of the feedbackRecords array for the given human and agent
return feedbackRecords[_human].length;
}
}
// SampleAgent.sol
pragma solidity >=0.7.0;
interface Agent {
function getOutput() external view returns (bytes);
}
contract SampleAgent is Agent {
bytes constant readonly output = "Sample agent's output";
function getOutput() external view returns (bytes) {
return output;
}
} This smart contract encapsulates the feedback functionality between humans, agents, and models. Humans provide feedback via the The Please note that this is a basic example for illustrative purposes. Depending on your specific requirements, you may need to extend, modify, or adapt this code to cater to more complex use cases and considerations. |
ChatGPT: To implement a Solidity smart contract that represents the feedback of a human to an output of a model via an agent, we need to define a few key concepts:
The contract will have functions to:
Here's a basic implementation in Solidity: // SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract FeedbackContract {
// A struct to hold the details of a model output
struct ModelOutput {
uint256 id;
address agent;
string output;
}
// A struct to hold feedback details
struct Feedback {
uint256 outputId;
address human;
string comment;
uint8 rating; // A rating from 1 to 5
}
// State variables
ModelOutput[] public modelOutputs;
Feedback[] public feedbacks;
// Mapping from output ID to its feedback
mapping(uint256 => Feedback) public feedbackByOutput;
// Function to record a new model output
function recordOutput(address agent, string memory output) public {
modelOutputs.push(ModelOutput(modelOutputs.length, agent, output));
}
// Function to add feedback to a model output
function addFeedback(uint256 outputId, string memory comment, uint8 rating) public {
require(rating >= 1 && rating <= 5, "Rating should be between 1 and 5");
require(outputId < modelOutputs.length, "Invalid output ID");
Feedback memory newFeedback = Feedback(outputId, msg.sender, comment, rating);
feedbacks.push(newFeedback);
feedbackByOutput[outputId] = newFeedback;
}
// Function to retrieve a specific model output
function getModelOutput(uint256 outputId) public view returns (ModelOutput memory) {
require(outputId < modelOutputs.length, "Invalid output ID");
return modelOutputs[outputId];
}
// Function to retrieve feedback for a specific model output
function getFeedback(uint256 outputId) public view returns (Feedback memory) {
require(outputId < modelOutputs.length, "Invalid output ID");
return feedbackByOutput[outputId];
}
} This contract allows an agent to record outputs of a model, and humans can provide feedback on these outputs. Each output and feedback is stored in arrays, and there's a mapping to link feedback directly to a model output. The contract includes basic validation for the input data. This is a simple structure and can be expanded or modified based on specific requirements. |
ChatGPT: Integrating Morpheus (mor.org) with OpenAdaptAI (https://github.com/OpenAdaptAI/OpenAdapt) for feedback representation involves a few steps:
By combining OpenAdaptAI's capabilities with Morpheus's decentralized AI infrastructure and Smart Agents, a robust, user-friendly system for human feedback on AI model outputs can be established. |
Feature request
This task involves implementing a smart contract to represent the "feedback" of a "human" to an "output" of a "model" via an "agent", where "feedback" is the human feedback on the quality of an agent's behavior and/or the raw output of the model.
Motivation
Ultimately we want to improve the behavior of one or more
Agents
, currently implemented asReplayStrategies
.Yoshua Bengio had a nice short paper on his old website about how intelligence can't exist in an individual, and a collective is necessary for intelligence nodes to interact with each other.
(Sadly looks like it wasn't saved [ https://archive.is/http://iro.umontreal.ca/~bengioy/ ]; see https://arxiv.org/abs/1203.2990 for something possibly related)
One of the ideas was that language is obviously a pretty big component of AGI, and that language would not have been possible without having cooperation.
Tools are also clearly important (e.g. https://openai.com/research/emergent-tool-use; you are reading this through a tool).
Perhaps human intelligence evolution can inform hierarchy :
Cooperation between humans involves love, pain, capital. What does cooperation between humans and LLMs look like?
Feedback welcome!
Related:
#393
#61
The text was updated successfully, but these errors were encountered: