Natural Language Commanding via Program Synthesis

Apurva Gandhi, Thong Q. Nguyen, Huitian Jiao, Robert Steen, Ameya BhatawdekararXiv 2023 · DOI

TL;DR

Microsoft researchers have developed Semantic Interpreter, a system that turns natural language commands (like "Make the title look formal") into executable actions within productivity apps like PowerPoint. By translating user intent into a custom, "LLM-friendly" Domain Specific Language (ODSL) using a novel Analysis-Retrieval prompting method, they achieve a 96.06% success rate in executing complex, multi-step document tasks.

Introduction: Bridging the Text-to-Action Gap

Large Language Models (LLMs) are world-class at understanding intent—they can interpret the nuance behind a request like "make this slide pop." However, they consistently struggle with execution in specialized software environments. Standard LLMs face three major hurdles in productivity applications:

  1. Text-to-Action Gap: LLMs perform text-to-text transformations and cannot directly manipulate a document's internal object model.
  2. API Hallucination: General-purpose APIs (like JavaScript or C++) are too vast and verbose. When asked to write code for these, LLMs often "hallucinate" function names or omit required boilerplate.
  3. Context Constraints: Providing the entire state of a large presentation to an LLM would exceed token limits and be prohibitively expensive.

The authors bridge this gap by creating a "neurosymbolic" system that combines the creative reasoning of LLMs with the rigid precision of a custom-built programming language.

The Semantic Interpreter Framework

The core of the system is the Semantic Interpreter, which follows a multi-stage pipeline to translate natural language into executable code.

The end-to-end Semantic Interpreter pipeline, illustrating the flow from natural language input to final document execution.

Office Domain Specific Language (ODSL)

Instead of asking the LLM to write complex JavaScript, the researchers designed ODSL. This high-level, human-readable language focuses on four "CRUD-like" operations: select, insert, format, and delete. ODSL is designed to be compact to save tokens and uniform to make it easier for the LLM to learn patterns.

A sample ODSL program demonstrating the language's compact and human-readable syntax for document manipulation.

Analysis-Retrieval Method (ARM)

To keep prompts lean and efficient, the system employs the Analysis-Retrieval Method (ARM). Rather than providing every possible rule to the LLM, the system uses specialized components:

  • Classifiers: These determine which "entities" (text, images, shapes) are relevant to the query and whether the current document state (context) is even needed.
  • Entity-Aware Semantic Search: This retrieves only the most relevant few-shot examples from an "ODSL Sample Bank" to demonstrate how to handle similar requests.

The ODSL Interpreter

Once the LLM generates an ODSL program, a symbolic interpreter takes over. It validates the code, performs Automatic Code Correction (e.g., fixing typos in font names or clamping transparency values), and finally "transpiles" the ODSL into native Office-JS for execution.

Evaluation and Results

The researchers evaluated the system using a specialized PowerPoint Evaluation Set containing 197 test cases. These cases covered scenarios ranging from slide creation and content insertion to complex text rewriting.

Key findings include:

  • High Accuracy: The full system achieved a 96.06% pass rate on the benchmark.
  • The Power of Examples: Few-shot prompting was critical; without examples ($k=0$), the pass rate was only 10.42%. Performance peaked at $k=5$ examples.
  • Ablation Impact: Removing the Entity Classifier dropped the pass rate by ~12%, while removing Automatic Code Correction dropped it by ~5%, proving that symbolic "safety nets" are vital for catching LLM hallucinations.
  • Efficiency: The ODSL approach used roughly 1.5x fewer tokens than alternative verbose DSL designs, making the system faster and more cost-effective.

Discussion and Future Work

While the Semantic Interpreter shows immense promise, the authors identify several areas for expansion. The current exploration is focused primarily on PowerPoint; expanding ODSL to handle Excel's cells and formulas or Word's paragraph structures is a logical next step. Additionally, the system currently handles single commands, and future iterations will aim to maintain state across multi-turn dialogs.

Finally, the researchers noted that very abstract queries (e.g., "make this better") lack a single "ground truth," suggesting a need for more sophisticated, human-in-the-loop evaluation metrics to handle subjective user intent.

Summary updated

BibTeX
@misc{gandhi2023natural,
  author = {Apurva Gandhi and Thong Q. Nguyen and Huitian Jiao and Robert Steen and Ameya Bhatawdekar},
  title = {{Natural Language Commanding via Program Synthesis}},
  year = {2023},
  eprint = {2306.03460},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2306.03460},
}
Figure