FLARE-NL¶
- milp_flare.flare_nl.flare_nl_prompt(formulation_a, formulation_b, parameter_map)[source]¶
Build the FLARE-NL prompt from two MILP formulations and a parameter map.
FLARE-NL is a natural language judge for
FLAREthat prompts an LLM to decided if one formulation is a reformulation of another according to the FormulationBench definition of reformulation. See Prompts for the full prompt. See the FLARE Paper for more details.- Parameters:
- formulation_a
str Markdown description of formulation A. Typically produced by
Formulation.render_markdown()from FormulationBench.- formulation_b
str Markdown description of formulation B. Typically produced by
Formulation.render_markdown()from FormulationBench.- parameter_map
str Markdown description of the parameter mapping from A’s parameters to B’s. Typically produced by
Reformulation.parameter_map.render_markdown()from FormulationBench. The judge is asked to decide whether B is a reformulation of A under this mapping specifically.
- formulation_a
- Returns:
- prompt
FLARENLPrompt The system and user messages to send to the judge LLM.
- prompt
Examples
Use FLARE-NL to verify if formulation
bof problemp1from FormulationBench is a reformulation of formulationa:>>> from formulation_bench import Dataset >>> from milp_flare import flare_nl_prompt >>> ds = Dataset.load() >>> pair = ds.reformulations[0] # p1.a -> p1.b >>> prompt = flare_nl_prompt( ... pair.a.render_markdown(), ... pair.b.render_markdown(), ... pair.parameter_map.render_markdown(), ... ) >>> print(prompt.user) You are given the following two Mixed-Integer Linear Programming (MILP)... ## Formulations ... ## Parameter Mapping ... ## Instructions - Decide whether B is a reformulation of A under *this* parameter mapping... - Do NOT make any assumptions about the formulation ... - When uncertain, state that formulation B is *not* a reformulation of A. - Provide a short summary of your conclusion ...
- class milp_flare.flare_nl.FLARENLPrompt(system, user)[source]¶
Return type of
flare_nl_prompt()with system and user messages.- Attributes:
- system
str System message describing the judge’s role. Set to
FLARE_NL_SYSTEM.- user
str User message containing the two formulations and instructions for the judge.
- system
- milp_flare.flare_nl.FLARE_NL_SYSTEM = 'You are an expert in mathematical optimization problems. You decide if one given MILP formulation is a reformulation of another.'¶
System prompt describing the FLARE-NL judge’s role.