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 ( -
+