欢迎来到第二章,我们的大模型学习开始了新篇章,这一章还是比较基础的调用api,有些朋友建议直接搞构造大模型,很显然这是很不科学的,我们先从基础学习,大模型本来就是很晦涩难懂的东西,并且知识体系十分庞大,所以我们慢慢学习才是最重要的事情!
工程迭代
首先我们需要介绍这个名词,什么是工程迭代?我们需要理解,在此我们总结为以下几点:
在大模型(如GPT-3.5、GPT-4等)的开发和改进过程中,工程迭代是一个非常重要的环节。工程迭代指的是在模型开发、训练和部署过程中,不断进行改进、测试和优化的循环过程。以下是大模型工程迭代的一些关键方面:
1. 数据收集和预处理
- 数据收集:收集大规模、多样化的训练数据。数据的质量和多样性对模型的性能至关重要。
- 数据清洗和预处理:处理和清洗数据,以确保数据的准确性和一致性。这包括去除噪声数据、处理缺失值、标准化等。
2. 模型训练
- 初始训练:使用收集的数据进行初始模型训练。这通常需要大量的计算资源和时间。
- 超参数调整:通过调整超参数(如学习率、批量大小等)来优化模型的性能。
- 分阶段训练:在某些情况下,可能需要分阶段训练模型,即先进行初步训练,再进行精细调优。
3. 模型评估和验证
- 性能评估:使用测试数据集评估模型的性能,包括准确性、召回率、F1分数等。
- 验证集:使用验证集来选择最优模型并避免过拟合。
- 错误分析:分析模型的错误输出,以找出模型的弱点和改进点。
4. 模型优化
- 模型压缩:为了在实际应用中提高效率,可能需要对模型进行压缩,如量化、剪枝等。
- 加速推理:使用优化算法和硬件加速(如GPU、TPU)来提高模型的推理速度。
- 内存管理:优化模型的内存使用,以便在资源有限的环境中运行。
5. 部署和监控
- 模型部署:将训练好的模型部署到生产环境中,这可能涉及到服务器配置、API开发等。
- 实时监控:监控模型在实际应用中的性能,收集用户反馈和使用数据,以便进行进一步优化。
- 持续集成和部署:通过自动化工具实现模型的持续集成和部署,确保快速迭代和更新。
6. 用户反馈和改进
- 用户反馈:收集用户的反馈意见,了解模型在实际应用中的表现和问题。
- 迭代改进:根据用户反馈和新数据进行模型的持续改进和重新训练。
7. 安全和伦理考虑
- 偏见和公平性:确保模型在不同群体中的公平性,减少偏见。
- 隐私保护:确保训练数据和模型的使用符合隐私保护法规和伦理标准。
8. 研究和创新
- 新技术探索:不断探索新的技术和方法,以提高模型的性能和能力。
- 学术合作:与学术界合作,共同研究和攻关技术难题。 通过以上这些迭代步骤,大模型可以不断改进和优化,以满足更高的应用需求和用户期望。
最基础的例子
当然我们现在水平是不足以做到这么多的,我们这篇文章会以一个小白的视角(我的视角)去看最基础的工程迭代
首先我们现在假设是有一个公司,我们主打的就是宣传我们的家具–凳子,但是我们不想写啊,我就交给了大模型处理,所以现在我们把对应的信息喂给模型进行处理,以下是对应代码:
传统的输出样式
fact_sheet_chair = """
OVERVIEW
- Part of a beautiful family of mid-century inspired office furniture,
including filing cabinets, desks, bookcases, meeting tables, and more.
- Several options of shell color and base finishes.
- Available with plastic back and front upholstery (SWC-100)
or full upholstery (SWC-110) in 10 fabric and 6 leather options.
- Base finish options are: stainless steel, matte black,
gloss white, or chrome.
- Chair is available with or without armrests.
- Suitable for home or business settings.
- Qualified for contract use.
CONSTRUCTION
- 5-wheel plastic coated aluminum base.
- Pneumatic chair adjust for easy raise/lower action.
DIMENSIONS
- WIDTH 53 CM | 20.87”
- DEPTH 51 CM | 20.08”
- HEIGHT 80 CM | 31.50”
- SEAT HEIGHT 44 CM | 17.32”
- SEAT DEPTH 41 CM | 16.14”
OPTIONS
- Soft or hard-floor caster options.
- Two choices of seat foam densities:
medium (1.8 lb/ft3) or high (2.8 lb/ft3)
- Armless or 8 position PU armrests
MATERIALS
SHELL BASE GLIDER
- Cast Aluminum with modified nylon PA6/PA66 coating.
- Shell thickness: 10 mm.
SEAT
- HD36 foam
COUNTRY OF ORIGIN
- Italy
"""
这个是对应语料对应翻译的话可以使用deepl或者其他翻译手段看看,简单来说就是些我们这个凳子的商品信息
然后我们就要开始给模型投入相应的信息或者说是要求
prompt = f"""
Your task is to help a marketing team create a
description for a retail website of a product based
on a technical fact sheet.
Write a product description based on the information
provided in the technical specifications delimited by
triple backticks.
Technical specifications: ```{fact_sheet_chair}```
"""
response = get_completion(prompt)
print(response)
这段代码的目的是使用OpenAI的语言模型帮助营销团队根据产品的技术规格撰写产品描述。具体来说,这段代码会根据提供的技术规格信息生成一个适合零售网站的产品描述。
构建提示字符串
prompt = f"""
Your task is to help a marketing team create a
description for a retail website of a product based
on a technical fact sheet.
Write a product description based on the information
provided in the technical specifications delimited by
triple backticks.
Technical specifications: ```{fact_sheet_chair}```
"""
这段代码构建了一个提示字符串prompt
,其内容如下:
Your task is to help a marketing team create a description for a retail website of a product based on a technical fact sheet.
Write a product description based on the information provided in the technical specifications delimited by triple backticks.
Technical specifications: ```{fact_sheet_chair}```
这个提示请求模型帮助营销团队创建一个产品描述。它要求模型基于技术规格表中的信息撰写一个适合零售网站使用的产品描述。
调用函数生成响应
response = get_completion(prompt)
这行代码调用了前面定义的get_completion
函数,传入构建的prompt
作为参数。该函数使用OpenAI的API生成对提示的响应。
打印结果
print(response)
这行代码打印出模型生成的响应。具体来说,将显示模型根据技术规格表撰写的产品描述。
总结
这段代码的作用是:
- 构建一个详细的提示,要求模型根据技术规格表创建一个产品描述。
- 使用OpenAI的模型生成响应并打印输出。
- 通过打印输出,展示模型撰写的产品描述,这对于营销团队在零售网站上展示产品信息非常有帮助。
通过运行代码我们可以看到结果是:
我们现在就有个问题,生成的内容太多了,有一说一本人在买东西的时候看到字多的我都不愿意看,所以我们可以简单些,所以我们就继续让模型给我们生成信息,我们继续给模型提要求,实现一个迭代过程
prompt = f"""
Your task is to help a marketing team create a
description for a retail website of a product based
on a technical fact sheet.
Write a product description based on the information
provided in the technical specifications delimited by
triple backticks.
Use at most 50 words.
Technical specifications: ```{fact_sheet_chair}```
"""
response = get_completion(prompt)
print(response)
这段代码和上述代码其实并没有太多的区别,主要的区别还是在于要求Use at most 50 words.
在这里插句话:在现在模型当中这种具体多少词数的要求其实处理能力是很有限的,就这么说吧,我相信有些人肯定会用chatgpt写作业,不少于多少多少字,但很显然有时候大模型是不能正确处理这些信息的
所以我们在这里其实不需要太过于准确
然后各位可以看这个运行结果我们可以看到,简洁了许多,我们再来看看具体输出的词数
WoW,还不错,这个模型还挺给我面子,哈哈哈哈哈哈
然后就是第二点,我们如果发现这个有一些错误的信息我们可以继续提示,或者说,我想要模型重点提及某些信息同样是可以写的
prompt = f"""
Your task is to help a marketing team create a
description for a retail website of a product based
on a technical fact sheet.
Write a product description based on the information
provided in the technical specifications delimited by
triple backticks.
The description is intended for furniture retailers,
so should be technical in nature and focus on the
materials the product is constructed from.
Use at most 50 words.
Technical specifications: ```{fact_sheet_chair}```
"""
response = get_completion(prompt)
print(response)
这段代码的目的是帮助营销团队根据产品的技术规格撰写一个简洁且技术性的产品描述,特别关注产品的材料,并将字数限制在最多50个单词以内
构建提示字符串
prompt = f"""
Your task is to help a marketing team create a
description for a retail website of a product based
on a technical fact sheet.
Write a product description based on the information
provided in the technical specifications delimited by
triple backticks.
The description is intended for furniture retailers,
so should be technical in nature and focus on the
materials the product is constructed from.
Use at most 50 words.
Technical specifications: ```{fact_sheet_chair}```
"""
这段代码构建了一个提示字符串prompt
,其内容如下:
Your task is to help a marketing team create a description for a retail website of a product based on a technical fact sheet.
Write a product description based on the information provided in the technical specifications delimited by triple backticks.
The description is intended for furniture retailers, so should be technical in nature and focus on the materials the product is constructed from.
Use at most 50 words.
Technical specifications: ```{fact_sheet_chair}```
这个提示请求模型帮助营销团队创建一个技术性产品描述,要求基于技术规格表中的信息撰写一个适合家具零售商使用的、最多50个单词的产品描述,特别关注产品的材料。
调用函数生成响应
response = get_completion(prompt)
这行代码调用了前面定义的get_completion
函数,传入构建的prompt
作为参数。该函数使用OpenAI的API生成对提示的响应。
打印结果
print(response)
这行代码打印出模型生成的响应。具体来说,将显示模型根据技术规格表撰写的技术性且简洁的产品描述。
总结
这段代码的作用是:
- 构建一个详细的提示,要求模型根据技术规格表创建一个技术性且简洁的、最多50个单词的产品描述,特别关注材料信息。
- 使用OpenAI的模型生成响应并打印输出。
- 通过打印输出,展示模型撰写的技术性产品描述,这对于营销团队在零售网站上展示产品信息非常有帮助,能够快速传达产品的技术特点和材料信息。
很显然这个就是个训练模型的过程
然后还有比如我要让你举例
prompt = f"""
Your task is to help a marketing team create a
description for a retail website of a product based
on a technical fact sheet.
Write a product description based on the information
provided in the technical specifications delimited by
triple backticks.
The description is intended for furniture retailers,
so should be technical in nature and focus on the
materials the product is constructed from.
At the end of the description, include every 7-character
Product ID in the technical specification.
Use at most 50 words.
Technical specifications: ```{fact_sheet_chair}```
"""
response = get_completion(prompt)
print(response)
这段代码的目的是帮助营销团队根据产品的技术规格撰写一个简洁且技术性的产品描述,特别关注产品的材料,并将字数限制在最多50个单词以内。此外,要求在描述的末尾包含每个7个字符的产品ID。
构建提示字符串
prompt = f"""
Your task is to help a marketing team create a
description for a retail website of a product based
on a technical fact sheet.
Write a product description based on the information
provided in the technical specifications delimited by
triple backticks.
The description is intended for furniture retailers,
so should be technical in nature and focus on the
materials the product is constructed from.
At the end of the description, include every 7-character
Product ID in the technical specification.
Use at most 50 words.
Technical specifications: ```{fact_sheet_chair}```
"""
这个提示请求模型帮助营销团队创建一个技术性产品描述,要求基于技术规格表中的信息撰写一个适合家具零售商使用的、最多50个单词的产品描述,特别关注产品的材料,并在描述末尾包含所有7个字符的产品ID。
调用函数生成响应
response = get_completion(prompt)
这行代码调用了前面定义的get_completion
函数,传入构建的prompt
作为参数。该函数使用OpenAI的API生成对提示的响应。
打印结果
print(response)
这行代码打印出模型生成的响应。具体来说,将显示模型根据技术规格表撰写的技术性且简洁的产品描述,并在描述末尾包含产品ID。
总结
这段代码的作用是:
- 构建一个详细的提示,要求模型根据技术规格表创建一个技术性且简洁的、最多50个单词的产品描述,特别关注材料信息,并在描述末尾包含所有7个字符的产品ID。
- 使用OpenAI的模型生成响应并打印输出。
- 通过打印输出,展示模型撰写的技术性产品描述,这对于营销团队在零售网站上展示产品信息非常有帮助,能够快速传达产品的技术特点和材料信息,同时确保包含产品ID以便识别。
很显然模型做的非常好
表格形式
在这里如果我们需要用到表格该怎么办呢,我们的用户喜欢看表格更加直观好看,怎么办???
在这里我们可以运用HTML知识
prompt = f"""
Your task is to help a marketing team create a
description for a retail website of a product based
on a technical fact sheet.
Write a product description based on the information
provided in the technical specifications delimited by
triple backticks.
The description is intended for furniture retailers,
so should be technical in nature and focus on the
materials the product is constructed from.
At the end of the description, include every 7-character
Product ID in the technical specification.
After the description, include a table that gives the
product's dimensions. The table should have two columns.
In the first column include the name of the dimension.
In the second column include the measurements in inches only.
Give the table the title 'Product Dimensions'.
Format everything as HTML that can be used in a website.
Place the description in a <div> element.
Technical specifications: ```{fact_sheet_chair}```
"""
response = get_completion(prompt)
print(response)
这段代码的目的是帮助营销团队根据产品的技术规格撰写一个技术性且简洁的产品描述,并以HTML格式输出,适用于在网站上使用。描述中需要特别关注产品的材料,并包含产品ID和产品尺寸表 构建提示字符串
prompt = f"""
Your task is to help a marketing team create a
description for a retail website of a product based
on a technical fact sheet.
Write a product description based on the information
provided in the technical specifications delimited by
triple backticks.
The description is intended for furniture retailers,
so should be technical in nature and focus on the
materials the product is constructed from.
At the end of the description, include every 7-character
Product ID in the technical specification.
After the description, include a table that gives the
product's dimensions. The table should have two columns.
In the first column include the name of the dimension.
In the second column include the measurements in inches only.
Give the table the title 'Product Dimensions'.
Format everything as HTML that can be used in a website.
Place the description in a <div> element.
Technical specifications: ```{fact_sheet_chair}```
"""
这个提示请求模型帮助营销团队创建一个产品描述,要求基于技术规格表中的信息撰写一个适合家具零售商使用的产品描述,并在描述末尾包含所有7个字符的产品ID和产品尺寸表。要求使用HTML格式输出,描述部分放在<div>
元素中。
调用函数生成响应
response = get_completion(prompt)
这行代码调用了前面定义的get_completion
函数,传入构建的prompt
作为参数。该函数使用OpenAI的API生成对提示的响应。
打印结果
print(response)
这行代码打印出模型生成的响应。具体来说,将显示模型根据技术规格表撰写的技术性且简洁的产品描述,并在描述末尾包含产品ID和产品尺寸表,所有内容格式化为HTML。
总结
这段代码的作用是:
- 构建一个详细的提示,要求模型根据技术规格表创建一个技术性且简洁的、适合家具零售商使用的产品描述,特别关注材料信息,并在描述末尾包含所有7个字符的产品ID和产品尺寸表。
- 要求使用HTML格式输出,描述部分放在
<div>
元素中,尺寸表使用<table>
元素。 - 使用OpenAI的模型生成响应并打印输出。
- 通过打印输出,展示模型生成的HTML格式的产品描述和尺寸表,这对于营销团队在零售网站上展示产品信息非常有帮助。
然后因为输出内筒有点多我们就直接复制输出的信息
<div>
<p>This mid-century inspired office chair is a stylish and functional addition to any workspace. The chair is available in a variety of shell colors and base finishes to suit your aesthetic preferences. Choose between plastic back and front upholstery or full upholstery in a range of fabric and leather options. The chair features a 5-wheel plastic coated aluminum base for stability and mobility, along with a pneumatic adjustment for easy height customization. Whether for home or business use, this chair is designed to provide comfort and support. Made with high-quality materials, including cast aluminum with a modified nylon coating for the shell and HD36 foam for the seat, this chair is built to last. Enhance your office with this versatile and durable seating option.</p>
<p>Product IDs: SWC-100, SWC-110</p>
</div>
<table>
<caption>Product Dimensions</caption>
<tr>
<th>Dimension</th>
<th>Measurements (inches)</th>
</tr>
<tr>
<td>Width</td>
<td>20.87"</td>
</tr>
<tr>
<td>Depth</td>
<td>20.08"</td>
</tr>
<tr>
<td>Height</td>
<td>31.50"</td>
</tr>
<tr>
<td>Seat Height</td>
<td>17.32"</td>
</tr>
<tr>
<td>Seat Depth</td>
<td>16.14"</td>
</tr>
</table>
然后我们来看看这个对应的信息是什么样子
可以看到这个代码运行是这个样子的,是不是好看了一点点
总结
在这里,我们发现其实我们口中所说的工程迭代不过是一直给机器提供信息然后让机器进行学习,锻炼模型最后就可以拿到我们想要的结果啦!!!
本章节结束啦,如果文章对您有帮助,还望留下一个大大的赞,您的支持是我滴动力!!!
程序员为什么要学大模型?
大模型时代,火爆出圈的LLM大模型让程序员们开始重新评估自己的本领。 “AI会取代那些行业
?”“谁的饭碗又将不保了?
”等问题热议不断。
事实上,抢你饭碗的不是AI,而是会利用AI的人。
继科大讯飞、阿里、华为
等巨头公司发布AI产品后,很多中小企业也陆续进场!超高年薪,挖掘AI大模型人才! 如今大厂老板们,也更倾向于会AI的人,普通程序员,还有应对的机会吗?
与其焦虑……
不如成为「掌握AI工具的技术人
」,毕竟AI时代,谁先尝试,谁就能占得先机!
但是LLM相关的内容很多,现在网上的老课程老教材关于LLM又太少。所以现在小白入门就只能靠自学,学习成本和门槛很高。
针对所有自学遇到困难的同学们,我帮大家系统梳理大模型学习脉络,将这份 LLM大模型资料
分享出来:包括LLM大模型书籍、640套大模型行业报告、LLM大模型学习视频、LLM大模型学习路线、开源大模型学习教程
等, 😝有需要的小伙伴,可以 扫描下方二维码领取🆓↓↓↓
一、LLM大模型经典书籍
AI大模型已经成为了当今科技领域的一大热点,那以下这些大模型书籍就是非常不错的学习资源。
二、640套LLM大模型报告合集
这套包含640份报告的合集,涵盖了大模型的理论研究、技术实现、行业应用等多个方面。无论您是科研人员、工程师,还是对AI大模型感兴趣的爱好者,这套报告合集都将为您提供宝贵的信息和启示。(几乎涵盖所有行业)
三、LLM大模型系列视频教程
四、LLM大模型开源教程(LLaLA/Meta/chatglm/chatgpt)
LLM大模型学习路线 ↓
阶段1:AI大模型时代的基础理解
-
目标:了解AI大模型的基本概念、发展历程和核心原理。
-
内容:
- L1.1 人工智能简述与大模型起源
- L1.2 大模型与通用人工智能
- L1.3 GPT模型的发展历程
- L1.4 模型工程
- L1.4.1 知识大模型
- L1.4.2 生产大模型
- L1.4.3 模型工程方法论
- L1.4.4 模型工程实践
- L1.5 GPT应用案例
阶段2:AI大模型API应用开发工程
-
目标:掌握AI大模型API的使用和开发,以及相关的编程技能。
-
内容:
- L2.1 API接口
- L2.1.1 OpenAI API接口
- L2.1.2 Python接口接入
- L2.1.3 BOT工具类框架
- L2.1.4 代码示例
- L2.2 Prompt框架
- L2.3 流水线工程
- L2.4 总结与展望
阶段3:AI大模型应用架构实践
-
目标:深入理解AI大模型的应用架构,并能够进行私有化部署。
-
内容:
- L3.1 Agent模型框架
- L3.2 MetaGPT
- L3.3 ChatGLM
- L3.4 LLAMA
- L3.5 其他大模型介绍
阶段4:AI大模型私有化部署
-
目标:掌握多种AI大模型的私有化部署,包括多模态和特定领域模型。
-
内容:
- L4.1 模型私有化部署概述
- L4.2 模型私有化部署的关键技术
- L4.3 模型私有化部署的实施步骤
- L4.4 模型私有化部署的应用场景
这份 LLM大模型资料
包括LLM大模型书籍、640套大模型行业报告、LLM大模型学习视频、LLM大模型学习路线、开源大模型学习教程
等, 😝有需要的小伙伴,可以 扫描下方二维码领取🆓↓↓↓