skills/skillxiv-v0.0.2-claude-opus-4.6/capmagine-visual-reasoning/SKILL.md
CapImagine teaches models to explicitly imagine through text rather than latent reasoning, significantly improving visual reasoning performance.
npx skillsauth add ADu2021/skillXiv capmagine-visual-reasoningInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Multimodal language models struggle with visual reasoning tasks because their hidden (latent) reasoning produces negligible impact on final answers. While explicit chain-of-thought helps textual reasoning, simply moving it to latent space doesn't work for vision tasks. The reason: visual perception requires explicit symbolic reasoning that models can't perform implicitly in token embeddings.
CapImagine solves this by encouraging models to explicitly imagine the visual scene using text before answering. Rather than relying on hidden representations to bridge vision and reasoning, the model explicitly describes what it sees, imagines intermediate steps, and uses these concrete representations to reason. This dramatically improves visual reasoning accuracy.
The core insight comes from causal mediation analysis: when latent tokens are perturbed, they produce minimal impact on final answers (latent-answer disconnect). This reveals a fundamental limitation of implicit reasoning for vision tasks. Explicit imagination—asking the model to describe what it sees and imagines—provides the concrete symbolic grounding needed for robust visual reasoning.
This connects to cognitive science: human visual reasoning isn't latent; it's explicit—we mentally simulate and verbalize what we observe before drawing conclusions.
CapImagine is a prompting technique—no model modification needed. Here's how to implement it:
Design prompt templates that explicitly cue imagination of the visual scene:
# Standard visual reasoning prompt (baseline)
def standard_visual_qa(image_caption, question):
prompt = f"""
Image caption: {image_caption}
Question: {question}
Answer: """
return prompt
# CapImagine prompt: explicit imagination instruction
def capmagine_visual_qa(image_caption, question):
prompt = f"""
Image caption: {image_caption}
Before answering, imagine the scene described above. What do you see?
Describe the key objects, their positions, colors, and relationships:
[Imagination]
Now, using your imagination of the scene, answer the question:
Question: {question}
Answer: """
return prompt
Implement an inference wrapper that collects explicit imagination outputs:
def generate_with_imagination(model, tokenizer, image, question):
"""
Generate visual reasoning with explicit imagination.
Returns both imagination and final answer.
"""
# Get image caption or encoding (using existing vision encoder)
image_caption = get_image_caption(model, tokenizer, image)
# Create imagination prompt
imagination_prompt = f"""
Image caption: {image_caption}
Describe the visual scene in detail. What objects are present?
What are their spatial relationships and colors?
Description: """
# Generate imagination
imagination_tokens = model.generate(
imagination_prompt,
max_length=150,
temperature=0.7
)
imagination_text = tokenizer.decode(imagination_tokens)
# Create reasoning prompt incorporating imagination
reasoning_prompt = f"""
Image caption: {image_caption}
Scene description: {imagination_text}
Now answer the question using the scene description above:
Question: {question}
Answer: """
# Generate final answer
answer_tokens = model.generate(
reasoning_prompt,
max_length=100,
temperature=0.7
)
answer_text = tokenizer.decode(answer_tokens)
return {
'imagination': imagination_text,
'answer': answer_text,
'full_prompt': reasoning_prompt
}
Implement training data augmentation with explicit reasoning annotations:
def create_vision_qa_with_imagination(
dataset,
model,
tokenizer,
annotation_batch_size=32
):
"""
Augment visual QA dataset with explicit imaginations.
Use these (image, imagination, question, answer) tuples for supervised fine-tuning.
"""
augmented_data = []
for image, question, ground_truth_answer in dataset:
# Generate imagination
imagination_output = generate_with_imagination(
model, tokenizer, image, question
)
# Create training example with explicit imagination
example = {
'image': image,
'question': question,
'imagination': imagination_output['imagination'],
'answer': ground_truth_answer,
'full_reasoning': imagination_output['full_prompt']
}
augmented_data.append(example)
return augmented_data
When to Use:
When NOT to Use:
Prompting Strategies:
Hyperparameters:
imagination_max_length: 100–200 tokens typicaltemperature: 0.7–0.9 for creative imaginationanswer_max_length: 50–150 depending on taskFine-tuning for Better Performance: If you have QA data with ground truth answers, create (image, imagination_prompt → imagination, question → answer) pairs and fine-tune the model. This teaches it to generate high-quality imaginations that support reasoning.
Results:
Reference: Imagination Helps Visual Reasoning, But Not Yet in Latent Space
testing
Uses flow maps as look-ahead operators to enable principled reward-guided diffusion by predicting trajectory endpoints at any denoising step. Deploy when applying rewards or preferences to diffusion trajectories with meaningful gradients throughout generation.
testing
Train language models where each expert learns independently on closed datasets, enabling flexible inference with selective data inclusion or exclusion. 41% performance improvement while allowing users to opt out of specific data sources without retraining.
data-ai
Understand how token generation flexibility in diffusion LMs paradoxically constrains reasoning, as models exploit ordering flexibility to avoid uncertain tokens, and apply simplified approaches that preserve parallel decoding benefits. Use when optimizing diffusion-based language models for reasoning tasks.
devops
Enable LLM agents to improve continuously during deployment by constructing structured experience libraries through self-reflection on successes and failures—achieving 23% improvement on reasoning without gradient-based parameter updates or external training.