System Specification

1. Document Role

This document defines what the research platform must do, what components it contains, and what contracts must remain stable during implementation.

It is the primary functional specification for:

Related documents:

2. Scope

This specification covers the research prototype used to study interactive prompt-embedding steering for diffusion models.

It includes:

It does not define:

3. System Goals

The system must:

4. High-Level System Overview

The system consists of six major parts:

  1. Frontend: interface for prompt entry, image display, feedback collection, replay, and export
  2. Experiment Controller: orchestrates session lifecycle and round progression
  3. Generation Engine: encodes prompts, applies steering, and renders images
  4. Sampling Module: proposes steering candidates under a configured policy
  5. Preference / Update Module: learns from feedback and computes the next incumbent
  6. Storage and Evaluation Layer: persists state, computes metrics, and reconstructs replay data

Runtime architecture diagram

5. Primary User Workflow

The canonical workflow is:

  1. create or load an experiment
  2. create a session with prompt and configuration
  3. encode the base prompt and initialize steering state
  4. propose round candidates
  5. render candidate images
  6. collect user feedback
  7. update preference state and incumbent steering vector
  8. repeat until the user stops
  9. export or replay the session

6. Core Invariants

The following must remain true:

7. Core Research Abstractions

7.1 Experiment

An experiment defines a reusable research configuration.

Required fields:

7.2 Session

A session is one interactive run of one experiment with one prompt.

Required fields:

7.3 Round

A round is one propose-render-feedback-update cycle.

Required fields:

7.4 Candidate

A candidate is one proposed point in steering space.

Required fields:

7.5 Feedback Event

A feedback event records one user action on a round.

Required fields:

8. Lifecycle State Model

8.1 Experiment states

Recommended states:

8.2 Session states

Recommended states:

Session lifecycle diagram - paused

8.3 Candidate render states

Recommended states:

9. Frontend Specification

9.1 Design principles

The frontend should be intentionally simple:

9.2 Main pages

A. Experiment Dashboard

Purpose:

Required elements:

B. Session Setup Page

Required inputs:

Required actions:

C. Interactive Steering Page

Required layout:

Required actions:

Required grid behavior:

Required feedback widgets:

D. Replay / Analysis Page

Purpose:

9.3 Frontend state model

The frontend should maintain:

9.4 Accessibility requirements

The interface must support:

9.5 Frontend failure behavior

The UI must:

10. Backend Specification

Baseline stack:

10.2 Backend modules

A. API layer

Responsibilities:

B. Orchestrator

Responsibilities:

C. Embedding manager

Responsibilities:

D. Sampling manager

Responsibilities:

E. Generation manager

Responsibilities:

F. Preference / update manager

Responsibilities:

G. Evaluation manager

Responsibilities:

H. Storage layer

Responsibilities:

11. Data Model Specification

11.1 Core tables or collections

experiments

sessions

rounds

candidates

feedback_events

artifacts

11.2 File artifacts

Artifacts to store:

12. API Specification

12.1 API conventions

The API should follow these rules:

12.2 Example endpoints

POST /experiments

Create a new experiment.

Request body:

Response:

GET /experiments

List experiments.

GET /experiments/{experiment_id}

Return full experiment metadata and configuration.

POST /sessions

Create a session from an experiment or full config.

Request body:

Response:

GET /sessions/{session_id}

Return session summary and current state.

POST /sessions/{session_id}/rounds/next

Generate the next round of candidates.

Response:

POST /rounds/{round_id}/feedback

Submit feedback for a round.

Request body:

Response:

GET /sessions/{session_id}/replay

Return ordered rounds, artifacts, and summaries for replay.

POST /frontend-events

Persist browser-side trace events for debugging and auditability.

GET /sessions/{session_id}/export

Export logs, metrics, and artifact manifest.

13. Steering Representation Specification

13.1 Required modes

The system must support at least:

13.2 Default steering equation

For low-dimensional steering:

E(z) = E0 + U z

Where:

13.3 Basis construction strategies

The system should support:

13.4 Representation constraints

The steering representation must support:

14. Sampling Strategy Specification

14.1 Sampler contract

Each sampler must implement:

14.2 Required baseline samplers

The system must include:

14.3 Optional advanced samplers

The system may later include:

14.4 Batch composition controls

Per round, the system should log and optionally constrain:

15. Feedback Mechanism Specification

15.1 Unified schema

All frontend feedback must normalize into one internal event format.

The backend should derive pairwise preferences from richer signals when useful.

15.2 Required feedback modes

The system must support:

15.3 Feedback quality controls

The platform should support:

16. Update Mechanism Specification

16.1 Updater contract

Each updater must implement:

16.2 Required baseline updaters

The system must include:

16.3 Optional advanced updaters

The system may later include:

16.4 Stabilization controls

Each updater should optionally support:

17. Seed Policy Specification

17.1 Required seed modes

The system must support:

17.2 Seed metadata requirements

For every candidate, persist:

18. Evaluation and Metrics Specification

The platform must support both online and offline evaluation.

18.1 Interaction metrics

18.2 Optimization metrics

18.3 Robustness metrics

18.4 Diversity metrics

18.5 Drift metrics

18.6 Human-centered metrics

19. Logging and Reproducibility Specification

19.1 Mandatory logging

Every experiment must log:

19.2 Replay requirements

A replay must reconstruct:

19.3 Versioning

Version independently:

20. Error Handling and Fault Tolerance

The system must handle:

Behavioral requirements:

21. Security and Privacy Notes

Minimum requirements:

22. Operational Constraints

The v1 system should assume:

23. Suggested Project Structure

project/
  app/
    api/
      routes_experiments.py
      routes_sessions.py
      routes_rounds.py
      routes_exports.py
    core/
      config.py
      logging.py
      schema.py
    engine/
      prompt_encoder.py
      steering_basis.py
      generation.py
      seeds.py
    samplers/
      base.py
      random_local.py
      exploit_orthogonal.py
      uncertainty.py
      thompson.py
      quality_diversity.py
    feedback/
      normalization.py
      validation.py
    updaters/
      base.py
      winner_copy.py
      winner_average.py
      linear_pref.py
      bradley_terry.py
      bayesian.py
    evaluation/
      metrics.py
      replay.py
      reports.py
    storage/
      db.py
      models.py
      repository.py
    frontend/
      templates/
        index.html
        setup.html
        session.html
        replay.html
      static/
        styles.css
        app.js
  tests/
    unit/
    integration/
    e2e/
    fixtures/
  scripts/
    run_dev.py
    export_session.py
    replay_session.py
  docs/
    system_specification.md

24. Minimal Viable Research Prototype

24.1 Mandatory capabilities

24.2 Optional v1 extensions

25. Implementation Deliverables

An implementation generated from this specification should produce:

  1. a Python FastAPI backend
  2. a simple HTML/CSS/JS frontend
  3. modular sampler interfaces
  4. modular updater interfaces
  5. a working diffusion wrapper
  6. persistence and export support
  7. a test suite aligned with the test specification
  8. local setup documentation

26. Summary

This system is a controlled research platform for interactive user-guided image generation through prompt-embedding steering.

Its architectural priorities are: