-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from DARPA-ASKEM/4841-extract-interventions-fr…
…om-document Add new interventions from paper method
- Loading branch information
Showing
5 changed files
with
214 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
INTERVENTIONS_FROM_DOCUMENT_PROMPT = """ | ||
You are a helpful agent designed to find intervention policies for a given AMR model described in a research paper. | ||
For context, intervention policies can include multiple interventions that include only static interventions or dynamic interventions. | ||
Static interventions are applied at a specific point in time and permanently change the value of a specific parameter or state. | ||
Dynamic interventions try to keep a specific parameter from going above or below a threshold value. | ||
Use the following AMR model JSON file as a reference: | ||
---START AMR MODEL JSON--- | ||
{amr} | ||
---END AMR MODEL JSON--- | ||
Use the following user-provided text as the research paper to answer the query: | ||
---START USER-PROVIDED TEXT--- | ||
{research_paper} | ||
---END USER-PROVIDED TEXT--- | ||
Assume that the user-provided text describes multiple intervention policies to apply to the model. | ||
For each intervention policy, create a list of interventions depending on what the text describes. | ||
Be sure to use a meaningful descriptive name for the intervention policy, instead of 'intervention_1' and 'intervention_2'. | ||
For each policy described in the paper, create an interventionPolicy object. To do this, follow the instructions below: | ||
1. Create a value for `name` and `description` from the user-provided text. | ||
2. For the description, provide a long-form description of the condition. If the description cannot be created from the user-provided text, set it to an empty string. | ||
3. `model_id` id a UUID. If the AMR model has an id, you can use it. Otherwise, you can set as the nil UUID "00000000-0000-0000-0000-000000000000". | ||
4. For each intervention specified in the policy create an intervention object with the following rules. | ||
a. Create a value for `name` from the user-provided text. | ||
b. `appliedTo` should reference the id of the parameter or initial state of the AMR Model. If you cannot find an initial state or parameter that matches the intervention, do not create an intervention object. | ||
c. `type` should be either "state" or "parameter" depending on what the intervention is applied to. | ||
d. create a list of either static or dynamic interventions, but not both. | ||
Do not respond in full sentences; only create a JSON object that satisfies the JSON schema specified in the response format. | ||
Answer: | ||
""" |
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 |
---|---|---|
@@ -0,0 +1,125 @@ | ||
{ | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"$defs": { | ||
"intervention": { | ||
"type": "object", | ||
"description": "A list of interventions that can be applied to the model.", | ||
"properties": { | ||
"name": { | ||
"type": "string" | ||
}, | ||
"appliedTo": { | ||
"type": "string" | ||
}, | ||
"type": { | ||
"type": "string", | ||
"enum": [ | ||
"state", | ||
"parameter" | ||
] | ||
}, | ||
"staticInterventions": { | ||
"type": "array", | ||
"description": "A list of static interventions that can be applied to the model.", | ||
"items": { | ||
"type": "object", | ||
"properties": { | ||
"timestep": { | ||
"type": "number", | ||
"description": "The timestep at which the intervention is applied" | ||
}, | ||
"value": { | ||
"type": "number", | ||
"description": "The new value of the state or parameter" | ||
} | ||
}, | ||
"required": [ | ||
"timestep", | ||
"value" | ||
], | ||
"additionalProperties": false | ||
} | ||
}, | ||
"dynamicInterventions": { | ||
"type": "array", | ||
"description": "A list of dynamic interventions that can be applied to the model.", | ||
"items": { | ||
"type": "object", | ||
"properties": { | ||
"parameter": { | ||
"type": "string", | ||
"description": "The parameter to which the intervention is applied" | ||
}, | ||
"threshold": { | ||
"type": "string", | ||
"description": "The threshold value for the which the parameter can't go above or below" | ||
}, | ||
"value": { | ||
"type": "string", | ||
"description": "The new value of the state or parameter" | ||
}, | ||
"isGreaterThan": { | ||
"type": "string", | ||
"description": "Whether the parameter should be greater than or less than the threshold" | ||
} | ||
}, | ||
"required": [ | ||
"parameter", | ||
"threshold", | ||
"value", | ||
"isGreaterThan" | ||
], | ||
"additionalProperties": false | ||
} | ||
} | ||
}, | ||
"required": [ | ||
"name", | ||
"appliedTo", | ||
"type", | ||
"staticInterventions", | ||
"dynamicInterventions" | ||
], | ||
"additionalProperties": false | ||
} | ||
}, | ||
"type": "object", | ||
"properties": { | ||
"interventionPolicies": { | ||
"type": "array", | ||
"items": { | ||
"type": "object", | ||
"properties": { | ||
"modelId": { | ||
"type": "string", | ||
"description": "The ID of the AMR model to which the intervention policy applies." | ||
}, | ||
"name": { | ||
"type": "string" | ||
}, | ||
"description": { | ||
"type": "string" | ||
}, | ||
"interventions": { | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/$defs/intervention" | ||
}, | ||
"additionalProperties": false | ||
} | ||
}, | ||
"required": [ | ||
"modelId", | ||
"name", | ||
"description", | ||
"interventions" | ||
], | ||
"additionalProperties": false | ||
} | ||
} | ||
}, | ||
"required": [ | ||
"interventionPolicies" | ||
], | ||
"additionalProperties": false | ||
} |
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