-
Notifications
You must be signed in to change notification settings - Fork 7
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
[BUG]: Model extraction cases #407
Comments
I have more cases described here: The issue there (Cases 1, 3) appear to be related to the SymPy's Can Case 3aodes_latex = [
r"\frac{d S(t)}{d t} = -b * S(t) * I(t) + l - m * S(t)",
r"\frac{d I(t)}{d t} = b * S(t) * I(t) - g * I(t) - m * I(t)",
r"\frac{d R(t)}{d t} = g * I(t) - m * R(t)",
]
odes_sympy = [
Eq(Derivative(S(t), t), -m*S(t) + (l + ((-b)*S(t))*I(t))),
Eq(Derivative(I(t), t), -m*I(t) + (-g*I(t) + (b*S(t))*I(t))),
Eq(Derivative(R(t), t), g*I(t) - m*R(t))
] Case 3bodes_latex = [
r"\frac{d S(t)}{d t} = -b * S(t) * I(t)",
r"\frac{d I(t)}{d t} = b * S(t) * I(t) - k * g * I(t) - (1 - k) * g * I(t)",
r"\frac{d R(t)}{d t} = k * g * I(t)",
r"\frac{d V(t)}{d t} = (1 - k) * g * I(t)"
]
odes_sympy = [
Eq(Derivative(S(t), t), -b*I(t)*S(t)),
Eq(Derivative(I(t), t), -g*(1 - k)*I(t) + ((b*S(t))*I(t) - g*k*I(t))),
Eq(Derivative(R(t), t), (g*k)*I(t)),
Eq(Derivative(V(t), t), (g*(1 - k))*I(t))
] |
For Case 1, I think the term |
For Case 2, I agree this is an ambiguous case (both models produce correct ODEs) and it would be nice to recognize the natural conversions, though not trivial. This requires some further thinking and algorithmic improvement. |
@bgyori I just updated our LaTeX style guide (which an LLM agent is instructed to follow when cleaning up LaTeX provided by users or upstream service). |
I imagine Case 2 is quite nontrivial to tackle automatically, despite how common I see it in model-extraction scenarios. I'm split on whether to try to teach/instruct the equation-styling LLM agent to recognize and expand branching terms. I'll experiment. |
Could you comment on Cases 3a/b? We're trying to figure out how to pass SymPy strings (as opposed to SymPy Previously, we simply did: model = template_model_from_sympy_odes([sympy.parsing.latex.parse_latex(ode) for ode in odes_latex]) If MIRA didn't get tripped up by the extra |
For Case 3a, I believe we are getting the expected result, despite the parentheses.
In particular, the first two templates look correct in terms of a separate production and conversion template. |
Case 3b appears to be working correctly as well, I get these templates
which look correct (just printing some basic details, the actual subjects/objects/controllers are also correct) |
That's quite weird, I get different results from you:
|
Here's the code snippets that I used: # Case 3a
odes_latex = [
r"\frac{d S(t)}{d t} = -b * S(t) * I(t) + l - m * S(t)",
r"\frac{d I(t)}{d t} = b * S(t) * I(t) - g * I(t) - m * I(t)",
r"\frac{d R(t)}{d t} = g * I(t) - m * R(t)",
]
odes_sympy = [sympy.parsing.latex.parse_latex(ode) for ode in odes_latex]
__ = [print(ode) for ode in odes_sympy]
model = template_model_from_sympy_odes(odes_sympy)
generate_summary_table(model) # Case 3b
odes_latex = [
r"\frac{d S(t)}{d t} = -b * S(t) * I(t)",
r"\frac{d I(t)}{d t} = b * S(t) * I(t) - k * g * I(t) - (1 - k) * g * I(t)",
r"\frac{d R(t)}{d t} = k * g * I(t)",
r"\frac{d V(t)}{d t} = (1 - k) * g * I(t)"
]
odes_sympy = [sympy.parsing.latex.parse_latex(ode) for ode in odes_latex]
__ = [print(ode) for ode in odes_sympy]
model = template_model_from_sympy_odes(odes_sympy)
generate_summary_table(model) |
I found some edge cases for
template_model_from_sympy_odes
.Case 1
Fixed Birth (
l
) and proportionate death (m X
) processes are interpreted correctly as natural production and natural degradation:However, I had expected the
m S
terms ond I/d t, d R/d t
to be interpreted controlled degradation templates with rate lawsm * S
.Doing it directly with
template_model_from_sympy_odes
gives a model that completely ignores all them S
terms:Doing it within Terarium (which styles the above LaTeX and converts it to SymPy before sending to MIRA) gives a strange model wherein the rate laws are
"-I*S*b + l", "I*S*b - I*g", "I*g"
(possibly unrelated to MIRA):Case 2
This is a case with "branching ratios":
This gives a model where
I
has a natural degradationg I
and two controlled productions ofR, V
, instead of two natural conversions fromI
intoR, V
.If we were to rewrite the 2nd equation as
\frac{d I}{d t} = b S I - k g I - (1 - k) g I
, then MIRA returns the correct model (whereI
branches intoR, V
with ratiok
).Such a branching case was actually involved in a paper from which the UCSD team wanted to extract a model and it required careful reading of the text to realize a rewrite of the equations.
I
branches intoZ, R
with ratioeta
Do you have a forthcoming solution to this problem or do you expect users/Terarium to rewrite the equations?
The text was updated successfully, but these errors were encountered: