From 4781d2afd09136970b803cc732c4055eec8bb7c8 Mon Sep 17 00:00:00 2001
From: Justin <9146678+brickfrog@users.noreply.github.com>
Date: Tue, 9 Jul 2024 18:42:18 -0400
Subject: [PATCH] Quartz sync: Jul 9, 2024, 6:42 PM
---
content/daily/2024/07/2024-07-06.md | 2 +-
content/daily/2024/07/2024-07-07.md | 9 +-
content/daily/2024/07/2024-07-08.md | 52 +++++++
content/daily/2024/07/2024-07-09.md | 51 ++++++
content/index.md | 2 +
...ngAbstractionofThoughtMakesLanguage2024.md | 146 ++++++++++++++++++
functions.ts | 36 ++++-
quartz.config.ts | 8 +-
quartz.layout.ts | 11 +-
quartz/components/Backlinks.tsx | 2 +-
quartz/components/CollapsibleHeaders.tsx | 47 ++++++
quartz/components/ContentMeta.tsx | 24 +++
quartz/components/index.ts | 2 +
quartz/components/styles/contentMeta.scss | 8 +-
quartz/styles/base.scss | 4 +-
quartz/styles/custom.scss | 73 ++++++++-
16 files changed, 451 insertions(+), 26 deletions(-)
create mode 100644 content/daily/2024/07/2024-07-08.md
create mode 100644 content/daily/2024/07/2024-07-09.md
create mode 100644 content/references/hongAbstractionofThoughtMakesLanguage2024.md
create mode 100644 quartz/components/CollapsibleHeaders.tsx
diff --git a/content/daily/2024/07/2024-07-06.md b/content/daily/2024/07/2024-07-06.md
index 37eaaf137..2ba8a66f0 100644
--- a/content/daily/2024/07/2024-07-06.md
+++ b/content/daily/2024/07/2024-07-06.md
@@ -2,7 +2,7 @@
title: 2024-07-06
author: ["Justin"]
date: 2024-07-06T06:20:00-04:00
-lastmod: 2024-07-06T19:04:54-04:00
+lastmod: 2024-07-08T09:04:26-04:00
draft: false
---
diff --git a/content/daily/2024/07/2024-07-07.md b/content/daily/2024/07/2024-07-07.md
index 04aaf9af3..0333718ca 100644
--- a/content/daily/2024/07/2024-07-07.md
+++ b/content/daily/2024/07/2024-07-07.md
@@ -2,7 +2,7 @@
title: 2024-07-07
author: ["Justin"]
date: 2024-07-07T05:16:00-04:00
-lastmod: 2024-07-07T07:49:51-04:00
+lastmod: 2024-07-07T21:23:11-04:00
draft: false
---
@@ -14,9 +14,10 @@ draft: false
### Tasks {#tasks}
-- [ ] Chinese
-- [ ] Read
-- [ ] Anki stuff
+- [X] Chinese
+ - 646!
+- [X] Read
+- [X] Anki stuff
- [X] CSS spacing
- Think I got it - distinct CSS for h\* + ul vs. p, cumbersome, but with
variables shouldn't hurt too much to change down the line.
diff --git a/content/daily/2024/07/2024-07-08.md b/content/daily/2024/07/2024-07-08.md
new file mode 100644
index 000000000..77045d106
--- /dev/null
+++ b/content/daily/2024/07/2024-07-08.md
@@ -0,0 +1,52 @@
+---
+title: 2024-07-08
+author: ["Justin"]
+date: 2024-07-08T06:23:00-04:00
+lastmod: 2024-07-08T22:24:59-04:00
+draft: false
+---
+
+
+
+## Agenda {#agenda}
+
+
+
+### Tasks {#tasks}
+
+- [X] Chinese
+ - 657!
+- [X] Read
+- [X] Build
+
+
+
+
+
+
+
+## Notes {#notes}
+
+
+
+### Reading {#reading}
+
+- Reading [Hong, Ruixin and Zhang, Hongming and Pan, Xiaoman and Yu, Dong and
+ Zhang, Changshui :: Abstraction-of-Thought Makes Language Models Better
+ Reasoners]({{< relref "../../../references/hongAbstractionofThoughtMakesLanguage2024.md" >}})[^fn:1]
+ - Need to come back to this, will finish tomorrow.
+
+
+
+
+
+
+
+## Journal {#journal}
+
+Weekend over. Womp. Want to mess around with some LLM stuff today. Got the
+reference section of the site up. Should put all books, etc. etc. stuff there.
+
+
+
+[^fn:1]: Ruixin Hong et al., “Abstraction-of-Thought Makes Language Models Better Reasoners” (arXiv, June 2024).
diff --git a/content/daily/2024/07/2024-07-09.md b/content/daily/2024/07/2024-07-09.md
new file mode 100644
index 000000000..d2257aeb0
--- /dev/null
+++ b/content/daily/2024/07/2024-07-09.md
@@ -0,0 +1,51 @@
+---
+title: 2024-07-09
+author: ["Justin"]
+date: 2024-07-09T07:07:00-04:00
+lastmod: 2024-07-09T15:32:37-04:00
+draft: false
+---
+
+
+
+## Agenda {#agenda}
+
+
+
+### Tasks {#tasks}
+
+- [ ] Chinese
+- [ ] Read
+- [ ] Build
+
+
+
+
+
+
+
+## Notes {#notes}
+
+
+
+### Reading {#reading}
+
+
+
+#### [Blow Out Kits – One Medic’s Perspective](https://civiliangunfighter.wordpress.com/2015/06/17/blow-out-kits-one-medics-perspective/) medic {#blow-out-kits-one-medic-s-perspective}
+
+- Just kind of wandered into this, I should take a first-aid class.
+
+
+
+
+
+
+
+
+
+## Journal {#journal}
+
+Slower day. Stuck doing non-computer stuff so a bit behind on things.
+
+
diff --git a/content/index.md b/content/index.md
index f0462d09c..0c91c4072 100644
--- a/content/index.md
+++ b/content/index.md
@@ -28,3 +28,5 @@ Before this I was planning on doing some mass exports with a doomscript but I fo
Most of these will be just random things I'm reading, I think. I still need to figure out a good way to do a slip-box. I have a org server extension I can send links to but I forget to do it. Same with pocket (non-open source reasons aside, the emacs package works well)
- [Daily Notes](/daily/)
+- [Main](/main/)
+- [References](/references/)
diff --git a/content/references/hongAbstractionofThoughtMakesLanguage2024.md b/content/references/hongAbstractionofThoughtMakesLanguage2024.md
new file mode 100644
index 000000000..d27ca694b
--- /dev/null
+++ b/content/references/hongAbstractionofThoughtMakesLanguage2024.md
@@ -0,0 +1,146 @@
+---
+title: "Hong, Ruixin and Zhang, Hongming and Pan, Xiaoman and Yu, Dong and Zhang, Changshui :: Abstraction-of-Thought Makes Language Models Better Reasoners"
+author: ["Justin"]
+date: 2024-07-08T09:29:00-04:00
+lastmod: 2024-07-08T16:15:51-04:00
+tags: ["machine-learning", "prompting"]
+draft: false
+---
+
+
+
+## Paper {#paper}
+
+Abstraction-of-Thought (AoT) is a novel structured reasoning format designed to
+enhance language models' abstract reasoning capabilities. Unlike the
+step-by-step Chain-of-Thought (CoT) method, AoT requires models to consider
+problems at varying levels of abstraction before delving into concrete details.
+
+
+
+
+
+## Implementation {#implementation}
+
+These are various implementations I've created or wandered into.
+
+
+Python
+
+
+The python one I created myself, was pondering using it for some of my projects.
+
+```python
+
+import openai
+
+client = openai.OpenAI()
+
+def abstraction_of_thought(problem):
+ # Step 1: High-level planning
+ high_level_prompt = f"""Problem: {problem}
+
+ Let's think logically and provide an abstract higher-order plan on how to
+ solve this kind of problem. Don't dive into small details, only provide
+ a high-level plan."""
+
+ high_level_response = client.chat.completions.create(
+ model="gpt-3.5-turbo",
+ messages=[{"role": "user", "content": high_level_prompt}]
+ )
+ high_level_plan = high_level_response.choices[0].message.content
+
+ # Step 2: Detailed planning
+ detailed_prompt = f"""High-level plan: {high_level_plan}
+
+ Provide a more detailed plan. What specific steps should we take? On
+ what details should we pay attention?"""
+
+ detailed_response = client.chat.completions.create(
+ model="gpt-3.5-turbo",
+ messages=[{"role": "user", "content": detailed_prompt}]
+ )
+ detailed_plan = detailed_response.choices[0].message.content
+
+ # Step 3: Problem-solving
+ solve_prompt = f"""Problem: {problem}
+ High-level plan: {high_level_plan}
+ Detailed plan: {detailed_plan}
+
+ Now, apply this plan to solve the problem and provide the final solution."""
+
+ solve_response = client.chat.completions.create(
+ model="gpt-3.5-turbo",
+ messages=[{"role": "user", "content": solve_prompt}]
+ )
+ solution = solve_response.choices[0].message.content
+
+ # Step 4: Summarizing
+ summary_prompt = f"""Solution: {solution}
+
+ Provide a short, concise final answer based on this solution."""
+
+ summary_response = client.chat.completions.create(
+ model="gpt-3.5-turbo",
+ messages=[{"role": "user", "content": summary_prompt}]
+ )
+ final_answer = summary_response.choices[0].message.content
+
+ return {
+ "high_level_plan": high_level_plan,
+ "detailed_plan": detailed_plan,
+ "solution": solution,
+ "final_answer": final_answer
+ }
+
+# Example usage
+problem = """I have an orange, five raspberries, two books,
+ three plums, a pencil, and a grape. How many fruits do I have?"""
+result = abstraction_of_thought(problem)
+
+print("High-level plan:", result["high_level_plan"])
+print("\nDetailed plan:", result["detailed_plan"])
+print("\nSolution:", result["solution"])
+print("\nFinal answer:", result["final_answer"])
+```
+
+
+
+
+Elisp
+
+
+This elisp implementation is in the
+[GitHub - s-kostyaev/ellama](https://github.com/s-kostyaev/ellama) package.
+
+```elisp
+This is an elisp implementation of abstraction of thought
+
+(defun ellama-solve-reasoning-problem (problem)
+ "Solve reasoning PROBLEM with absctraction of thought.
+Problem will be solved with the chain of questions to LLM."
+ (interactive "sProblem: ")
+ (ellama-chain
+ problem
+ '((:chat t
+ :transform (lambda (problem _)
+ (format "Problem:
+%s
+
+Let's think logically and provide abstract higher order plan how to solve this
+kind of problems. Don't dive into small details only provide high-level plan."
+ problem)))
+ (:chat t
+ :transform (lambda ( )
+ "Provide more detailed plan. On what details should we pay attention?"))
+ (:chat t
+ :transform (lambda ( )
+ "Now revise the plan and provide the final solution."))
+ (:chat t
+ :transform (lambda ( )
+ "Provide short final answer based on final solution.")))))
+```
+
+
+
+
diff --git a/functions.ts b/functions.ts
index 9a0d3f707..9ed1dc86d 100644
--- a/functions.ts
+++ b/functions.ts
@@ -1,8 +1,32 @@
import { Options } from "./quartz/components/ExplorerNode"
const toTitleCase = (str: string): string => {
- return str.replace(/\w\S*/g, (txt: string): string => {
- return txt.charAt(0).toUpperCase() + txt.slice(1).toLowerCase()
+ const exceptions = [
+ "of",
+ "and",
+ "in",
+ "the",
+ "with",
+ "on",
+ "at",
+ "by",
+ "from",
+ "to",
+ "a",
+ "an",
+ "for",
+ ]
+
+ return str.replace(/\b\w+(-\w+)*\b/g, (txt: string): string => {
+ return txt
+ .split("-")
+ .map((word, index) => {
+ if (exceptions.includes(word.toLowerCase()) && index !== 0) {
+ return word.toLowerCase()
+ }
+ return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()
+ })
+ .join("-")
})
}
@@ -13,10 +37,14 @@ export const mapFn: Options["mapFn"] = (node) => {
if (node.file) {
if (node.file.relativePath?.includes("daily/")) {
node.displayName = "🗓️ " + node.displayName
+ }
+ if (node.file.relativePath?.includes("references/")) {
+ const parts = node.file.frontmatter?.title?.split("::") ?? []
+ node.displayName = "📚 " + (parts.length > 1 ? parts[1].trim() : parts[0]?.trim() || "")
} else if (node.name == "movies") {
- node.displayName = "🎬 " + node.displayName
+ node.displayName = "🎬 " + node.file.frontmatter?.title
} else {
- node.displayName = "📄 " + node.displayName
+ node.displayName = "📄 " + node.file.frontmatter?.title
}
} else {
node.displayName = "📁 " + toTitleCase(node.displayName)
diff --git a/quartz.config.ts b/quartz.config.ts
index 5871f303e..ef05b07e4 100644
--- a/quartz.config.ts
+++ b/quartz.config.ts
@@ -25,7 +25,7 @@ const config: QuartzConfig = {
typography: {
header: "Open Sans",
body: "Open Sans",
- code: "Space Mono",
+ code: "Roboto Mono",
},
colors: {
lightMode: {
@@ -70,10 +70,10 @@ const config: QuartzConfig = {
}),
Plugin.SyntaxHighlighting({
theme: {
- light: "github-light",
- dark: "dracula",
+ light: "catppuccin-latte",
+ dark: "tokyo-night",
},
- keepBackground: false,
+ keepBackground: true,
}),
Plugin.TableOfContents({
showByDefault: true,
diff --git a/quartz.layout.ts b/quartz.layout.ts
index 2066b7b04..26e2c24ae 100644
--- a/quartz.layout.ts
+++ b/quartz.layout.ts
@@ -19,12 +19,18 @@ export const sharedPageComponents: SharedLayout = {
// components for pages that display a single page (e.g. a single note)
export const defaultContentPageLayout: PageLayout = {
beforeBody: [
- Component.Breadcrumbs({ rootName: "Index" }),
+ Component.CollapsibleHeaders(),
+ Component.Breadcrumbs({
+ rootName: "Index",
+ showCurrentPage: false,
+ }),
Component.ArticleTitle(),
+ Component.TagList(),
Component.ContentMeta({
showReadingTime: false,
+ showFootnoteLink: true,
+ showComma: true,
}),
- Component.TagList(),
],
left: [
Component.PageTitle(),
@@ -33,6 +39,7 @@ export const defaultContentPageLayout: PageLayout = {
Component.Darkmode(),
Component.DesktopOnly(
Component.Explorer({
+ title: "Notes",
mapFn: mapFn,
sortFn: sortFn,
}),
diff --git a/quartz/components/Backlinks.tsx b/quartz/components/Backlinks.tsx
index aa412a2e0..0de2f117b 100644
--- a/quartz/components/Backlinks.tsx
+++ b/quartz/components/Backlinks.tsx
@@ -13,7 +13,7 @@ const Backlinks: QuartzComponent = ({
const slug = simplifySlug(fileData.slug!)
const backlinkFiles = allFiles.filter((file) => file.links?.includes(slug))
return (
-
+
{i18n(cfg.locale).components.backlinks.title}
{backlinkFiles.length > 0 ? (
diff --git a/quartz/components/CollapsibleHeaders.tsx b/quartz/components/CollapsibleHeaders.tsx
new file mode 100644
index 000000000..66daa8797
--- /dev/null
+++ b/quartz/components/CollapsibleHeaders.tsx
@@ -0,0 +1,47 @@
+import { QuartzComponentConstructor, QuartzComponentProps } from "./types"
+
+export default (() => {
+ function CollapsibleHeaders({ displayClass }: QuartzComponentProps) {
+ return
+ }
+
+ CollapsibleHeaders.afterDOMLoaded = `
+ document.addEventListener('DOMContentLoaded', function() {
+ const headers = document.querySelectorAll('h2, h3, h4, h5, h6');
+
+ headers.forEach(header => {
+ // Add click event listener to each header
+ header.addEventListener('click', function() {
+ this.classList.toggle('collapsed');
+ let currentElement = this.nextElementSibling;
+
+ while (currentElement && !['H2', 'H3', 'H4', 'H5', 'H6'].includes(currentElement.tagName)) {
+ if (currentElement.style.display === 'none') {
+ currentElement.style.display = '';
+ } else {
+ currentElement.style.display = 'none';
+ }
+ currentElement = currentElement.nextElementSibling;
+ }
+ });
+
+ // Add visual cue that header is clickable
+ header.style.cursor = 'pointer';
+ });
+ });
+ `
+
+ CollapsibleHeaders.css = `
+ h2, h3, h4, h5, h6 {
+ transition: opacity 0.3s;
+ }
+ .collapsed + * {
+ display: none;
+ }
+ .collapsed {
+ opacity: 0.6;
+ }
+ `
+
+ return CollapsibleHeaders
+}) satisfies QuartzComponentConstructor
diff --git a/quartz/components/ContentMeta.tsx b/quartz/components/ContentMeta.tsx
index 24ff6324f..c5f77038b 100644
--- a/quartz/components/ContentMeta.tsx
+++ b/quartz/components/ContentMeta.tsx
@@ -8,11 +8,15 @@ import style from "./styles/contentMeta.scss"
interface ContentMetaOptions {
showReadingTime: boolean
+ showBacklinkLink: boolean
+ showFootnoteLink: boolean
showComma: boolean
}
const defaultOptions: ContentMetaOptions = {
showReadingTime: true,
+ showBacklinkLink: true,
+ showFootnoteLink: true,
showComma: true,
}
@@ -81,6 +85,26 @@ export default ((opts?: Partial) => {
segments.push(displayedTime)
}
+ // Display link to footnotes if enabled
+ if (options.showFootnoteLink) {
+ const footnoteLinkSegment = (
+
+ footnotes
+
+ )
+ segments.push(footnoteLinkSegment)
+ }
+
+ // Display link to backlinks if enabled
+ if (options.showBacklinkLink) {
+ const backlinkSegment = (
+
+ backlinks
+
+ )
+ segments.push(backlinkSegment)
+ }
+
const segmentsElements = segments.map((segment) => {segment})
return (
diff --git a/quartz/components/index.ts b/quartz/components/index.ts
index b3db76bed..9ea8290ad 100644
--- a/quartz/components/index.ts
+++ b/quartz/components/index.ts
@@ -19,6 +19,7 @@ import DesktopOnly from "./DesktopOnly"
import MobileOnly from "./MobileOnly"
import RecentNotes from "./RecentNotes"
import Breadcrumbs from "./Breadcrumbs"
+import CollapsibleHeaders from "./CollapsibleHeaders"
export {
ArticleTitle,
@@ -42,4 +43,5 @@ export {
RecentNotes,
NotFound,
Breadcrumbs,
+ CollapsibleHeaders,
}
diff --git a/quartz/components/styles/contentMeta.scss b/quartz/components/styles/contentMeta.scss
index 4d89f65d5..6eb310362 100644
--- a/quartz/components/styles/contentMeta.scss
+++ b/quartz/components/styles/contentMeta.scss
@@ -1,13 +1,15 @@
.content-meta {
- margin-top: 0;
+ font-weight: bold;
+ margin-top: 0.25em;
color: var(--gray);
&[show-comma="true"] {
> span:not(:last-child) {
- margin-right: 8px;
+ margin-right: 0.75em;
&::after {
- content: ",";
+ content: "·";
+ margin-left: 0.75em;
}
}
}
diff --git a/quartz/styles/base.scss b/quartz/styles/base.scss
index 5649f4b27..381703ed3 100644
--- a/quartz/styles/base.scss
+++ b/quartz/styles/base.scss
@@ -131,7 +131,7 @@ a {
& article {
& > h1 {
- font-size: 1.75rem;
+ font-size: 1.65rem;
}
& li:has(> input[type="checkbox"]) {
@@ -413,7 +413,7 @@ pre {
}
code {
- font-size: 0.9em;
+ font-size: 1.0em;
color: var(--dark);
font-family: var(--codeFont);
border-radius: 5px;
diff --git a/quartz/styles/custom.scss b/quartz/styles/custom.scss
index cea3aed1f..56c22e50b 100644
--- a/quartz/styles/custom.scss
+++ b/quartz/styles/custom.scss
@@ -47,7 +47,7 @@
.tag {
float: right;
- font-size: 12px;
+ font-size: 0.75rem;
color: var(--theme);
}
@@ -103,6 +103,7 @@ p.timestamp-wrapper {
}
/* Base styles */
+
.jvc {
margin-left: var(--base-indent);
}
@@ -277,10 +278,72 @@ article.popover-hint::after {
padding-bottom: 1em;
}
-/* Metadata */
+/* Metadata + Title */
+
+.article-title {
+ font-size: 1.15em;
+ margin-top: 0.5rem;
+ margin-bottom: 0.5rem;
+ }
p.content-meta a {
- /* your styles here */
- color: var(--gray); /* example: change link color */
- text-decoration: underline; /* example: underline on hover */
+ color: var(--gray);
+ text-decoration: underline;
}
+
+/* Explorer */
+
+#explorer-content {
+ font-size: 0.9em;
+}
+
+/* Details */
+
+details {
+ border: 1px solid var(--lightgray);
+ border-radius: 4px;
+ padding: 10px;
+ margin: 10px 0;
+ background-color: var(--light);
+ transition: all 0.3s ease-in-out;
+}
+
+/* style the summary element */
+summary {
+ font-weight: bold;
+ cursor: pointer;
+ padding: 5px 0;
+ color: var(--darkgray);
+ outline: none;
+}
+
+/* add a transition effect for the summary element when focused */
+summary:focus {
+ color: var(--secondary);
+ outline: none;
+}
+
+/* add a hover effect for the summary element */
+summary:hover {
+ color: var(--secondary);
+}
+
+/* additional style for the details content */
+details[open] {
+ border-color: var(--secondary);
+ background-color: var(--highlight);
+}
+
+/* optional: add an icon before the summary text */
+summary::before {
+ content: "➕ ";
+ font-size: 0.8em;
+ margin-right: 5px;
+ transition: transform 0.3s ease-in-out;
+}
+
+/* rotate the icon when the details element is open */
+details[open] summary::before {
+ transform: rotate(45deg);
+ content: "➖ ";
+}
\ No newline at end of file