Skip to content

Commit

Permalink
Finish alignment case study. Ready for review.
Browse files Browse the repository at this point in the history
  • Loading branch information
souzatharsis committed Dec 14, 2024
1 parent 657c9f1 commit 808a8a7
Show file tree
Hide file tree
Showing 33 changed files with 2,789 additions and 3,035 deletions.
Binary file modified tamingllms/_build/.doctrees/environment.pickle
Binary file not shown.
Binary file modified tamingllms/_build/.doctrees/notebooks/alignment.doctree
Binary file not shown.
Binary file modified tamingllms/_build/.doctrees/notebooks/evals.doctree
Binary file not shown.
Binary file modified tamingllms/_build/.doctrees/notebooks/output_size_limit.doctree
Binary file not shown.
Binary file modified tamingllms/_build/.doctrees/notebooks/structured_output.doctree
Binary file not shown.
126 changes: 126 additions & 0 deletions tamingllms/_build/html/_images/dpo_eval.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tamingllms/_build/html/_images/dpo_opt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tamingllms/_build/html/_images/rewards.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,197 changes: 455 additions & 742 deletions tamingllms/_build/html/_sources/notebooks/alignment.ipynb

Large diffs are not rendered by default.

101 changes: 101 additions & 0 deletions tamingllms/_build/html/_static/alignment/dpo_eval.d2
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
direction: right

# Response Generation in middle
generation: Response Generation {
direction: right
shape: rectangle
style.fill: "#FCF3CF"
style.stroke: "#F4D03F"

input: Models {
shape: rectangle
style.fill: "#FFFFFF"

base: Base LLM
aligned: Aligned LLM
}

task: Task {
shape: rectangle
style.fill: "#FFFFFF"
label: "Generate responses\nfor each prompt"
}

output: Output {
shape: document
style.fill: "#FFFFFF"
label: "Paired responses"
}

input.base -> task
input.aligned -> task
task -> output
}

# LLM Judge Scoring at bottom
scoring: LLM Judge Scoring {
direction: right
shape: rectangle
style.fill: "#EBF5FB"
style.stroke: "#3498DB"

scale: Safety Scale {
shape: rectangle
style.fill: "#FFFFFF"
label: "0.1: Inappropriate\n0.5: Somewhat aligned\n1.0: Fully aligned"
}

task: Task {
shape: rectangle
style.fill: "#FFFFFF"
label: "Evaluate responses"
}

output: Output {
shape: cylinder
style.fill: "#FFFFFF"
label: "Safety scores database"
}

scale -> task -> output
}

# Success criteria at very bottom
success: Success Criteria {
shape: page
style.fill: "#F5EEF8"
style.stroke: "#8E44AD"
label: "Compare score distributions\nAligned model should show\nhigher safety scores"
}

# Start with Evaluation Dataset at top
dataset: Evaluation Dataset {
direction: right
shape: rectangle
style.fill: "#E8F6F3"
style.stroke: "#2ECC71"

input: DPO Dataset {
shape: cylinder
style.fill: "#FFFFFF"
label: "User prompts that\ncould violate policy"
}

task: Task {
shape: rectangle
style.fill: "#FFFFFF"
label: "Sample n entries"
}

output: Output {
shape: document
style.fill: "#FFFFFF"
label: "n evaluation prompts"
}

input -> task -> output
}

scoring.output -> success: Analyze
generation.output -> scoring.task: Responses
dataset.output -> generation.task: Prompts
126 changes: 126 additions & 0 deletions tamingllms/_build/html/_static/alignment/dpo_eval.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletions tamingllms/_build/html/_static/alignment/dpo_opt.d2
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Data Inputs
data: Data Inputs {
shape: rectangle
style.fill: "#E8F6F3"
style.stroke: "#2ECC71"
direction: right

binary: ultrafeedback_binarized {
shape: cylinder
style.fill: "#FFFFFF"
}

policy: policy_aligned {
shape: cylinder
style.fill: "#FFFFFF"
}
}

# Model Input
model: Model Input {
shape: rectangle
style.fill: "#FCF3CF"
style.stroke: "#F4D03F"

base: SmolLM2-360M-Instruct {
shape: rectangle
style.fill: "#FFFFFF"
label: "SmolLM2-360M-Instruct"
}
}

# DPO Optimization
dpo: DPO Optimization {
shape: rectangle
style.fill: "#EBF5FB"
style.stroke: "#3498DB"
}

# Output Model
output: smolK-12 {
shape: rectangle
style.fill: "#F5EEF8"
style.stroke: "#8E44AD"
label: "SmolK-12 (Aligned Model)"
}

# Connections
data -> dpo
model -> dpo
dpo -> output

direction: down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tamingllms/_build/html/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@

<li class="toctree-l1 ">

<a href="notebooks/alignment.html" class="reference internal ">Alignment</a>
<a href="notebooks/alignment.html" class="reference internal ">Safety and Alignment</a>



Expand Down
2 changes: 1 addition & 1 deletion tamingllms/_build/html/markdown/intro.html
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@

<li class="toctree-l1 ">

<a href="../notebooks/alignment.html" class="reference internal ">Alignment</a>
<a href="../notebooks/alignment.html" class="reference internal ">Safety and Alignment</a>



Expand Down
2 changes: 1 addition & 1 deletion tamingllms/_build/html/markdown/toc.html
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@

<li class="toctree-l1 ">

<a href="../notebooks/alignment.html" class="reference internal ">Alignment</a>
<a href="../notebooks/alignment.html" class="reference internal ">Safety and Alignment</a>



Expand Down
1,184 changes: 497 additions & 687 deletions tamingllms/_build/html/notebooks/alignment.html

Large diffs are not rendered by default.

88 changes: 44 additions & 44 deletions tamingllms/_build/html/notebooks/evals.html

Large diffs are not rendered by default.

62 changes: 31 additions & 31 deletions tamingllms/_build/html/notebooks/output_size_limit.html

Large diffs are not rendered by default.

82 changes: 41 additions & 41 deletions tamingllms/_build/html/notebooks/structured_output.html

Large diffs are not rendered by default.

Binary file modified tamingllms/_build/html/objects.inv
Binary file not shown.
2 changes: 1 addition & 1 deletion tamingllms/_build/html/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@

<li class="toctree-l1 ">

<a href="notebooks/alignment.html" class="reference internal ">Alignment</a>
<a href="notebooks/alignment.html" class="reference internal ">Safety and Alignment</a>



Expand Down
2 changes: 1 addition & 1 deletion tamingllms/_build/html/searchindex.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tamingllms/_build/jupyter_execute/markdown/intro.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "f95d8b97",
"id": "9a3aac65",
"metadata": {},
"source": [
"(intro)=\n",
Expand Down
Loading

0 comments on commit 808a8a7

Please sign in to comment.