Adam Bandel


Gallery of Conceptual Lenses

Nov 2025
Type: web-app
Code: 2k lines
Files: 3
Active: May 2025 to Nov 2025
Stack:
PythonStreamlitOpenAI Embeddingssentence-transformersNumPyscikit-learnUMAPPlotly
Tags:
aideveloper-toolsdata

Overview

Gallery of Conceptual Lenses takes a problem statement and picks a set of lenses for it, where a lens is a frame of thought: a discipline, a philosophy, a reasoning mode, a cognitive bias and so on. Each lens has to be relevant to the problem, and together they have to be as far apart from each other in embedding space as possible. That’s the reverse of semantic search, which returns whatever is closest. The chosen lenses go into a prompt template, so a model can work the problem from each of them.

The lenses come from a taxonomy of more than 1,000 concepts in 12 categories, among them disciplines, epistemic schools, rhetorical styles, value frameworks, formal structures, cognitive bias probes, time horizons and scales. A greedy MaxMin selection then picks lenses that clear a relevance threshold and sit as far as possible from the ones already chosen.

Screenshots

Lens Discovery Interface

UMAP Diversity Visualization

Lens Diversity Heatmap

Problem

One day I spent a long time researching prompt engineering and current work on latent space, and went down a side rabbit hole: how do you extend a model’s horizon?

When you send a prompt to an LLM, it activates the neurons and connections in the hidden layers that relate to the prompt, and a lot of the latent space goes unused. That’s generally good, because it’s efficient and gives you something related to what you asked. But if you want the model to be more creative, you want it searching through things as different from the prompt as possible.

People have the same habit with familiar frameworks: an economist sees market failures, an engineer sees systems to optimize, a philosopher sees ethical dilemmas. Semantic search makes it worse, because it returns content similar to what you already asked. The goal was a way to pull in perspectives from anywhere (quantum physics, indigenous knowledge systems, game theory, deep ecology, chaos mathematics), in whatever combination covers the most ground around the problem.

Approach

Stack

Challenges

Outcomes

Every pair of chosen lenses is at least the minimum separation apart, and a pairwise similarity heatmap shows how much any two of them overlap.

The taxonomy is embedded once and cached to disk, and composite lenses are averaged from cached vectors instead of being embedded, so after that first pass a new problem needs one embedding call. The cache cuts API cost by more than 95%.

The drawback is that working from lenses that far apart makes the model less focused. But when I want it to think outside the box or take several approaches to something, I’ve found it a great tool for brainstorming and coming up with new ideas.

Implementation Notes

The selection starts from the lens most similar to the problem, then keeps adding whichever remaining candidate is farthest from its nearest already-chosen lens:

def step4_pick_far_apart_lenses(relevant_lenses, n_lenses, min_separation):
    # Anchor: highest similarity to problem
    chosen = [max(relevant_lenses, key=lambda x: x.similarity)]

    while len(chosen) < n_lenses:
        best_candidate = None
        best_min_dist = -1

        for candidate in remaining:
            # MaxMin criterion: maximize the minimum distance
            min_dist = min(cosine_distance(candidate, c) for c in chosen)
            if min_dist > best_min_dist and min_dist >= min_separation:
                best_min_dist = min_dist
                best_candidate = candidate

        if best_candidate:
            chosen.append(best_candidate)
        else:
            break  # No candidates meet separation threshold

    return chosen

main.py checks sys.streamlit_is_running to tell whether it’s running under Streamlit, so the same file serves as the web UI and as a command-line tool for batch runs.


Related Posts