Below is one way to think about a “domain‐specific language” (DSL) for interacting with a language model. (Feel free to build on or modify it as necessary.) The idea is to have a small set of commands that let you:
- Record new questions and answers:
That is, treat the conversation like a numbered dialogue.
- Reference previous parts:
Be it entire messages or “components” (for example, a summary, details, or a list of reasons).
- Break up answers into labeled components:
This lets you later say “use the explanation part from answer #3” or “add advice to the reasoning.”
- Work with lists of alternative responses:
In some cases, you may want to ask “What are various ways to answer this question?” and then “evaluate” or “iterate” through them.
Below is one proposal for such a simple language. For clarity, we present a grammar outline, a description of each command, and then a sample “session” to illustrate usage.
1. DSL Design Overview
We define a DSL called LM-Interact with two broad categories of commands: message definition and message reference/evaluation.
A. Message Definition Commands
-
Question Command (Q:)
Begins a new interaction (a question).
Syntax:
Q <id> : <question text>
Example:
Q1: What is the capital of France?
-
Answer Command (A:)
Specifies an answer to a previously asked question. You can also include “components” (i.e. parts of the answer).
Syntax:
A <id> : <answer text> { parts: { <label1>=<component1>, <label2>=<component2>, ... } }
Example:
A1: Paris. { parts: { fact="Paris", explanation="It is the capital of France." } }
-
List Responses Command (LIST:)
Request a list of different ways to respond to a given question.
Syntax:
LIST <source-id> : <question text>
This effectively tells the model: “Generate several candidate answers for question <source-id>.”
Example:
LIST Q2: How can we solve this problem?
-
Iterate/Evaluate Command (ITERATE: / EVAL:)
Iterate through a list of responses (generated via LIST:) and add judgments or feedback.
Syntax:
ITERATE <list-id> : [ { option=<option-id>, feedback=<feedback text> }, ... ]
Or, if you want the model to judge the quality of each option:
EVAL <list-id> : <evaluation prompt>
Example:
ITERATE L1: [ { option=1, feedback="This is too terse." }, { option=2, feedback="Good detail on the explanation." } ]
B. Message Reference Commands
Sometimes you want to refer back to a previous question or answer or even a specific “component” of an answer. For these purposes, we include:
-
Reference (REF:)
Syntax:
REF <message-id> [ .<component-label> ]
This lets you say “use the full text of message Q3” or “use only the 'explanation' part of A1.”
Examples:
REF A1 // refers to the full answer of A1
REF A1.explanation // refers to only the explanation piece of A1
-
Augment (AUGMENT:)
This command lets you feed additional advice or clarifications into the context after selecting a component from a previous answer.
Syntax:
AUGMENT <target-id> [ .<component-label> ] : <additional context>
Example:
AUGMENT A1.explanation: Please provide further historical context about Paris.
2. DSL Grammar (Informal BNF)
Below is an informal BNF representation of the DSL commands:
<session> ::= (<command> "\n")*
<command> ::= <question> | <answer> | <list> | <iterate> | <eval> | <ref> | <augment>
<question> ::= "Q" <id> ":" <text>
<answer> ::= "A" <id> ":" <text> [ "{ parts: {" <parts> "}" ]
<parts> ::= <part> ("," <part>)*
<part> ::= <label> "=" <text>
<list> ::= "LIST" <id> ":" <text>
<iterate> ::= "ITERATE" <list-id> ":" "[" <iterate-items> "]"
<iterate-items> ::= <iterate-item> ("," <iterate-item>)*
<iterate-item> ::= "{ option=" <option-id> ", feedback=" <text> " }"
<eval> ::= "EVAL" <list-id> ":" <text>
<ref> ::= "REF" <id> [ "." <label> ]
<augment> ::= "AUGMENT" <id> [ "." <label> ] ":" <text>
<id> ::= (an identifier, e.g. Q1, A1, L1)
<label> ::= (a string identifier, e.g. fact, explanation)
<text> ::= (any text string)
3. Sample Session
Below is a sample session showing how you might use this DSL:
Q1: What is the capital of France?
A1: Paris. { parts: { fact="Paris", explanation="Paris is not only the largest city but also the capital, historically and politically." } }
Q2: Can you provide some alternative phrasings for a short answer to Q1?
LIST L1: List alternative responses for Q1.
EVAL L1: For each option evaluate its clarity and informativeness.
ITERATE L1: [
{ option=1, feedback="Too brief, could use more context." },
{ option=2, feedback="Balanced, but could mention history for added depth." }
]
AUGMENT A1.explanation: Please also add a note about Paris's role as a cultural center.
Explanation of the session above:
- The first block registers a question (Q1) and its answer (A1). The answer is split into two parts: a short fact and a more detailed explanation.
- In Q2, we ask the model to generate a list of alternative responses for Q1. The generated list is assigned an identifier (L1).
- An evaluation prompt (EVAL) is issued for the list L1 to let the model decide on clarity and informativeness.
- We then iterate over the list L1 (with
ITERATE) to provide specific feedback on selected options.
- Finally,
AUGMENT is used to instruct the model to extend just the “explanation” part of answer A1 with additional cultural context.
4. Rationale & Benefits
-
Modularity and Reuse:
By assigning IDs to each message, you can easily refer back to them later or even “update” them with additional context.
-
Granularity:
Splitting answers into labeled components (like “fact” and “explanation”) makes it possible to target parts of the response for review, feedback, or augmentation.
-
Iteration:
The LIST, EVAL, and ITERATE commands create a framework for the model to offer multiple candidate responses and for you to provide iterative feedback on each—helping fine-tune the conversation.
-
Transparency:
Commands like REF make it explicit which prior message or component is being used for further processing, reducing ambiguity.
5. Extensions and Considerations
-
Error Handling:
In a complete implementation, you’d want to add error-checking (for example, to ensure that referenced IDs exist).
-
Context Merging:
Depending on how the LM is implemented, you may need to specify whether new input should replace or add to prior context.
-
Command Ordering:
You might require that certain commands (like a reference) only work after the referenced messages have been defined.
-
Flexibility in Lists:
You might expand the list/evaluation mechanism to permit nested evaluations, weighted scoring, or integration with external criteria.
This simple DSL provides a structured way to interact with a language model, enabling precise references to previous content, component-level feedback, and iterative evaluation of answer candidates. It is intentionally minimal yet flexible enough to serve as the basis for more sophisticated interactions.