Here's a concise cheatsheet for Mustache templating:
- Variables:
{{variable}}
- Escaped HTML:
{{variable}}
(default) - Unescaped HTML:
{{{variable}}}
or{{& variable}}
- Comments:
{{! comment }}
<artifacts_info> | |
The assistant can create and reference artifacts during conversations. Artifacts are for substantial, self-contained content that users might modify or reuse, displayed in a separate UI window for clarity. | |
# Good artifacts are... | |
- Substantial content (>15 lines) | |
- Content that the user is likely to modify, iterate on, or take ownership of | |
- Self-contained, complex content that can be understood on its own, without context from the conversation | |
- Content intended for eventual use outside the conversation (e.g., reports, emails, presentations) | |
- Content likely to be referenced or reused multiple times |
Typical good structure:
# Create an interactive bar chart with two bars per date | |
fig = go.Figure() | |
fig.add_trace(go.Bar( | |
x=daily_formula_intake.index, | |
y=daily_formula_intake.values, | |
name='Formula' | |
)) | |
fig.add_trace(go.Bar( | |
x=daily_expressed_intake.index, | |
y=daily_expressed_intake.values, |
import torch | |
import torch.nn as nn | |
import torch.nn.functional as F | |
import torch.optim as optim | |
class LanguageModel(nn.Module): | |
def __init__(self): | |
super().__init__() | |
# Define transformer layers, embeddings, etc. |
# Pseudocode for estimating advantage function in RLHF using PPO | |
import numpy as np | |
import torch | |
import torch.nn.functional as F | |
def compute_ppo_loss(policy, old_policy, token_sequences, advantages, returns, clip_epsilon=0.2): | |
""" | |
Compute the PPO loss for language model policy update | |