Skip to content

Commit 4e145c3

Browse files
committed
update tags
1 parent 62d9d14 commit 4e145c3

39 files changed

+458
-97
lines changed

content/posts/2025-08-19_redis-learn-01.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
date = '2025-08-19T8:00:00+08:00'
33
draft = false
44
title = 'Redis String'
5-
tags = ['Redis', 'Database']
5+
tags = ['Redis', 'NoSQL']
66
+++
77
介绍Redis中的字符串键
88

content/posts/2025-08-21_redis-learn-02.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
date = '2025-08-21T8:00:00+08:00'
33
draft = false
44
title = 'Redis Hash'
5-
tags = ['Redis', 'Database']
5+
tags = ['Redis', 'NoSQL']
66
+++
77

88
## 散列

content/posts/2025-08-22_tokei-share.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
date = '2025-08-22T8:00:00+08:00'
33
draft = false
44
title = 'Tokei'
5-
tags = ['Tools']
5+
tags = ['Rust']
66
+++
77

88
### Tokei 介绍

content/posts/2025-08-23_rust-alternatives.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
date = '2025-08-23T8:00:00+08:00'
33
draft = false
44
title = 'Rust Alternaitve Tools'
5-
tags = ['Tools', 'Rust']
5+
tags = ['Rust']
66
+++
77

88
常用工具的 rust 替代品.

content/posts/2025-08-26_redis-learn-04.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
date = '2025-08-26T8:00:00+08:00'
33
draft = false
44
title = 'Redis Set'
5-
tags = ['Redis', 'Database']
5+
tags = ['Redis', 'NoSQL']
66
+++
77

88
Redis 的集和 set 键允许用户将任意多个不同的元素存储到集和中, 既可以是文本数据, 也可以是二进制数据. 其与列表有以下两个明显的区别:

content/posts/2025-08-28_context-enigneering.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
+++
22
date = '2025-08-28T8:00:00+08:00'
33
draft = false
4-
title = 'Prompt Origanization'
4+
title = 'Prompt Organization'
55
tags = ['Prompt', 'LLMs']
66
+++
77

@@ -52,8 +52,8 @@ def get_prompt(role: str, query: str) -> list[dict]:
5252
对比 f-string, 模板字符串更加灵活, 且可以只传入部分值
5353

5454

55-
### Jinja2
56-
Jinja2 是一个现代的设计者友好的, 仿照 Django 模板的 Python 模板语言. 它速度快, 被广泛使用, 并且提供了可选的沙箱模板执行环境保证安全:
55+
### Jinja
56+
Jinja 是一个现代的设计者友好的, 仿照 Django 模板的 Python 模板语言. 它速度快, 被广泛使用, 并且提供了可选的沙箱模板执行环境保证安全:
5757
例如下面这个 `.j2` 文件内容, 构造了一个用于少样本提示的模板
5858
```Jinja
5959
{% if examples %}
@@ -99,13 +99,13 @@ def get_prompt(user_input: str) -> list[dict]:
9999

100100
return messages
101101
```
102-
使用 Jinja2 模板文件的好处是:
102+
使用 Jinja 模板文件的好处是:
103103
1. 方便组织提示词文件, 例如这里是将提示词文件放在 `ProjectRoot/app/module/prompt` 里面, 模板文件放在 `prompt/template` 里面, 在提示词文件中导入模板文件十分方便, 文件组织清晰, 代码可读性高, 且方便扩展
104-
2. 提示词灵活性更好, 对比 string.Template, Jinja2 模板不仅可以填充变量, 还可以在模板中插入循环和条件判断等语法, 使得代码中只需提供一个字典格式的数据即可, 无需在代码里拼凑提示词, 也方便和 RAG 系统结合使用
104+
2. 提示词灵活性更好, 对比 string.Template, Jinja 模板不仅可以填充变量, 还可以在模板中插入循环和条件判断等语法, 使得代码中只需提供一个字典格式的数据即可, 无需在代码里拼凑提示词, 也方便和 RAG 系统结合使用
105105

106-
虽然 Jinja2 对比 string.Template 性能上要差一些, 但是 LLM 应用真正花时间的地方是模型的推理部分, 相比之下提示词渲染的时间几乎可以忽略不计. 如果提示词非常多, Jinja2 还提供了异步渲染功能, 可以结合异步框架进一步提升性能.
106+
虽然 Jinja 对比 string.Template 性能上要差一些, 但是 LLM 应用真正花时间的地方是模型的推理部分, 相比之下提示词渲染的时间几乎可以忽略不计. 如果提示词非常多, Jinja 还提供了异步渲染功能, 可以结合异步框架进一步提升性能.
107107

108108
### Wrapping Up
109-
上面就是近期使用的一些构造提示词的方法, 分别是 `f-string``string.Template``Jinja2`.
110-
当然也有像 `langchain_core.prompts.prompt.PromptTemplate` 这样专用框架提供的提示词模板功能, 但是为了支持 LangChain LCEL 语法等原因, 导致其类型设计十分抽象, 且 LangChain 对新模型和新功能的支持比较缓慢, 加上版本不稳定, 接口经常变动, 故没有考虑使用 LangChain 框架提供的功能.(实际上, langchain 也支持使用 Jinja2 模板)
109+
上面就是近期使用的一些构造提示词的方法, 分别是 `f-string``string.Template``Jinja`.
110+
当然也有像 `langchain_core.prompts.prompt.PromptTemplate` 这样专用框架提供的提示词模板功能, 但是为了支持 LangChain LCEL 语法等原因, 导致其类型设计十分抽象, 且 LangChain 对新模型和新功能的支持比较缓慢, 加上版本不稳定, 接口经常变动, 故没有考虑使用 LangChain 框架提供的功能.(实际上, langchain 也支持使用 Jinja 模板)
111111
总之, 上面介绍的提示词构造方法各有优劣, 应该根据你项目的复杂度, 自行选择合适的提示词构造方式.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
+++
2+
date = '2025-08-29T8:00:00+08:00'
3+
draft = true
4+
title = 'Redis Sorted Set'
5+
tags = ['Redis', 'NoSQL']
6+
+++
7+

public/archives/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
<span>30 posts total</span></div><div class="flex items-center gap-1"><svg class="h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5A2 2 0 003 7v12a2 2 0 002 2z"/></svg>
5555
<span>Timeline view</span></div></div></header><div class=relative><div class="bg-border absolute top-0 bottom-0 left-4 w-0.5"></div><div class=mb-12><div class="relative mb-8 flex items-center"><div class="bg-primary absolute left-0 z-10 flex h-8 w-8 items-center justify-center rounded-full"><svg class="h-4 w-4 text-primary-foreground" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5A2 2 0 003 7v12a2 2 0 002 2z"/></svg></div><div class=ml-12><h2 class="text-foreground text-2xl font-bold">2025</h2><p class="text-muted-foreground text-sm">28
5656
posts</p></div></div><div class="relative mb-8"><div class="relative mb-4 flex items-center"><div class="bg-accent border-background absolute left-2 z-10 h-4 w-4 rounded-full border-2"></div><div class=ml-12><h3 class="text-foreground text-lg font-semibold">August 2025</h3><p class="text-muted-foreground text-xs">28
57-
posts</p></div></div><div class="ml-12 space-y-3"><article class="group bg-card border-border hover:bg-accent/50 rounded-lg border p-4 transition-all duration-300"><div class="flex items-center justify-between gap-4"><div class="min-w-0 flex-1"><h4 class="text-foreground group-hover:text-primary mb-3 font-medium transition-colors duration-200"><a href=/posts/prompt-origanization/ class=block>Prompt Origanization</a></h4><div class="text-muted-foreground flex items-center gap-4 text-xs"><div class="flex items-center gap-1"><svg class="h-3 w-3" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5A2 2 0 003 7v12a2 2 0 002 2z"/></svg>
57+
posts</p></div></div><div class="ml-12 space-y-3"><article class="group bg-card border-border hover:bg-accent/50 rounded-lg border p-4 transition-all duration-300"><div class="flex items-center justify-between gap-4"><div class="min-w-0 flex-1"><h4 class="text-foreground group-hover:text-primary mb-3 font-medium transition-colors duration-200"><a href=/posts/prompt-organization/ class=block>Prompt Organization</a></h4><div class="text-muted-foreground flex items-center gap-4 text-xs"><div class="flex items-center gap-1"><svg class="h-3 w-3" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5A2 2 0 003 7v12a2 2 0 002 2z"/></svg>
5858
<time datetime=2025-08-28>08-28</time></div><div class="flex items-center gap-1"><svg class="h-3 w-3" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3A9 9 0 113 12a9 9 0 0118 0z"/></svg>
5959
<span>3
6060
min</span></div></div></div></div></article><article class="group bg-card border-border hover:bg-accent/50 rounded-lg border p-4 transition-all duration-300"><div class="flex items-center justify-between gap-4"><div class="min-w-0 flex-1"><h4 class="text-foreground group-hover:text-primary mb-3 font-medium transition-colors duration-200"><a href=/posts/from-python-to-go/ class=block>From Python to Go</a></h4><div class="text-muted-foreground flex items-center gap-4 text-xs"><div class="flex items-center gap-1"><svg class="h-3 w-3" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5A2 2 0 003 7v12a2 2 0 002 2z"/></svg>

0 commit comments

Comments
 (0)