今天是2024年9月18日,星期三,北京,天气晴。
假期结束,我们继续来跟进相关技术。
我们昨天的文章回顾了,RAG地几个经典概念,《有趣的RAG变体们-从RAG、ROG、RCG到RIG:概念辨析及RIG实现思路》https://mp.weixin.qq.com/s/oy_vXweIBUY7OTKmX-_KHQ,其中提到的几个概念可以看看。
我们今天来看2个事儿,一个是关于OpenAI o1相关技术的一些整理,另一个是可自定义向量维度的向量工具WordLlama。
供大家一起参考并思考。
持续前进,保持自律,踏实成长。
关于OpenAI o1相关技术资源(论文和博客等)收集的项目,可以看看:https://platform.openai.com/docs/guides/reasoning
地址:https://github.com/hijkzzz/Awesome-LLM-Strawberry
里面提到了一些外界的解读,可以做补充看看:
1、博客blog
1)OpenAI《Learning to Reason with LLMs》
地址:https//openai.com/index/learning-to-reason-with-llms/
2)OpenAI《OpenAI o1-mini Advancing cost-efficient reasoning
地址:https://openai.com/index/openai-o1-mini-advancing-cost-efficient-reasoning
3)OpenAI《Finding GPT-4’s mistakes with GPT-4》
这个文章有点意思,提到一个CriticGPT,也是用RLHF(基于人类反馈的强化学习)训练的,与ChatGPT类似。
但与ChatGPT不同的是,它看到大量包含错误的输入,然后必须对这些错误进行批评,要求AI训练师在ChatGPT生成的代码中手动插入这些错误,然后撰写示例反馈,就好像他们发现了他们刚刚插入的错误一样。
然后,同一个人比较了修改后的代码的多个批评,这样他们就可以很容易地判断批评是否抓住了他们插入的错误。
地址:https://openai.com/index/finding-gpt4s-mistakes-with-gpt-4/
4)Tibor Blaho《Summary of what we have learned during AMA hour with the OpenAI o1 tea》
地址:https://twitter-thread.com/t/1834686946846597281
5)Nathan Lambert《OpenAI’s Strawberry, LM self-talk, inference scaling laws, and spending more on inference》
地址:https://www.interconnects.ai/p/openai-strawberry-and-inference-scaling-laws
6)Nathan Lambert《Reverse engineering OpenAI’s o1》
地址:https://www.interconnects.ai/p/reverse-engineering-openai-o1
2、相关的论文:Relevant Paper from OpenAI o1
1、《Training Verifiers to Solve Math Word Problems》
这个工作介绍了一个新的数据集GSM8K,包含8.5K个高质量的、语言多样的小学数学文字题。提出了训练验证器来判断模型完成结果的正确性
。在测试时,模型会生成多个候选解,并选择验证器排名最高的解。
地址:https://arxiv.org/abs/2110.14168
2、《Generative Language Modeling for Automated Theorem Proving》
这个工作提出了一个名为GPT-f的自动定理证明器和证明助手,专门针对 Metamath 形式化语言。
地址:https://arxiv.org/abs/2009.03393
3、《Chain-of-Thought Prompting Elicits Reasoning in Large Language Models》
这个工作探讨了如何通过生成一系列中间推理步骤(即“思维链”)来显著提高大型语言模型执行复杂推理任务的能力。
这种方法被称为“思维链提示”(chain-of-thought prompting),通过在提示中提供一些思维链示例来自然地激发大型语言模型的推理能力,也就是现在大家必提的经典概念。
地址:https://arxiv.org/abs/2201.11903
4、《Let's Verify Step by Step》
这个工作探讨了如何通过过程监督(process supervision)来训练更可靠的大型语言模型,以执行复杂的多步推理任务。
与结果监督(outcome supervision)相比,过程监督为每个中间推理步骤提供反馈,而不是仅对最终结果提供反馈。
地址:https://arxiv.org/abs/2305.20050
5、《LLM Critics Help Catch LLM Bugs》
这个工作探讨了如何通过训练“批评者”模型来帮助人类更准确地评估由大模型(LLM)编写的代码。
这些批评者模型本身是使用强化学习从人类反馈(RLHF)训练出来的,用于生成突出代码中问题的自然语言反馈。
地址:https://arxiv.org/abs/2407.00215
6、《Self-critiquing models for assisting human evaluators》
这个工作探讨了如何通过行为克隆(behavioral cloning)微调大模型来撰写自然语言批判(即自然语言批评性评论),以帮助人类评估者发现可能错过的摘要中的缺陷。
地址:https://arxiv.org/pdf/2206.05802
这个有趣的工具,WordLlama:快速、轻量级的NLP工具包,用于模糊去重、相似度和排序任务
WordLlama是一个用于自然语言处理(NLP)和词嵌入模型的工具,基于大模型生成词表示(例如GloVe、Word2Vec或FastText)。为了灵活性,WordLlama采用了套娃表示学习训练技术。最大的模型(1024维)可以截断到64、128、256或512。
对于密集嵌入,256维足以捕捉大部分性能,而对于二进制嵌入,验证精度在512维(打包后64字节)时接近饱和。
根据该项目的结论,WordLlama在MTEB基准测试中的表现优于GloVe 300d等词模型,同时在大小上显著更小(默认模型16MB,256维,相比之下GloVe等模型通常超过2GB)。
地址:https://github.com/dleemiller/WordLlama
我们可以重点看看以下几点:
1、加载方式及一些功能
1)加载模型-Load the default WordLlama model
from wordllama import WordLlama
wl = WordLlama.load()
2)计算相似度-Calculate similarity between two sentences
similarity_score = wl.similarity("i went to the car", "i went to the pawn shop")
print(similarity_score) # Output: 0.06641249096796882
3)文档排序-Rank documents based on their similarity to a query
query = "i went to the car"
candidates = ["i went to the park", "i went to the shop", "i went to the truck", "i went to the vehicle"]
ranked_docs = wl.rank(query, candidates)
print(ranked_docs)
# Output:
# [
# ('i went to the vehicle', 0.7441646856486314),
# ('i went to the truck', 0.2832691551894259),
# ('i went to the shop', 0.19732814982305436),
# ('i went to the park', 0.15101404519322253)
# ]
4)去重、聚类、过滤
wl.deduplicate(candidates, threshold=0.8) # fuzzy deduplication
wl.cluster(docs, k=5, max_iterations=100, tolerance=1e-4) # labels using kmeans/kmeans++ init
wl.filter(query, candidates, threshold=0.3) # filter candidates based on query
wl.topk(query, candidates, k=3) # return topk strings based on query
2、指定向量维度向量化文本Embed Text
from wordllama import WordLlama
# Load pre-trained embeddings
# truncate dimension to 64
wl = WordLlama.load(trunc_dim=64)
# Embed text
embeddings = wl.embed(["the quick brown fox jumps over the lazy dog", "and all that jazz"])
print(embeddings.shape) # (2, 64)
也可以转为二进制的嵌入表示Binary embedding
# Binary embeddings are packed into uint64
# 64-dims => array of 1x uint64
wl = WordLlama.load(trunc_dim=64, binary=True) # this will download the binary model from huggingface
wl.embed("I went to the car") # Output: array([[3029168427562626]], dtype=uint64)
# load binary trained model trained with straight through estimator
wl = WordLlama.load(dim=1024, binary=True)
# Uses the hamming similarity to binarize
similarity_score = wl.similarity("i went to the car", "i went to the pawn shop")
print(similarity_score) # Output: 0.57421875
ranked_docs = wl.rank("i went to the car", ["van", "truck"])
wl.binary = False # turn off hamming and use cosine
# load a different model class
wl = WordLlama.load(config="l3_supercat", dim=1024) # downloads model from HF
1、https://github.com/dleemiller/WordLlama
2、https://github.com/hijkzzz/Awesome-LLM-Strawberry
老刘,NLP开源爱好者与践行者,主页:https://liuhuanyong.github.io。
对大模型&知识图谱&RAG&文档理解感兴趣,并对每日早报、老刘说NLP历史线上分享、心得交流等感兴趣的,欢迎加入社区,社区持续纳新。
加入会员方式:关注公众号,在后台菜单栏中点击会员社区->会员入群加入