Demonstration Selection via Shared Logical Structure

This direction is merged into another direction: semantic-logical misalignment. Its last version stays readable and citable here.

Version 1 of 175 papers102 conceptsfrozen 2026-10-04

Large Language Models (LLMs) are famously sensitive to the "few-shot" examples provided in a prompt. A slight change in the choice or order of these demonstrations can swing a model's performance from expert-level to total failure. Traditionally, researchers have relied on semantic similarity—using tools like K-Nearest Neighbors (KNN) to find examples that share the same keywords or topics as the user's query.

However, a growing body of research suggests that for complex tasks, what a problem is about matters far less than how it is solved. This shift in perspective has led to a new paradigm: selecting in-context demonstrations based on their underlying logical structure rather than surface-level text similarity.

The Semantic Similarity Trap

If you ask an LLM to solve a word problem about calculating interest rates, a standard retriever might provide a few-shot example about a bank. While the topic matches, the logic might not; the bank example might involve simple addition, while the query requires compound interest formulas.

Researchers like Dan Iter and Reid Pryzant have shown that effective demonstration selection depends more on shared logical structure and task formatting than on surface-level vocabulary. In In-Context Demonstration Selection with Cross Entropy Difference, they argue that the best examples act as "meta-gradients," clarifying the required reasoning pattern for the model.

Mapping the Latent Logic

To move beyond keywords, researchers are developing ways to map problems into a "logic space." The goal is to identify the "skills" or "functional building blocks" required for a solution.

One prominent approach is LaRS (Latent Reasoning Skills), developed by Haozhu Wang and Zifan Xu. In Latent Skill Discovery for Chain-of-Thought Reasoning, they use unsupervised learning to map rationales into a latent space. Instead of matching a query to a similar-looking question, LaRS matches the query's predicted "latent skill" to the skills demonstrated in a bank of examples. This ensures that the model receives a template for the correct procedural steps, even if the problem domain is entirely different.

Similarly, Anlai Zhou and colleagues introduced the concept of a "latent learningscape" in Latent Learningscape Guided In-context Learning. They characterize demonstrations by their functional utility—specifically, their ability to help a model solve problems it previously failed. This moves the selection criteria from "does this look like the query?" to "does this provide the missing logic the model needs?"

Retrieving the Reasoning Path

If we want to match logic, we need to know the model's intended "path." Several new frameworks use a "draft-then-retrieve" strategy.

In DQ-LoRe: Dual Queries with Low Rank Approximation Re-ranking for In-Context Learning, Jing Xiong and others propose using a preliminary, model-generated reasoning path as part of the search query. By combining the original question with this "draft" chain-of-thought, the system can find examples that align with the required logical trajectory.

Chen Chen and Chengwei Qin take this further with Iterative Demonstration Selection (IDS). As described in In-Context Learning with Iterative Demonstration Selection, the framework uses the model's own zero-shot reasoning to pick the best few-shot examples, iteratively refining the selection to balance similarity and logical diversity.

From Instances to Abstract Routines

The most recent work in this area attempts to move away from specific examples entirely, focusing instead on abstract "routines."

Chen Si 0005 and Zhiting Hu introduced ArcMemo, a system that distills modular, reusable reasoning patterns into a "concept-level" memory. In ArcMemo: Abstract Reasoning Composition with Lifelong LLM Memory, they show that retrieving these abstract concepts is more effective than standard vector similarity when the relationship between a task and a solution is subtle or non-obvious.

This philosophy also extends to personalization. Jieyong Kim and Tongyoung Kim developed RPM (Reasoning-Level Personalization), which discovers a user's unique decision-making logic from their history. As detailed in Reasoning-Level Personalization for Black-Box Large Language Models, the system retrieves historical examples that share the user's underlying reasoning structure, rather than just matching keywords from their past queries.

Why It Works

The success of these methods reveals a fundamental truth about LLMs: they are highly effective at structural analogy. When we provide an example that shares the same "skeleton" of operations—even if the "flesh" of the topic is different—we reduce the noise the model has to filter through. By prioritizing the reasoning path, we guide the model toward the correct functional relationship, transforming in-context learning from a game of keyword matching into a process of logical alignment.

Papers in this version

Showing 60 of 75 papers.

History & citationVersion 1 · 2026-10-04

Merged into another direction · Permanent link

View frozen version 1

Cite this direction

Latest version (a living page):

@misc{lacuna_demonstration_selection_via_shared_logic_e414b69b,
  title = {Demonstration Selection via Shared Logical Structure},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/demonstration-selection-via-shared-logical-structure/rdr_e414b69b1af14ce7b31e48e0a0cd0b3c},
  note = {Latest version of a living research direction; cite a version for a fixed text. Accessed 2026-11-23},
}

This exact version (version 1, frozen text):

@misc{lacuna_demonstration_selection_via_shared_logic_e414b69b_v1,
  title = {Demonstration Selection via Shared Logical Structure},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/demonstration-selection-via-shared-logical-structure/rdr_e414b69b1af14ce7b31e48e0a0cd0b3c/v/1},
  note = {Version 1, frozen 2026-10-04. Accessed 2026-11-23},
}