FLARE-NL

milp_flare.flare_nl.flare_nl_prompt(formulation_a, formulation_b)[source]

Build the FLARE-NL prompt from two MILP formulations.

FLARE-NL is a natural language judge for FLARE that 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_astr

Markdown description of formulation A. Typically produced by Formulation.render_markdown() from FormulationBench.

formulation_bstr

Markdown description of formulation B. Typically produced by Formulation.render_markdown() from FormulationBench.

Returns:
promptFLARENLPrompt

The system and user messages to send to the judge LLM.

Examples

Use FLARE-NL to verify if formulation b of problem p1 from FormulationBench is a reformulation of formulation a:

>>> from formulation_bench import Dataset
>>> from milp_flare import flare_nl_prompt

>>> ds = Dataset.load()
>>> a = ds.problems[1].formulations["a"]
>>> b = ds.problems[1].formulations["b"]

>>> prompt = flare_nl_prompt(a.render_markdown(), b.render_markdown())
>>> print(prompt.user)
You are given the following two Mixed-Integer Linear Programming (MILP)...

## Formulations
...

## Instructions

- 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:
systemstr

System message describing the judge’s role. Set to FLARE_NL_SYSTEM.

userstr

User message containing the two formulations and instructions for the judge.

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.