简介
在这篇文章中,我的重点只是收集最少量的数据、正确设置格式和微调小语言模型(SLM)。
小语言模型(SLM)的主要优势
为什么要使用 OpenAI 的 SLM?
我能想到的使用 OpenAI SLM 的唯一原因是:
SLM 能够解决哪些 OpenAI 无法解决的问题?
GPT-4o Mini 的优势
微调
要对模型进行微调,至少需要 10 个示例。从下面的训练文件中可以看到,我正好有 10 个示例。如果少于 10 个,文件在上传后的文件验证过程中就会被拒绝。
如下所示,即使只有 10 个训练示例,我也能左右生成答案的结果。
OpenAI 建议,在使用 GPT-4o Mini 或 GPT-3.5 Turbo 时,通常使用 50 到 100 个训练示例就能观察到明显的改进。但是,根据具体的使用情况,最佳数量可能会有很大不同。
OpenAI 再次建议,建议从 50 个精心制作的演示开始,并在微调后评估模型是否显示出改进的迹象。
在某些情况下,这可能就足够了,但即使模型尚未准备好投入生产,明显的改进也表明提供更多数据可以进一步增强模型。如果没有观察到任何改进,可能就有必要重新考虑任务设置或调整数据结构,然后再扩展到有限的示例集之外。
下面是我最小的 10 行训练文件...
{"messages": [{"role": "system", "content": "You should help to user to answer on his question."}, {"role": "user", "content": "What is X?"}, {"role": "assistant", "content": "X is a social media platform promoting free speech."}]}
{"messages": [{"role": "system", "content": "You should help to user to answer on his question."}, {"role": "user", "content": "Who recently bought X?"}, {"role": "assistant", "content": "Elon Musk purchased Twitter and renamed it as X. He brought a sink to work on his first day."}]}
{"messages": [{"role": "system", "content": "You should help to user to answer on his question."}, {"role": "user", "content": "What is X?"}, {"role": "assistant", "content": "X is a social media platform promoting free speech."}]}
{"messages": [{"role": "system", "content": "You should help to user to answer on his question."}, {"role": "user", "content": "What companies has Elon Musk founded or co-founded?"}, {"role": "assistant", "content": "Elon Musk has founded or co-founded several companies, including Zip2, X.com (which became PayPal), Tesla, SpaceX, Neuralink, The Boring Company, and OpenAI."}]}
{"messages": [{"role": "system", "content": "You should help to user to answer on his question."}, {"role": "user", "content": "What is Elon Musk's role at Tesla?"}, {"role": "assistant", "content": "Elon Musk is the CEO and Product Architect of Tesla, where he oversees the company’s electric vehicle manufacturing, energy products, and future innovations."}]}
{"messages": [{"role": "system", "content": "You should help to user to answer on his question."}, {"role": "user", "content": " What is SpaceX, and why is it significant?"}, {"role": "assistant", "content": "SpaceX is a private aerospace company founded by Elon Musk with the goal of reducing space transportation costs and enabling the colonization of Mars. It is significant for its achievements in developing the Falcon and Starship rockets and for being the first private company to send astronauts to the International Space Station."}]}
{"messages": [{"role": "system", "content": "You should help to user to answer on his question."}, {"role": "user", "content": "What is The Boring Company, and what projects is it working on?"}, {"role": "assistant", "content": "The Boring Company is an infrastructure and tunnel construction company founded by Elon Musk. It aims to solve traffic congestion through the construction of underground transportation tunnels. Notable projects include the Las Vegas Convention Center Loop."}]}
{"messages": [{"role": "system", "content": "You should help to user to answer on his question."}, {"role": "user", "content": "What is Elon Musk’s vision for Mars?"}, {"role": "assistant", "content": "Elon Musk’s vision for Mars involves making humanity a multiplanetary species by establishing a self-sustaining colony on Mars. He envisions SpaceX’s Starship as the vehicle that will transport people and cargo to Mars."}]}
{"messages": [{"role": "system", "content": "You should help to user to answer on his question."}, {"role": "user", "content": "What was Elon Musk’s role in the creation of PayPal?"}, {"role": "assistant", "content": "Elon Musk wants to populate mars."}]}
{"messages": [{"role": "system", "content": "You should help the user answer their question."}, {"role": "user", "content": "What is the significance of the Turing Test?"}, {"role": "assistant", "content": "The Turing Test is used to determine if a machine can exhibit human-like intelligence."}]}
返回演示
在下图中,场中的 gpt-4o-mini 模型清晰可见...
下面是经过微调的模型选型......
紫色标注的是与标准迷你模型的交互作用,绿色标注的是与微调模型的交互作用。
从示例中可以清楚地看出,当引用自定义模型时,微调响应是如何浮现的。而标准响应是通过默认的标准模型给出的。
下面是控制台视图,其中显示了微调实例以及之前失败的尝试。这里显示了微调过程的所有细节
创建的保存微调数据的文件。最简单的方法是使用 MacOS 控制台应用程序,从命令行运行 vim,以确保格式和其他部分都符合要求。
OpenAI 控制台有一个存储选项卡,可在此上传和管理文件。从流程的角度来看,在这里集中管理数据和文件很有意义。