Skip to content

Commit d15e259

Browse files
committed
added stuff:
1 parent 7f3bd15 commit d15e259

File tree

2 files changed

+136
-0
lines changed

2 files changed

+136
-0
lines changed

index.html

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,31 @@
1414
<link href="./style.css" rel="stylesheet" type="text/css">
1515
<title>Refactoring Codebases through Library Design</title>
1616

17+
<!-- MathJax Configuration -->
18+
<script>
19+
window.MathJax = {
20+
tex: {
21+
inlineMath: [['$', '$'], ['\\(', '\\)']],
22+
displayMath: [['$$', '$$'], ['\\[', '\\]']],
23+
processEscapes: true,
24+
processEnvironments: true,
25+
macros: {
26+
program: '\\ensuremath{\\rho}',
27+
library: '\\ensuremath{\\mathcal{L}}',
28+
loss: ['\\ensuremath{\\ell}\\left( #1 \\right)', 1],
29+
sample: ['\\ensuremath{\\textsc{Sample}}\\left( #1 \\right)', 1],
30+
instance: 'Source'
31+
}
32+
},
33+
options: {
34+
ignoreHtmlClass: 'tex2jax_ignore',
35+
processHtmlClass: 'tex2jax_process'
36+
}
37+
};
38+
</script>
39+
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
40+
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
41+
1742
<script>
1843
function copyText() {
1944
var text = document.getElementById("citation-content")
@@ -81,6 +106,59 @@ <h2 id="contributions">Key Contributions</h2>
81106
</div>
82107
</section>
83108

109+
<section>
110+
<h2 id="project-goal">Problem Statement</h2>
111+
<p>We're tackling the challenge of refactoring code to make it more organized and efficient. Imagine you have several pieces of code that do similar things. Our goal is to create a unified library that captures the common patterns, significantly reducing the total code size while still supporting all original functionalities. This not only makes the code base smaller but also helps uncover new ways to use the code.</p>
112+
113+
<h3>How We Do It</h3>
114+
<p>Our approach focuses on finding refactorings that are both correct and simple.</p>
115+
<ul>
116+
<li><strong>Correctness</strong> is straightforward: Does the refactored code pass all the original tests?</li>
117+
<li><strong>Simplicity</strong> is more nuanced. We don't just count characters; we define simplicity using <strong>Minimum Description Length (MDL)</strong>. This means we're looking for code that is not only short but also natural, elegant, and extensible—like finding the most concise yet understandable way to express an idea, rather than just the shortest, potentially unreadable, version (think "Perl Golf" where the shortest code is often incomprehensible!).</li>
118+
</ul>
119+
120+
121+
<h3>The Math Behind It</h3>
122+
<p>Formally, given a set of original programs $\{\rho_n\}_{n=1}^N$, we want to find a new library $\mathcal{L}$ and refactored programs $\{\rho'_n\}_{n=1}^N$. We optimize the following objective:</p>
123+
124+
<div class="math-display">
125+
$$
126+
\ell(\mathcal{L}, \{\rho'_n\}) =
127+
\begin{cases}
128+
-\log p_{\text{LM}}(\mathcal{L}) + \sum_n -\log p_{\text{LM}}(\rho'_n\mid\mathcal{L}) & \forall \rho_n, \, \tau(\rho_n) \leq \tau(\rho'_n) \\
129+
\infty & \text{otherwise}
130+
\end{cases}
131+
$$
132+
</div>
133+
<p style="margin-top: 1em;">
134+
Here, $p_{\text{LM}}(\mathcal{L})$ is the probability of the library under a language model, and $p_{\text{LM}}(\rho'_n\mid\mathcal{L})$ is the probability of the refactored program $\rho'_n$ given the library $\mathcal{L}$. The constraint $\tau(\rho_n) \leq \tau(\rho'_n)$ ensures that the refactored programs pass at least as many tests as the originals. The loss function $\ell$ thus encourages solutions that are both correct and have minimal description length, as measured by the language model.
135+
</p>
136+
<p>In simpler terms, we're looking for a library and refactored programs that pass at least as many tests as the originals, and whose combined "description length" (how hard they are to describe using a language model) is minimized. This ensures our refactored code is not only correct but also intuitively simple and well-structured.</p>
137+
</section>
138+
139+
<section>
140+
<h2 id="librarian-method">Librarian: Refactoring Code to Create Libraries</h2>
141+
<p>
142+
Librarian is our method for refactoring existing code into a more organized and reusable library. By identifying common patterns and abstracting them into shared building blocks, Librarian compresses collections of programs while migrating them to use these new components—reducing overall code size and often improving functionality. The method operates on a simple sample-and-rerank framework, progressively building a library of useful functions to maximize our refactoring objective. <strong>Figure 1</strong> illustrates the overall process.
143+
</p>
144+
<p>
145+
Librarian operates on a simple sample-and-rerank framework to maximize our refactoring objective described above. It maintains and grows a library of useful functions as part of this objective.
146+
</p>
147+
<p>Concretely, our framework follows:</p>
148+
<div class="math-display">
149+
$$
150+
\mathcal{L}^\star, \left\{ \rho^\star_n \right\} = \arg\min_{\mathcal{L}, \left\{ \rho'_n \right\} \in \mathrm{Sample}(\left\{ \rho_n \right\})}
151+
\ell(\mathcal{L}, \left\{ \rho'_n \right\}).
152+
$$
153+
</div>
154+
<h3>How It Works:</h3>
155+
<ul>
156+
<li><strong>Clustering:</strong> We group related input programs into "tuples" by having a language model summarize the code, then clustering these summaries. This focuses the language model's attention on relevant code chunks.</li>
157+
<li><strong>Sampling Refactorings:</strong> For each tuple, Librarian retrieves relevant existing library functions. Then, using the original code and retrieved functions as context, a language model proposes K candidate refactorings.</li>
158+
<li><strong>Ranking with Compression:</strong> All K candidates are evaluated. We select the refactoring that scores highest on quality and maintains (or improves) test accuracy compared to the original code. New, useful library functions from the chosen refactoring are then added to the Librarian library for future use.</li>
159+
</ul>
160+
</section>
161+
84162
<!-- <section>
85163
<h2 id="video">Video</h2>
86164
<iframe height="528" src="#" title="Supplemental video" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>

style.css

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,4 +369,62 @@ footer {
369369
.contribution-box:nth-child(2) strong {
370370
color: var(--nord12);
371371
background-color: rgba(208, 135, 112, 0.15);
372+
}
373+
374+
/* Project Goal section */
375+
#project-goal {
376+
margin-top: 2em;
377+
}
378+
379+
#project-goal h3 {
380+
font-size: 1.3em;
381+
margin: 1.5em 0 0.8em 0;
382+
color: var(--nord0);
383+
font-weight: 600;
384+
}
385+
386+
#project-goal ul {
387+
margin: 1em 0;
388+
padding-left: 2em;
389+
}
390+
391+
#project-goal li {
392+
margin: 0.5em 0;
393+
line-height: 1.6;
394+
}
395+
396+
#project-goal strong {
397+
color: var(--nord10);
398+
font-weight: 600;
399+
}
400+
401+
/* Math equation styling */
402+
.math-display {
403+
text-align: center;
404+
margin: 1.5em 0;
405+
padding: 1em;
406+
background-color: var(--nord5);
407+
border-radius: 6px;
408+
border: 1px solid var(--nord4);
409+
overflow-x: auto;
410+
}
411+
412+
.math-display .MathJax {
413+
font-size: 1.1em;
414+
}
415+
416+
/* Responsive adjustments for project goal section */
417+
@media screen and (max-width: 768px) {
418+
#project-goal h3 {
419+
font-size: 1.2em;
420+
}
421+
422+
#project-goal ul {
423+
padding-left: 1.5em;
424+
}
425+
426+
.math-display {
427+
padding: 0.75em;
428+
margin: 1em 0;
429+
}
372430
}

0 commit comments

Comments
 (0)