DARPA-ASKEM / terarium

https://app.terarium.ai
Apache License 2.0
15 stars 2 forks source link

[FEAT]: TA2 Operator Edit model #2358

Closed YohannParis closed 9 months ago

YohannParis commented 11 months ago

Task summary

Tasks

v1: create a notebook environment to send and process python/mira commands to edit a model

Create the operator skeleton: operator definition, node, drilldown ...etc. The operator should receive modelId as input and create new model (output modelId) as required.

For the drilldown UI: there will be 3 main sections: the wizard interface, the notebook interface, and the preview

The notebook tab is meant to emulate a notebook-cell, running the notebook runs against the model that is passed into the operator, and not the current model that may have had edits performed on it already. That is to say we basically start from scratch when running the notebook.

Note for the code to work, there is a notion of the beaker session's context (e.g. there should be a variable called model that you are expected to manipulate). For beaker-related issues please consult Matt.

In addition, we wrap beaker interactions inside a KernelSessionManager, this is to facilitate more complicated event-chaining - as beaker request/response is not strictly 1:1. For questions on this matter check in with Al-Jami.

v1.5: update model edit code snippets/fragments (Added December 19, 2023)

MIRA had gone through changes, thus some of the code fragments provided above are no invalid, we should have an updated understanding of what code should be generated. Work with @liunelson to update the operations needed for Petrinet

v2: add in LLM agent interface to infer the operations from natural language

In this pass, we want to add in an input/chat box to get the LLM to return the corresponding mira/python code that will perform model edit operations. The returned code-fragment should be appended to existing code, if applicable.

We want to be able to generate most, if not all of the edit operations outlined in the google-doc above related to petrinet.

As this requires prompt engineering, we should check in with Matt/Five on:

mwdchang commented 11 months ago

Model editing through MIRA/beaker kernel.

See document below for the available actions and corresponding MIRA template python code: https://docs.google.com/document/d/1zzh-F7QKhvzwRibpBR0KkNxZ284EaU_DuDWWBsA_SrA/edit#heading=h.rujuwfetezmv

This mostly refers to model editing for ODE-based models: Petrnet, RegNet and stock-and-flow. It is not completely clear if PDE (decapodes) will go through the same route for its model edits.

liunelson commented 10 months ago

As discussed, I have done the following:

This Google Doc describes the above: https://docs.google.com/document/d/1twvnKPHVETPQ59PdTscfmLxelvq5ErlXhB9AhG_1mW8/edit

This Google Drive directory has the AMR JSON mentioned therein https://drive.google.com/drive/u/0/folders/19fFkMY7ipu1hISh_XrKMTnQ7MgBmBblV

Whoever is implementing the Edit Model operator using templates should understand what the above examples and description.

The "template cards" in the Edit Model operator design should be generated using the information contain within the 7 template AMR JSONs (1 template AMR JSON -> 1 template card)

The two interconversion functions might be used when one wants to switch between the "flat" (or "single-card") view of a model and the "templates" (or "decomposed") view; i.e. viewing the SIR model as a single card with "S, I, R" or viewing it as two connected cards (one with just "S -> I" and the other with "I -> R"). The implementation of these two functions described in the Google Doc is done using Python and the MIRA package.

@YohannParis @mwdchang @Tom-Szendrey Does the above make sense?

Tom-Szendrey commented 10 months ago

As discussed, I have done the following:

  • generate the AMR JSON of the 7 template models needed to populate the right-hand-side panel in the Edit Model UI (context = any PetriNet model is just a linear combination of these 7)
  • define two functions, (1) take a model and return its templates, (2) take a list of templates and return the model that is their union
  • generate an example of this interconversion of a model and its templates using the SIR model

This Google Doc describes the above: https://docs.google.com/document/d/1twvnKPHVETPQ59PdTscfmLxelvq5ErlXhB9AhG_1mW8/edit

This Google Drive directory has the AMR JSON mentioned therein https://drive.google.com/drive/u/0/folders/19fFkMY7ipu1hISh_XrKMTnQ7MgBmBblV

Whoever is implementing the Edit Model operator using templates should understand what the above examples and description.

The "template cards" in the Edit Model operator design should be generated using the information contain within the 7 template AMR JSONs (1 template AMR JSON -> 1 template card)

The two interconversion functions might be used when one wants to switch between the "flat" (or "single-card") view of a model and the "templates" (or "decomposed") view; i.e. viewing the SIR model as a single card with "S, I, R" or viewing it as two connected cards (one with just "S -> I" and the other with "I -> R"). The implementation of these two functions described in the Google Doc is done using Python and the MIRA package.

@YohannParis @mwdchang @Tom-Szendrey Does the above make sense?

Thank you Nelson ill be checking these examples out this sounds super helpful!!

YohannParis commented 10 months ago

@liunelson I do beleive you added this information into the wrong issue: https://github.com/orgs/DARPA-ASKEM/projects/3/views/8?pane=issue&itemId=48926518