Algorithmic Vision | Learning | Coding

从语义表示到RAG: Embedding的前世今生

前言 当今如火如荼的大语言模型应用领域,向量数据库的使用几乎无处不在。文本类向量数据库中的每一条向量,是由一段文本经某种算法映射后所表示而成的。那么,文本是如何被表示成向量的呢?我们该如何训练一个能够实现 “文本 —> 向量” 这一功能的神经网络模型呢?这篇文章将为你进行逐一解答。 词嵌入(Word Embedding)简介 单词的数字表示 在处理自然语言类型的机器学习任务时,首先需要思考的问题就是:如何将字符串文本表示为数字? One-Hot Encoding 最初,单词被表示为它在一个词典中的索引(index)。比如一个语料库中一共有1000个单词,”language”这个单词在词典中排第200个,那么它可以被表示为一个独热向量(one-hot vector),即... Read more

LangChain Agent: Tutorial And Idea Behinds It

LangChain Agent简介 Agent的核心理念:“use a language model to choose a sequence of actions to take”。在Chain类的概念中,一系列的action是提前预设好且按照固定顺序执行的,而对于agent来讲,它的后端有一个LLM来根据用户的输入做推理,因此会“选择”action进行执行,并且自行决定执行的顺序。 Agent流程 Chain流程 Agent必要的组件 Prompt LLM Tool Parser 当前LangChain文档中主流的Agent的构建逻辑基本遵循着以下的流程 初始化prompt, llm, tools, parser 将tools b... Read more

iOS Development 05: Generic

Don’t Care Type 泛型代码让你能根据自定义的需求,编写出适用于任意类型的、灵活可复用的函数及类型。 Basic Grammar Generic Function The generic version of the function uses a placeholder type name (called T, in this case) instead of an actual type name (such as Int, String, or Double). T can be any name. The actual type to use in place of T is determined at each time the generic func... Read more

iOS Development 04: MVVM Design Pattern

MVVM设计模式 Model-View-ViewModel is a design paradigm. It must be adhered to for SwiftUI to work. Model UI Independent Data + Logic View The reflection of the Model Stateless Declared(只有“var body”决定了view是如何绘制的) Reactive (Always reacting efficiently to the change on the model) Automatically observes publications from ViewMod... Read more

iOS Development 03: Protocol

协议[Protocols] 总结来看,协议为Swift提供了一种方便,灵活的对类型进行抽象描述的方式。 A protocol defines a blueprint of methods, properties, and other requirements that suit a particular task or piece of functionality. The protocol can then be adopted by a class, structure, or enumeration to provide an actual implementation of those requirements. Any type that satisfies the re... Read more