使用C语言中的“不透明”指针,可以隐藏很多不想公开的细节-腾讯云开发者社区-腾讯云
再解释一下c语言的指针问题
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h> // 添加用于跨平台指针格式化
struct wl_registry;
struct wl_proxy {
int scope;
int age;
};
int main(int argc, char **argv)
{
struct wl_proxy *wl_proxy = (struct wl_proxy *)malloc(sizeof(struct wl_proxy));
wl_proxy->age = 10;
wl_proxy->scope = 0;
struct wl_registry* test = (struct wl_registry *) wl_proxy;
// 统一字段宽度为15字符,左对齐
printf("%-15s = %-10d | %-15s = %-10d\n",
"test->age", ((struct wl_proxy*)test)->age,
"test->scope", ((struct wl_proxy*)test)->scope);
printf("%-15s = %-10d | %-15s = %-10d\n\n",
"wl_proxy->age", wl_proxy->age,
"wl_proxy->scope", wl_proxy->scope);
// 使用跨平台指针格式化,宽度固定为18字符(含0x前缀)
printf("%-16s = 0x%-14" PRIxPTR "\n",
"test address", (uintptr_t)test);
printf("%-16s = 0x%-14" PRIxPTR "\n",
"wl_proxy address", (uintptr_t)wl_proxy);
free(wl_proxy);
return 0;
}
内存对齐,现在一般是8字节内存对齐,所以低三位肯定是0,因为一般是8的整数倍!
每个地址对应一个字节,比如int就占用4个字节,占用4个地址。32位是2^32=4GB内存。这样才能理解为什么wayland中要搞指针标志位。
4.30
一个简单的RAG参考项目,只有简单的检索,没有重排,但是有完整的调用链路,支持api或gradio前端,前者相当于是提供一个封装了的post请求接口,后者相当于是提供一个简单的web交互界面,两者其实都是发送请求到模型提供商。代码1k多行,值得一看,需要解决环境问题。
【DataWhale动手学大模型应用开发】动手学大模型应用开发第六课《LLM精选案例》学习笔记 - 知乎
GitHub - logan-zou/Chat_with_Datawhale_langchain
一些blog
《asyncio 系列》12. 详解 asyncio 支持的多种队列 - 古明地盆 - 博客园
-
仿函数(是一个含有operator()成员函数的对象)
-
bind
我们使用 auto fr 保存 std::bind 的返回结果,是因为我们并不关心 std::bind 真正的返回类型(实际上 std::bind 的返回类型是一个 stl 内部定义的仿函数类型),只需要知道它是一个仿函数,可以直接赋值给一个 std::function。当然,这里直接使用 std::function 类型来保存std::bind 的返回值也是可以的。
还有一点是std::thread和std::bind传递参数的时候,默认是值传递,引用传递必须使用std::ref。至于为什么?底层暂不深究。记住这一点就行。
DPO 是如何简化 RLHF 的 - 知乎
(4 条消息) dpo 的局限性 - 知乎
[Reinforcement Learning] Policy Gradient Methods - Poll的笔记 - 博客园
关于LLM训练损失的初始值和下界
大模型sft为什么第二个epoch的时候loss会突然下降? - 知乎