Módulo 6: Embedding Operations
Interpolation & Blending
Linear Interpolation
def interpolate(emb_a, emb_b, alpha=0.5):
"""Interpolar entre 2 embeddings"""
return alpha * emb_a + (1 - alpha) * emb_b
# Ejemplo
emb_cat = get_emb("cat")
emb_dog = get_emb("dog")
# Alpha = 0.5 → punto medio
emb_mid = interpolate(emb_cat, emb_dog, alpha=0.5)
# Buscar concepto más cercano
find_nearest(emb_mid) # "pet", "animal"
Smooth Transitions
# Transición gradual
for alpha in [0.0, 0.25, 0.5, 0.75, 1.0]:
emb = interpolate(emb_happy, emb_sad, alpha)
nearest = find_nearest(emb)
print(f"Alpha {alpha}: {nearest}")
# Output:
# Alpha 0.0: happy
# Alpha 0.25: cheerful
# Alpha 0.5: neutral
# Alpha 0.75: melancholy
# Alpha 1.0: sad
Applications
Content generation:
# Blend de estilos
emb_formal = get_emb("formal professional tone")
emb_casual = get_emb("casual friendly tone")
emb_balanced = interpolate(emb_formal, emb_casual, alpha=0.5)
# Use como prompt embedding para generation
Resumen
- ✅ Interpolation: Blend semántico
- ✅ Alpha: Control de mezcla (0-1)
- ✅ Use case: Transiciones suaves, style blending
Módulo 6 - Cápsula 03