Skip to content

Commit a4dd1c0

Browse files
committed
Merge branch 'gh-pages' of https://github.com/CHATS-lab/verbalized-sampling into gh-pages
2 parents b7b565b + a1e69a4 commit a4dd1c0

File tree

3 files changed

+226
-68
lines changed

3 files changed

+226
-68
lines changed

app/(dashboard)/page.tsx

Lines changed: 74 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -611,30 +611,28 @@ export default function HomePage() {
611611
</div>
612612
</div>
613613
</section>
614+
614615

615616
{/* Introduction */}
616-
<section className="py-8 bg-white">
617-
<div className="max-w-6xl mx-auto px-8 sm:px-12 lg:px-16">
617+
<section className="py-12 bg-white">
618+
<div className="max-w-4xl mx-auto px-8 sm:px-12 lg:px-16">
618619
<div className="text-center">
619-
<img
620-
src="/images/intro_teaser.jpg"
621-
alt="Verbalized Sampling Introduction"
622-
className="w-full max-w-4xl mx-auto rounded-lg shadow-lg"
623-
/>
624-
<div className="text-sm text-gray-500 mt-2">
625-
<strong>Figure 1:</strong> Overview of Verbalized Sampling (VS) for unlocking LLM diversity.
620+
<div className="text-center mb-8">
621+
<img
622+
src="/images/intro_teaser.jpg"
623+
alt="Verbalized Sampling Introduction"
624+
className="w-full max-w-4xl mx-auto rounded-lg shadow-lg"
625+
/>
626+
<div className="text-sm text-gray-500 mt-2">
627+
<strong>Figure 1:</strong> Overview of Verbalized Sampling (VS) for unlocking LLM diversity.
628+
</div>
626629
</div>
627-
</div>
628-
</div>
629-
</section>
630630

631-
<section className="py-12 bg-white">
632-
<div className="max-w-6xl mx-auto px-8 sm:px-12 lg:px-16">
633-
<div className="text-center">
634631
<h2 className="text-xl font-bold text-gray-700 tracking-tight sm:text-3xl mb-8">
635632
Abstract
636633
</h2>
637-
<div className="max-w-6xl mx-auto">
634+
635+
<div className="max-w-4xl mx-auto">
638636
<p className="text-base text-gray-600 leading-relaxed text-left">
639637
Post-training alignment often reduces LLM diversity, leading to a phenomenon known as <em>mode collapse</em>.
640638
Unlike prior work that attributes this effect to algorithmic limitations, we identify a fundamental, pervasive data-level driver: <em>typicality bias</em> in preference data,
@@ -649,9 +647,49 @@ export default function HomePage() {
649647
</div>
650648
</div>
651649
</div>
650+
</section>
651+
652+
{/* Verbalized Sampling: Title & Description left, install/code right */}
653+
<section className="py-12 bg-gray-50">
654+
<div className="max-w-6xl mx-auto px-8 sm:px-12 lg:px-16">
655+
<div className="lg:grid lg:grid-cols-2 lg:gap-12 lg:items-center">
656+
<div>
657+
<h2 className="text-xl font-bold text-gray-700 tracking-tight sm:text-3xl mb-6">
658+
Make Your LLMs More Creative!<br />
659+
<span className="text-orange-500"> With Verbalized Sampling</span>
660+
</h2>
661+
<div className="space-y-4 text-base text-gray-600">
662+
<p>
663+
Run Verbalized Sampling and unlock diverse LLM generations in seconds.
664+
Just install and use our open-source package!
665+
</p>
666+
<p>
667+
Check our{' '}
668+
<a
669+
href="https://github.com/CHATS-lab/verbalize-sampling"
670+
className="underline hover:text-orange-500 font-semibold"
671+
target="_blank"
672+
rel="noopener noreferrer"
673+
>
674+
GitHub
675+
</a>{' '}
676+
for more details.
677+
</p>
678+
</div>
679+
</div>
680+
<div className="mt-8 lg:mt-0">
681+
<div className="w-full">
682+
{(() => {
683+
const { Terminal } = require("./terminal_package");
684+
return <Terminal />;
685+
})()}
686+
</div>
687+
</div>
688+
</div>
689+
</div>
652690
</section>
653691

654-
<section className="py-12 bg-gray-50">
692+
<section className="py-12 bg-white">
655693
<div className="max-w-6xl mx-auto px-8 sm:px-12 lg:px-16">
656694
<div className="lg:grid lg:grid-cols-2 lg:gap-12 lg:items-center">
657695
<div>
@@ -686,7 +724,7 @@ export default function HomePage() {
686724
</div>
687725
</section>
688726

689-
<section className="py-12 bg-white">
727+
<section className="py-12 bg-gray-50">
690728
<div className="max-w-6xl mx-auto px-8 sm:px-12 lg:px-16">
691729
<div className="lg:grid lg:grid-cols-2 lg:gap-12 lg:items-center">
692730
<div className="mt-8 lg:mt-0">
@@ -727,7 +765,7 @@ export default function HomePage() {
727765
</div>
728766
</section>
729767

730-
<section className="py-12 bg-gray-50">
768+
<section className="py-12 bg-white">
731769
<div className="max-w-6xl mx-auto px-8 sm:px-12 lg:px-16">
732770
<div className="max-w-6xl mx-auto text-center">
733771
<h2 className="text-xl font-bold text-gray-700 tracking-tight sm:text-3xl mb-6">
@@ -745,24 +783,24 @@ export default function HomePage() {
745783
<strong>Figure 4:</strong> Qualitative and quantitative examples of Verbalized Sampling on creative writing, dialogue simulation, and enumerative open-ended QA.
746784
</p>
747785
</div>
748-
<div className="space-y-4 text-base text-gray-600 text-left">
749-
<p>
750-
Our comprehensive experiments on multiple tasks demonstrate that Verbalized Sampling significantly improves the diversity-quality trade-off across tasks and model families,
751-
without compromising factual accuracy and safety.
752-
</p>
753-
<p>
754-
As shown in Figure 4, for <strong>story writing</strong>, VS improves the output diversity.
755-
For <strong>dialogue simulation</strong>, VS simulates the donation amount distribution much closer to the human distribution, and generates more realistic persuasion behaviors.
756-
On the task of <strong>enumerative open-ended QA</strong>, we ask the model to "generate US states". We first query a pretraining corpus (RedPajama) to establish a "reference" distribution of US
757-
state names in the pretraining data. The verbalized probability distribution generated by VS, when averaged over 10 trials, closely aligns with this reference pretraining distribution (KL=0.12).
758-
In contrast, direct prompting collapses into a few modes, repeatedly outputting states like California and Texas.
759-
</p>
760-
</div>
786+
<div className="space-y-4 text-base text-gray-600 text-left max-w-5xl mx-auto xl:max-w-3xl">
787+
<p>
788+
Our comprehensive experiments on multiple tasks demonstrate that Verbalized Sampling significantly improves the diversity-quality trade-off across tasks and model families,
789+
without compromising factual accuracy and safety.
790+
</p>
791+
<p>
792+
As shown in Figure 4, for <strong>story writing</strong>, VS improves the output diversity.
793+
For <strong>dialogue simulation</strong>, VS simulates the donation amount distribution much closer to the human distribution, and generates more realistic persuasion behaviors.
794+
On the task of <strong>enumerative open-ended QA</strong>, we ask the model to "generate US states". We first query a pretraining corpus (RedPajama) to establish a "reference" distribution of US
795+
state names in the pretraining data. The verbalized probability distribution generated by VS, when averaged over 10 trials, closely aligns with this reference pretraining distribution (KL=0.12).
796+
In contrast, direct prompting collapses into a few modes, repeatedly outputting states like California and Texas.
797+
</p>
798+
</div>
761799
</div>
762800
</div>
763801
</section>
764802

765-
<section className="py-12 bg-white">
803+
<section className="py-12 bg-gray-50">
766804
<div className="max-w-6xl mx-auto px-8 sm:px-12 lg:px-16">
767805
<div className="lg:grid lg:grid-cols-2 lg:gap-12 lg:items-center">
768806
<div>
@@ -792,7 +830,7 @@ export default function HomePage() {
792830
</div>
793831
</section>
794832

795-
<section className="py-12 bg-gray-50">
833+
<section className="py-12 bg-white">
796834
<div className="max-w-6xl mx-auto px-8 sm:px-12 lg:px-16">
797835
<div className="lg:grid lg:grid-cols-2 lg:gap-12 lg:items-center">
798836
<div>
@@ -823,7 +861,7 @@ export default function HomePage() {
823861
</div>
824862
</section>
825863

826-
<section className="py-12 bg-white w-full">
864+
<section className="py-12 bg-gray-50 w-full">
827865
<div className="max-w-6xl mx-auto px-8 sm:px-12 lg:px-16">
828866
<div className="lg:grid lg:grid-cols-12 lg:gap-4">
829867
<div className="sm:text-center md:max-w-2xl md:mx-auto lg:col-span-7 lg:text-left">
@@ -845,7 +883,7 @@ export default function HomePage() {
845883
</section>
846884

847885
{/* BibTeX Citation */}
848-
<section className="py-12 bg-gray-50">
886+
<section className="py-12 bg-white">
849887
<div className="max-w-6xl mx-auto px-8 sm:px-12 lg:px-16">
850888
<div className="text-center">
851889
<h2 className="text-xl font-bold text-gray-700 sm:text-3xl mb-8">

app/(dashboard)/terminal_package.tsx

Lines changed: 150 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,129 @@ import { useState, useEffect } from 'react';
44
import { Copy, Check } from 'lucide-react';
55

66
export function Terminal() {
7-
const [terminalStep, setTerminalStep] = useState(0);
8-
const [copied, setCopied] = useState(false);
9-
const terminalSteps = [
10-
'conda create -n collabllm python=3.10',
11-
'conda activate collabllm',
12-
'pip install collabllm',
13-
'',
14-
'git clone https://github.com/Wuyxin/collabllm.git',
15-
'python -m scripts.engine.build_dataset <...>',
16-
'python -m scripts.train.{sft/*_dpo/ppo} <...>',
7+
const pipCommand = [
8+
'pip install verbalized-sampling'
179
];
1810

19-
useEffect(() => {
20-
const timer = setTimeout(() => {
21-
setTerminalStep((prev) =>
22-
prev < terminalSteps.length - 1 ? prev + 1 : prev
23-
);
24-
}, 500);
11+
const pythonCode = [
12+
'verbalize run \\',
13+
' --task joke \\',
14+
' --prompt "Tell me a joke about coffee." \\',
15+
' --model "gpt-4.1" \\',
16+
' --methods "direct vs_standard" \\',
17+
' --num-responses 10 \\',
18+
' --metrics "diversity joke_quality"'
19+
];
20+
21+
const allSteps = [...pipCommand, '', ...pythonCode];
22+
const [terminalStep, setTerminalStep] = useState(allSteps.length - 1);
23+
const [copied, setCopied] = useState(false);
2524

26-
return () => clearTimeout(timer);
27-
}, [terminalStep]);
2825

2926
const copyToClipboard = () => {
30-
navigator.clipboard.writeText(terminalSteps.join('\n'));
27+
navigator.clipboard.writeText(allSteps.join('\n'));
3128
setCopied(true);
3229
setTimeout(() => setCopied(false), 2000);
3330
};
3431

32+
const colorizeCode = (line: string) => {
33+
// Handle empty lines
34+
if (line.trim() === '') {
35+
return <span className="text-gray-500">&nbsp;</span>;
36+
}
37+
38+
// Handle comments
39+
if (line.trim().startsWith('#')) {
40+
return (
41+
<span className="text-gray-400">
42+
{line.replace('#', '')}
43+
</span>
44+
);
45+
}
46+
47+
// Handle pip install command
48+
if (line.includes('pip install')) {
49+
return (
50+
<>
51+
<span className="text-blue-400">pip</span>
52+
<span className="text-white"> install </span>
53+
<span className="text-yellow-300">verbalized-sampling</span>
54+
</>
55+
);
56+
}
57+
58+
// Handle verbalize command
59+
if (line.includes('verbalize run')) {
60+
return (
61+
<>
62+
<span className="text-blue-400">verbalize</span>
63+
<span className="text-white"> run </span>
64+
<span className="text-white">\\</span>
65+
</>
66+
);
67+
}
68+
69+
// Handle command line arguments (lines starting with spaces and --)
70+
if (line.trim().startsWith('--')) {
71+
const leadingSpaces = line.match(/^(\s*)/)?.[1] || '';
72+
const restOfLine = line.trim();
73+
// Convert spaces to non-breaking spaces to preserve them
74+
const preservedSpaces = leadingSpaces.replace(/ /g, '\u00A0');
75+
return (
76+
<>
77+
<span className="text-white">{preservedSpaces}</span>
78+
<span className="text-white">{restOfLine}</span>
79+
</>
80+
);
81+
}
82+
83+
// Handle import statements
84+
if (line.startsWith('from ') || line.startsWith('import ')) {
85+
const parts = line.split(' ');
86+
return (
87+
<>
88+
<span className="text-blue-400">{parts[0]}</span>
89+
<span className="text-white"> </span>
90+
<span className="text-green-300">{parts.slice(1).join(' ')}</span>
91+
</>
92+
);
93+
}
94+
95+
// Handle variable assignments
96+
if (line.includes(' = ')) {
97+
const [variable, ...rest] = line.split(' = ');
98+
return (
99+
<>
100+
<span className="text-yellow-300">{variable}</span>
101+
<span className="text-white"> = </span>
102+
<span className="text-blue-300">{rest.join(' = ')}</span>
103+
</>
104+
);
105+
}
106+
107+
// Handle function calls
108+
if (line.includes('(') && line.includes(')')) {
109+
const beforeParen = line.substring(0, line.indexOf('('));
110+
const parenContent = line.substring(line.indexOf('('), line.lastIndexOf(')') + 1);
111+
const afterParen = line.substring(line.lastIndexOf(')') + 1);
112+
113+
return (
114+
<>
115+
<span className="text-cyan-300">{beforeParen}</span>
116+
<span className="text-white">{parenContent}</span>
117+
<span className="text-white">{afterParen}</span>
118+
</>
119+
);
120+
}
121+
122+
// Default case
123+
return <span className="text-white">{line}</span>;
124+
};
125+
35126
return (
36-
<div className="w-full rounded-lg shadow-lg overflow-hidden bg-gray-900 text-white font-mono text-sm relative">
37-
<div className="p-4">
38-
<div className="flex justify-between items-center mb-4">
127+
<div className="w-full min-w-full rounded-lg shadow-lg overflow-hidden bg-gray-900 text-white font-mono text-sm relative">
128+
<div className="p-1">
129+
<div className="flex justify-between items-center mb-2">
39130
<div className="flex space-x-2">
40131
<div className="w-3 h-3 rounded-full bg-red-500"></div>
41132
<div className="w-3 h-3 rounded-full bg-yellow-500"></div>
@@ -54,14 +145,43 @@ export function Terminal() {
54145
</button>
55146
</div>
56147
<div className="space-y-2">
57-
{terminalSteps.map((step, index) => (
58-
<div
59-
key={index}
60-
className={`${index > terminalStep ? 'opacity-0' : 'opacity-100'} transition-opacity duration-300`}
61-
>
62-
<span className="text-green-400">$</span> {step}
63-
</div>
64-
))}
148+
{/* Pip Install Block */}
149+
<div className="space-y-1">
150+
{pipCommand.map((step, index) => (
151+
<div
152+
key={`pip-${index}`}
153+
className={`${index > terminalStep ? 'opacity-0' : 'opacity-100'} transition-opacity duration-300 whitespace-nowrap`}
154+
>
155+
<span className="text-green-400">$</span> {colorizeCode(step)}
156+
</div>
157+
))}
158+
</div>
159+
160+
{/* Separator */}
161+
<div className={`${pipCommand.length > terminalStep ? 'opacity-0' : 'opacity-100'} transition-opacity duration-300`}>
162+
<div className="text-gray-500">&nbsp;</div>
163+
</div>
164+
165+
{/* Python Code Block */}
166+
<div className="space-y-1">
167+
{pythonCode.map((step, index) => {
168+
const globalIndex = pipCommand.length + 1 + index;
169+
return (
170+
<div
171+
key={`python-${index}`}
172+
className={`${globalIndex > terminalStep ? 'opacity-0' : 'opacity-100'} transition-opacity duration-300 whitespace-pre`}
173+
>
174+
{step.trim() === '' ? (
175+
colorizeCode(step)
176+
) : (
177+
<>
178+
<span className="text-green-400">$</span> {colorizeCode(step)}
179+
</>
180+
)}
181+
</div>
182+
);
183+
})}
184+
</div>
65185
</div>
66186
</div>
67187
</div>

app/(dashboard)/terminal_prompt.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ export function Terminal_Prompt() {
99
const terminalSteps = [
1010
{ line: 'You are a helpful assistant. For each user query, generate a set of five responses. Each response should be approximately 200 words.', showPrompt: true },
1111
{ line: 'Return the responses each within a separate <response> tag.', showPrompt: false },
12-
{ line: 'Each <response> tag include a <text> and a numeric <probability>.', showPrompt: false },
13-
{ line: 'Please sample at random from the full distribution.', showPrompt: false },
12+
{ line: 'Each <response> tag must include a <text> and a numeric <probability>.', showPrompt: false },
13+
{ line: 'Randomly sample the responses from the full distribution.', showPrompt: false },
1414
{ line: '<user_query>Write a short story about a bear.</user_query>', showPrompt: true },
1515
];
1616

0 commit comments

Comments
 (0)