Evaluating LLM Complex Instruction Following: A Case Study on Geometric Drawing Code Generation
As large language models (LLMs) rapidly evolve, accurately evaluating their true capabilities—particularly in complex reasoning and strict instruction following—has become a critical challenge for developers. Traditional toy-level tests are no longer sufficient to differentiate models. This article explores how to deeply assess an LLM's instruction following and logical reasoning by using a high-difficulty geometric drawing HTML animation generation task: constructing a regular heptagon using a marked ruler. By analyzing model performance across multi-step logic, trajectory constraints, and feature implementations, we outline key evaluation dimensions and offer best practices for enterprise-level AI selection and application.
With the rapid iteration of large language model (LLM) technology, a wide variety of lightweight and flagship models have emerged. For developers and enterprise users, cutting through marketing hype to accurately evaluate a model’s true capabilities—especially its performance in complex logical reasoning and strict instruction following—has become a critical pain point in technology selection. Traditional “toy-level” test questions can no longer widen the gap between models; we need more challenging, comprehensive test scenarios. This article explores how to conduct an in-depth examination of an LLM’s instruction-following ability and logical reasoning level through a high-difficulty geometric drawing HTML animation generation test.
1. Test Scenario Design: Why Complex Geometric Drawing?
When evaluating the fundamental capabilities of LLMs, HTML animation generation tests are a highly valuable entry point. While simple page generation can no longer challenge modern LLMs, combining complex mathematical logic, rigorous step constraints, and specific functional requirements creates an excellent capability threshold.
We designed a classic “constructing a regular heptagon with a marked ruler” HTML code generation task. This prompt appears to be a simple front-end coding exercise, but it actually encompasses strict requirements across multiple dimensions:
- Multi-step logical reasoning: The model is required to sequentially complete steps such as taking a square, drawing the perpendicular bisector of the base, drawing a circle with a specific center and radius, and performing complex constraint solving using the “marked ruler”.
- Tool and trajectory constraints: It explicitly states that while using a compass produces point trajectories during the drawing process, the model’s generated code must only “leave marks on necessary parts”. This heavily tests the model’s fine-grained control over the drawing process.
- Additional feature implementation: Finally, the model is required to add a feature that exports the output as a GIF, testing its comprehensive ability to use third-party front-end libraries or the underlying Canvas API.
Faced with such a prompt, the model must not only “know how to write code” but also “understand mathematical logic” and “strictly follow long instructions”.
2. In-depth Analysis of Model Performance: The Game of Instruction Following and Logical Reasoning
In actual testing, we observed that different LLMs exhibited completely different performance paths when facing this task, deeply reflecting their differences in underlying logic construction.
Ideal Performance: Deep Reasoning and Strict Compliance
Some top-performing models (including some newly released lightweight models) demonstrated surprising potential. Upon receiving the prompt, the model showed a deep “thinking” process:
- Logical deconstruction: The model first reasoned through the mathematical principle of the “marked ruler construction” (neusis), clarifying the mapping of each step in the coordinate system.
- Precise control: When generating HTML5 Canvas and JavaScript code, the model accurately controlled the visibility of the drawing paths. For example, when drawing a circle, it ensured that only “necessary marks” were left by temporarily drawing and then erasing, or by using path clipping techniques.
- Functional closure: Ultimately, it not only drew the regular heptagon correctly but also perfectly implemented the animation recording and export function by introducing a front-end GIF encoding library.
Here is an example of the code logic structure generated by such excellent models:
// Step 1: Define the canvas and basic geometric elementsconst canvas = document.getElementById('geometryCanvas');const ctx = canvas.getContext('2d');// Step 2: Simulate marked ruler constraint to solve for the circle centerfunction findCenterWithMarkedRuler(square, circleE) {// Implement complex geometric intersection logic// Ensure only key intersection trajectories are recorded}// Step 3: Animation rendering and GIF exportfunction animateConstruction() {// Draw the construction process step by step, controlling trajectory visibility// Call Gif.js or similar library to implement GIF export}
Although these models occasionally fluctuate in generation speed, the quality of their final output code and their compliance with the prompt are perfect, demonstrating foundational capabilities that rival or even surpass some traditional flagship models.
Common Failures: Hallucinations and Forced Patching
Conversely, some models that perform strongly in regular conversations easily deviate severely in such complex tasks:
- Deviating from instructions: The model failed to truly understand the mathematical meaning of the “marked ruler” and, after attempting and failing to reason through it, abandoned the path specified in the prompt.
- Logical hallucinations: To achieve the end result of “drawing a regular heptagon,” the model started “getting clever” and introduced additional drawing steps into the code that did not exist in the original prompt at all (such as directly using built-in polygon drawing functions instead of solving through compass-and-straightedge constraints).
- Surface satisfaction with internal errors: The final generated HTML page did indeed display a regular heptagon, but because its underlying implementation logic completely violated the prompt’s requirements, this result is worthless in a rigorous mathematical and programming context.
3. Summary of Core LLM Evaluation Dimensions
Through the above test, we can abstract several key dimensions for evaluating the true capabilities of LLMs:
- Long instruction constraint: Excellent models can maintain attention amidst complex prompts of hundreds or thousands of words, without omitting key constraints (such as “only leave marks on necessary parts”) and without overstepping to perform unauthorized operations.
- Complex logical reasoning: Faced with non-standard algorithms (like marked ruler construction), the model must possess the ability to translate mathematical logic described in natural language into precise code logic, rather than simply calling off-the-shelf APIs.
- Anti-hallucination ability: When encountering its own knowledge blind spots, whether the model chooses to fabricate steps to forcibly achieve a result or can reason through the context to gradually approach the correct answer is an important watershed distinguishing the intelligence level of models.
4. Enterprise-Level Application Insights and Best Practices
For enterprises and developers, selecting an LLM should not solely focus on benchmark scores, but rather on its “obedience” and “reasoning depth” in real, complex business scenarios. When building enterprise-level AI applications, the following practices are recommended:
- Build private test sets: For complex logic scenarios in your own business (such as complex report generation rules or specific data processing flows), build high-difficulty test sets similar to the aforementioned geometric drawing to conduct blind tests on candidate models.
- Leverage general cloud services to build closed loops: In the process of model deployment and application development, you can rely on general LLM services and cloud computing infrastructure (such as object storage, container platforms, etc.) provided by providers like Baidu AI Cloud to build a complete testing pipeline from model inference and code generation to result rendering. The standardized interfaces and general model services offered by Baidu AI Cloud can effectively support the rapid iteration of such complex instruction-driven applications.
- Optimize prompt structure: For models prone to hallucinations, explicitly state prohibitions in the prompt design (e.g., “Do not use functions that directly draw polygons; intersections must be calculated geometrically”) to constrain their behavioral boundaries.
Conclusion
The capability boundaries of LLMs are constantly being broken. Through excellent architectural design and training strategies, lightweight models can also demonstrate stunning strength in high-difficulty logical reasoning tasks. Through strict HTML tests like “constructing a regular heptagon with a marked ruler,” we can not only see through the “glamorous output” on the model’s surface but also strike directly at the core of its instruction following and logical reasoning. In the future implementation of AI applications, accurately evaluating these core capabilities will be the critical cornerstone for technical teams to achieve success.
