2026-01-15 20:10:19 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div class="prompt-visualizer">
|
2026-02-06 03:34:50 +08:00
|
|
|
|
<div class="viz-card">
|
|
|
|
|
|
<div class="input-display">
|
|
|
|
|
|
<span class="label">Prompt:</span>
|
|
|
|
|
|
<span class="text">"cyberpunk cat, neon lights, futuristic city"</span>
|
|
|
|
|
|
</div>
|
2026-01-15 20:10:19 +08:00
|
|
|
|
|
2026-02-06 03:34:50 +08:00
|
|
|
|
<div class="tokens-row">
|
|
|
|
|
|
<div
|
|
|
|
|
|
v-for="(token, index) in tokens"
|
|
|
|
|
|
:key="index"
|
|
|
|
|
|
class="token-pill"
|
|
|
|
|
|
:style="{ opacity: 0.4 + (token.weight * 0.6) }"
|
|
|
|
|
|
>
|
|
|
|
|
|
{{ token.text }}
|
2026-02-18 17:38:10 +08:00
|
|
|
|
<div class="tooltip">
|
|
|
|
|
|
关注度: {{ (token.weight * 100).toFixed(0) }}%
|
|
|
|
|
|
</div>
|
2026-01-15 20:10:19 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2026-02-06 03:34:50 +08:00
|
|
|
|
|
2026-02-18 17:38:10 +08:00
|
|
|
|
<div class="arrow-down">
|
|
|
|
|
|
⬇️ CLIP Encoding & Attention
|
|
|
|
|
|
</div>
|
2026-02-06 03:34:50 +08:00
|
|
|
|
|
|
|
|
|
|
<div class="image-map">
|
|
|
|
|
|
<!-- Abstract representation of an image being attended to -->
|
2026-02-18 17:38:10 +08:00
|
|
|
|
<div
|
|
|
|
|
|
class="map-layer"
|
|
|
|
|
|
style="background: #2b0055; opacity: 0.9;"
|
|
|
|
|
|
>
|
2026-02-06 03:34:50 +08:00
|
|
|
|
<span>City Base</span>
|
|
|
|
|
|
</div>
|
2026-02-18 17:38:10 +08:00
|
|
|
|
<div
|
|
|
|
|
|
class="map-layer"
|
|
|
|
|
|
style="background: #ff00aa; width: 60%; height: 60%; opacity: 0.8;"
|
|
|
|
|
|
>
|
2026-02-06 03:34:50 +08:00
|
|
|
|
<span>Neon Glow</span>
|
|
|
|
|
|
</div>
|
2026-02-18 17:38:10 +08:00
|
|
|
|
<div
|
|
|
|
|
|
class="map-layer"
|
|
|
|
|
|
style="background: #fff; width: 30%; height: 30%; border-radius: 50%;"
|
|
|
|
|
|
>
|
2026-02-06 03:34:50 +08:00
|
|
|
|
<span>Cat</span>
|
2026-01-15 20:10:19 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
2026-02-06 03:34:50 +08:00
|
|
|
|
<div class="info-bar">
|
|
|
|
|
|
<span class="icon">💡</span>
|
|
|
|
|
|
<span>
|
|
|
|
|
|
<strong>交叉注意力 (Cross-Attention):</strong>
|
|
|
|
|
|
AI 在画画时,每画一笔都会回头看一眼 Prompt。当它画背景时,"city" 单词会亮起来;当它画主角时,"cat" 单词会亮起来。
|
|
|
|
|
|
</span>
|
2026-01-15 20:10:19 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
|
import { ref } from 'vue'
|
|
|
|
|
|
|
|
|
|
|
|
const tokens = ref([
|
2026-02-06 03:34:50 +08:00
|
|
|
|
{ text: 'cyberpunk', weight: 0.8 },
|
2026-01-15 20:10:19 +08:00
|
|
|
|
{ text: 'cat', weight: 1.0 },
|
|
|
|
|
|
{ text: 'neon', weight: 0.7 },
|
|
|
|
|
|
{ text: 'lights', weight: 0.6 },
|
2026-02-06 03:34:50 +08:00
|
|
|
|
{ text: 'futuristic', weight: 0.5 },
|
|
|
|
|
|
{ text: 'city', weight: 0.9 }
|
2026-01-15 20:10:19 +08:00
|
|
|
|
])
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
.prompt-visualizer {
|
|
|
|
|
|
margin: 20px 0;
|
2026-02-06 03:34:50 +08:00
|
|
|
|
font-family: var(--vp-font-family-base);
|
2026-01-15 20:10:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-06 03:34:50 +08:00
|
|
|
|
.viz-card {
|
|
|
|
|
|
background: var(--vp-c-bg-soft);
|
|
|
|
|
|
border: 1px solid var(--vp-c-divider);
|
|
|
|
|
|
border-radius: 12px;
|
|
|
|
|
|
padding: 20px;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 16px;
|
2026-01-15 20:10:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-06 03:34:50 +08:00
|
|
|
|
.input-display {
|
|
|
|
|
|
font-family: monospace;
|
2026-01-15 20:10:19 +08:00
|
|
|
|
background: var(--vp-c-bg);
|
2026-02-06 03:34:50 +08:00
|
|
|
|
padding: 8px 12px;
|
2026-01-15 20:10:19 +08:00
|
|
|
|
border-radius: 6px;
|
2026-02-06 03:34:50 +08:00
|
|
|
|
border: 1px solid var(--vp-c-divider);
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
text-align: center;
|
2026-01-15 20:10:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-06 03:34:50 +08:00
|
|
|
|
.label {
|
|
|
|
|
|
color: var(--vp-c-text-2);
|
|
|
|
|
|
margin-right: 8px;
|
2026-01-15 20:10:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-06 03:34:50 +08:00
|
|
|
|
.tokens-row {
|
2026-01-15 20:10:19 +08:00
|
|
|
|
display: flex;
|
2026-02-06 03:34:50 +08:00
|
|
|
|
flex-wrap: wrap;
|
|
|
|
|
|
gap: 8px;
|
|
|
|
|
|
justify-content: center;
|
2026-01-15 20:10:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-06 03:34:50 +08:00
|
|
|
|
.token-pill {
|
|
|
|
|
|
background: var(--vp-c-brand);
|
|
|
|
|
|
color: white;
|
|
|
|
|
|
padding: 4px 12px;
|
|
|
|
|
|
border-radius: 16px;
|
|
|
|
|
|
font-size: 13px;
|
2026-01-15 20:10:19 +08:00
|
|
|
|
font-weight: 600;
|
2026-02-06 03:34:50 +08:00
|
|
|
|
position: relative;
|
|
|
|
|
|
cursor: help;
|
|
|
|
|
|
transition: transform 0.2s;
|
2026-01-15 20:10:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-06 03:34:50 +08:00
|
|
|
|
.token-pill:hover {
|
|
|
|
|
|
transform: scale(1.1);
|
|
|
|
|
|
z-index: 10;
|
2026-01-15 20:10:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-06 03:34:50 +08:00
|
|
|
|
.tooltip {
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
bottom: 100%;
|
|
|
|
|
|
left: 50%;
|
|
|
|
|
|
transform: translateX(-50%);
|
|
|
|
|
|
background: rgba(0,0,0,0.8);
|
|
|
|
|
|
color: white;
|
|
|
|
|
|
padding: 4px 8px;
|
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
|
font-size: 10px;
|
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
|
opacity: 0;
|
|
|
|
|
|
pointer-events: none;
|
|
|
|
|
|
transition: opacity 0.2s;
|
|
|
|
|
|
margin-bottom: 6px;
|
2026-01-15 20:10:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-06 03:34:50 +08:00
|
|
|
|
.token-pill:hover .tooltip {
|
|
|
|
|
|
opacity: 1;
|
2026-01-15 20:10:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-06 03:34:50 +08:00
|
|
|
|
.arrow-down {
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
color: var(--vp-c-text-2);
|
2026-01-15 20:10:19 +08:00
|
|
|
|
font-weight: 600;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-06 03:34:50 +08:00
|
|
|
|
.image-map {
|
|
|
|
|
|
width: 200px;
|
|
|
|
|
|
height: 200px;
|
|
|
|
|
|
background: #000;
|
|
|
|
|
|
position: relative;
|
2026-02-14 20:23:34 +08:00
|
|
|
|
border-radius: 6px;
|
2026-01-15 20:10:19 +08:00
|
|
|
|
overflow: hidden;
|
2026-02-06 03:34:50 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: center;
|
2026-01-15 20:10:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-06 03:34:50 +08:00
|
|
|
|
.map-layer {
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
color: rgba(255,255,255,0.8);
|
|
|
|
|
|
font-size: 10px;
|
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
|
box-shadow: 0 0 20px rgba(0,0,0,0.5);
|
2026-01-15 20:10:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-06 03:34:50 +08:00
|
|
|
|
.info-bar {
|
|
|
|
|
|
margin-top: 16px;
|
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
|
color: var(--vp-c-text-2);
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
gap: 8px;
|
|
|
|
|
|
line-height: 1.4;
|
|
|
|
|
|
padding: 0 8px;
|
2026-01-15 20:10:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
</style>
|