프롬프트 가중치

Prompt weighting

프롬프트 안의 특정 단어에 괄호와 숫자로 더 강하게 또는 더 약하게 반영하라고 지정하는 문법.

다른 이름: Prompt emphasisAttention weighting
···
html
<div class="wrap">
  <div class="promptbar">호수 위의 (산:<b id="w">1.1</b>), 노을</div>
  <canvas id="cv"></canvas>
</div>
css
.wrap{position:relative;width:100%;height:100%}
#cv{position:absolute;inset:0;width:100%;height:100%}
.promptbar{position:absolute;top:10px;left:10px;right:10px;z-index:2;padding:7px 10px;border-radius:10px;
  background:rgba(13,13,18,0.55);backdrop-filter:blur(6px);border:1px solid rgba(255,255,255,0.15);
  font-size:11px;color:#f1f0ec;font-family:ui-monospace,monospace}
.promptbar b{color:var(--accent)}
js
const cv = document.getElementById('cv'), ctx = cv.getContext('2d');
const wEl = document.getElementById('w');
function fit() { const dpr = Math.min(devicePixelRatio || 1, 2); cv.width = innerWidth * dpr; cv.height = innerHeight * dpr; ctx.setTransform(dpr, 0, 0, dpr, 0, 0); }
addEventListener('resize', fit); fit();

function render(weight) {
  const w = innerWidth, h = innerHeight;
  const g = ctx.createLinearGradient(0, 0, 0, h);
  g.addColorStop(0, 'hsl(28 70% 60%)'); g.addColorStop(1, 'hsl(255 40% 22%)');
  ctx.fillStyle = g; ctx.fillRect(0, 0, w, h);
  ctx.beginPath(); ctx.arc(w * 0.72, h * 0.28, Math.min(w, h) * 0.08, 0, Math.PI * 2); ctx.fillStyle = 'hsl(45 90% 78%)'; ctx.fill();
  ctx.fillStyle = 'hsl(210 35% 20%)'; ctx.fillRect(0, h * 0.82, w, h * 0.18);
  const scale = 0.45 + weight * 0.4;
  const sat = 20 + weight * 35;
  const baseY = h * 0.82, peakY = baseY - h * 0.42 * scale, halfW = w * 0.22 * scale;
  const cx = w * 0.42;
  ctx.beginPath(); ctx.moveTo(cx - halfW, baseY); ctx.lineTo(cx, peakY); ctx.lineTo(cx + halfW, baseY); ctx.closePath();
  ctx.fillStyle = 'hsl(255 ' + sat + '% ' + (22 + weight * 6) + '%)'; ctx.fill();
}
let t = 0;
setInterval(() => {
  t += 0.045;
  const weight = 1.1 + Math.sin(t) * 0.7;
  wEl.textContent = weight.toFixed(1);
  render(weight);
}, 50);
render(1.1);

프롬프트의 각 토큰은 임베딩 벡터로 바뀌어 생성 과정을 이끄는 조건에 기여합니다. 가중치 문법(예: 단어 뒤에 배율을 붙이는 방식)은 그 토큰이 조건에 기여하는 크기를 다른 단어들과 합쳐지기 전에 키우거나 줄입니다. 가중치를 올리면 그 개념이 구도·크기·채도 면에서 더 도드라지고, 낮추면 배경 쪽으로 옅어집니다.

문법은 도구마다 다릅니다 — 괄호와 숫자, 반복되는 기호, 대괄호로 약화 표시 등 표기는 제각각이지만 "이 토큰의 기여도를 수치로 조절한다"는 메커니즘 자체는 공통입니다.

가중치를 극단적으로 높인다고 그 개념이 비례해서 커지지는 않습니다. 일정 지점을 넘으면 단순히 더 많이 반영되는 게 아니라 색이 깨지거나 이미지가 뭉개지는 식으로 무너지기 쉽습니다.

아래 데모는 실제 토큰 가중치 계산 대신, 프롬프트 문구 속 숫자가 오르내리는 것에 맞춰 그림 속 한 요소(산)의 크기·채도만 함께 오르내리게 해서 "가중치가 그 요소의 비중을 조절한다"를 흉내 낸 시뮬레이션입니다.

언제 쓰나

프롬프트 안의 여러 개념 중 특정 하나만 더 부각하거나 눌러야 할 때 씁니다. 문장을 통째로 다시 쓰기보다 국소적으로 조정하고 싶을 때 유용합니다.