Spaces:
Sleeping
Sleeping
File size: 464 Bytes
6e375cd fee1f1e 6e375cd fee1f1e 6e375cd 5f10669 6e375cd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
# diagram.py
import matplotlib.pyplot as plt
import tempfile
def show_transformer_diagram():
fig, ax = plt.subplots(figsize=(6, 4))
ax.text(0.5, 0.6, 'Input → Embedding → Self-Attention → FFN → Output',
fontsize=12, ha='center', va='center', wrap=True)
ax.axis('off')
with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as tmpfile:
plt.savefig(tmpfile.name, bbox_inches="tight")
return tmpfile.name
|