Where Are CreativeMath Prompts Stored? Complete Guide to the Prompt Library

CreativeMath prompts are stored in the src/prompts package, with core definitions located in src/prompts/prompts.py and exposed through src/prompts/__init__.py for easy import across the codebase.

The junyiye/creativemath repository implements a modular prompt engineering system that isolates all large language model (LLM) prompt templates from generation and evaluation logic. Understanding where CreativeMath prompts are stored is essential for customizing prompt engineering experiments or debugging model interactions.

Core Prompt Storage Location

The prompt library follows a self-contained architecture designed to facilitate rapid iteration on prompt wording without modifying business logic.

The src/prompts Package Structure

All prompt-related code resides within the src/prompts directory:

  • src/prompts/prompts.py — Contains the core prompt-generation functions that programmatically assemble multiline strings using Python f-strings and template logic.
  • src/prompts/__init__.py — Re-exports the four primary helper functions, enabling clean import statements throughout the project.

This separation ensures that prompt engineering changes remain localized to a single file (prompts.py), reducing the risk of introducing bugs into generation or evaluation workflows.

Key Functions in prompts.py

The src/prompts/prompts.py file defines four specialized functions that construct prompts for different stages of the CreativeMath pipeline:

Function Purpose Called From
load_novel_solution_generation_prompt Generates a prompt requesting a novel mathematical solution given a problem and k reference solutions src/generation.py (line 60)
load_correctness_evaluation_prompt Constructs a prompt asking the model to verify if a new solution matches reference solutions in correctness src/evaluation.py (line 89)
load_coarse_grained_novelty_evaluation_prompt Builds a prompt for coarse-grained novelty assessment using the first k references src/evaluation.py (line 134)
load_fine_grained_novelty_evaluation_prompt Creates a prompt for fine-grained novelty evaluation using remaining references after the first k src/evaluation.py (line 189)

Each function returns a formatted string that is passed directly to ModelWrapper.generate_response via the generation and evaluation modules.

How Prompts Are Used in the Codebase

The prompt functions are imported using the clean namespace provided by src/prompts/__init__.py, then invoked at specific execution points in the generation and evaluation pipelines.

Generation Pipeline (generation.py)

In src/generation.py, the system calls load_novel_solution_generation_prompt at line 60 to construct the prompt for creating novel mathematical solutions:

from prompts import load_novel_solution_generation_prompt

# Inside the generation workflow

prompt = load_novel_solution_generation_prompt(
    problem=problem_text,
    solutions=reference_solutions,
    k=num_references
)
response = model_wrapper.generate_response(prompt)

This invocation passes the mathematical problem statement, a list of existing reference solutions, and the parameter k (specifying how many references to include in the context).

Evaluation Pipeline (evaluation.py)

The src/evaluation.py module utilizes three distinct prompt functions to assess solution quality and novelty:

from prompts import (
    load_correctness_evaluation_prompt,
    load_coarse_grained_novelty_evaluation_prompt,
    load_fine_grained_novelty_evaluation_prompt
)

# Correctness check (line 89)

correctness_prompt = load_correctness_evaluation_prompt(
    problem, reference_solutions, candidate_solution
)

# Coarse novelty check (line 134)

coarse_prompt = load_coarse_grained_novelty_evaluation_prompt(
    problem, reference_solutions[:k], candidate_solution, k
)

# Fine novelty check (line 189)

fine_prompt = load_fine_grained_novelty_evaluation_prompt(
    problem, reference_solutions[k:], candidate_solution, k
)

Each prompt targets a specific evaluation dimension, allowing the system to programmatically assess both mathematical correctness and solution novelty through structured LLM queries.

Practical Code Examples

To retrieve and inspect the actual prompt text used by CreativeMath, import the relevant functions from the prompts package and call them with sample data.

Loading a Generation Prompt

This example demonstrates how to generate the prompt used for novel solution creation:

from prompts import load_novel_solution_generation_prompt

problem = "Find the sum of the first 100 natural numbers."
solutions = [
    "Solution 1: Use the formula n(n+1)/2 → 100·101/2 = 5050.",
    "Solution 2: Pair numbers (1+100), (2+99), … → 50 pairs × 101 = 5050."
]
k = 2

prompt = load_novel_solution_generation_prompt(problem, solutions, k)
print(prompt)

The function returns a formatted string containing the problem context, the k reference solutions, and instructions requesting a novel approach distinct from the provided examples.

Loading an Evaluation Prompt

To inspect the correctness evaluation template:

from prompts import load_correctness_evaluation_prompt

problem = "Compute the area of a circle with radius 3."
reference = ["Solution 1: π·3² = 9π"]
new_solution = "The area is 9π because π * 3 * 3 = 9π."

prompt = load_correctness_evaluation_prompt(problem, reference, new_solution)
print(prompt)

This constructs a prompt that asks the language model to verify whether the candidate solution mathematically agrees with the reference solutions, returning a boolean judgment and explanation.

Summary

CreativeMath stores all LLM prompts in a dedicated, modular location to facilitate rapid experimentation and maintenance:

  • Primary storage: src/prompts/prompts.py contains the core prompt-generation functions.
  • Public interface: src/prompts/__init__.py exposes four key functions for clean imports.
  • Generation usage: src/generation.py (line 60) calls load_novel_solution_generation_prompt to create novel solution requests.
  • Evaluation usage: src/evaluation.py (lines 89, 134, 189) utilizes correctness and novelty prompt functions to assess solution quality.
  • Architecture benefit: Isolating prompts in src/prompts allows prompt engineering changes without modifying generation or evaluation logic.

Frequently Asked Questions

How do I import the CreativeMath prompt functions in my own script?

Import the four main functions directly from the prompts package using the clean namespace exposed by src/prompts/__init__.py:

from prompts import (
    load_novel_solution_generation_prompt,
    load_correctness_evaluation_prompt,
    load_coarse_grained_novelty_evaluation_prompt,
    load_fine_grained_novelty_evaluation_prompt,
)

This import pattern is used consistently throughout src/generation.py and src/evaluation.py.

Can I modify the prompt templates without changing the generation logic?

Yes. Because all prompt text is constructed in src/prompts/prompts.py, you can edit the wording, formatting, or instructions within that file without touching src/generation.py or src/evaluation.py. The helper functions return formatted strings, so any changes to the template logic automatically propagate to all call sites that invoke these functions.

What is the difference between coarse-grained and fine-grained novelty prompts?

The load_coarse_grained_novelty_evaluation_prompt function evaluates novelty against the first k reference solutions, providing a broad initial filter for obvious similarities. In contrast, load_fine_grained_novelty_evaluation_prompt checks the candidate solution against the remaining references (those after the first k), performing a more detailed novelty assessment. Both are called sequentially in src/evaluation.py (lines 134 and 189) to ensure comprehensive novelty detection.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →