什么是ChatGPT?
1. 什么是ChatGPT?
ChatGPT是由OpenAI创建的大型语言模型。它采用Transformer架构和无监督预训练方法进行训练,并使用人类反馈强化学习 (RLHF) ,从而实现对自然语言的理解并生成类似于人类的响应。
ChatGPT基于GPT-3.5模型,参数数量达到了1750亿。使用了大量互联网上的文本数据集进行训练,包括书籍、文章和社交媒体帖子。这种广泛的训练使得ChatGPT能够提供智能和相关性强的响应,以回答各种提示和问题。
OpenAI官网: https://openai.com/
ChatGPT官网: https://chat.openai.com/
2. 如何使用ChatGPT?
首先要在ChatGPT官网上创建一个账号,注意需要使用国外手机号接收短信验证。
无法注册的话,也可以在ChatGPT镜像站点体验一下,注意不要输入敏感信息。
- 免费好用的ChatGPT镜像站点列表: https://github.com/xx025/carrot
注册成功后,可以直接访问 https://chat.openai.com/ 页面进行使用。
如果报 "Access denied You do not have access to chat.openai.com." 说明访问IP受限,只能更换IP或使用API方式。
使用API方式,首先要在 https://platform.openai.com/account/api-keys 创建API key,然后使用插件或客户端等方式使用,也可以自建服务。
- 使用开源项目搭建个人站点: https://github.com/Chanzhaoyu/chatgpt-web。
注意不要频繁更换IP或同一个key多个IP使用,这样可能会被封号。
3. 使用ChatGPT API
官方教程: https://platform.openai.com/docs/quickstart
使用Python简单调用ChatGPT API接口:
import openai
openai.api_key = "YOUR_API_KEY"
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello, can you introduce yourself?"}
]
)
print(response.get("choices")[0]["message"]["content"])
model="gpt-3.5-turbo" 指定调用的模型,ChatGPT使用的是"gpt-3.5-turbo"
{"role": "system", "content": "You are a helpful assistant."} 指定AI扮演的角色
{"role": "user", "content": "Hello, can you introduce yourself?"} 用户的提问
响应是JSON格式,可以通过 print(response.get("choices")[0]["message"]["content"])
获取
{
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "Certainly! My name is OpenAI Assistant and I am an AI language model designed by OpenAI to assist with a wide range of tasks and answer questions to the best of my ability. How can I assist you today?",
"role": "assistant"
}
}
],
"created": 1683288812,
"id": "chatcmpl-7CobUNdzZodUm6fSoO73uP47n8ONR",
"model": "gpt-3.5-turbo-0301",
"object": "chat.completion",
"usage": {
"completion_tokens": 44,
"prompt_tokens": 26,
"total_tokens": 70
}
}
4. 相关概念
tokens: 单词,单词块,单个字符。
OpenAI使用tokens来计费,普通的OpenAI账户当前有18美元的免费试用额度(有时间限制),如果使用gpt-3.5-turbo模型,则每1000个token耗费0.002美元,普通人是足够用了。
查看使用额度: https://platform.openai.com/account/usage
temperature: 温度 0-1 越高越具有创造性,越低越具有真实性。
不过还是需要注意,chatGPT会一本正经的胡说八道,需要检查回答的真实性。
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 没有源码,如何修改代码逻辑?
· DeepSeek R1 简明指南:架构、训练、本地部署及硬件要求
· NetPad:一个.NET开源、跨平台的C#编辑器
· PowerShell开发游戏 · 打蜜蜂