ChatGPT API 学习笔记

ArtificialIntelligence AI

This article was last updated on <span id="expire-date"></span> days ago, the information described in the article may be outdated.

ChatGPT API 学习笔记

Reference

  1. Openai Offical Document

Concepts

GPT or ChatGPT

OpenAI’s text generation models (often referred to as generative pre-trained transformers or “GPT” models for short)

OpenAI 的文本生成模型(通常称为生成式预训练变化者 或简称”GPT”模型)

Prompt 提示词

Designing a prompt is essentially how you “program” a model like GPT-4, usually by providing instructions or some examples of how to successfully complete a task.

prompt 的设计本质上是如何”编程”一个像GPT-4这样的模型,通常是通过提供成功完成任务的说明或一些示例来完成的.

Embedings 嵌入模型

Embeddings are a numerical representation of text.

嵌入是文本的数字表示.

An embedding is a vector representation of a piece of data (e.g. some text)

嵌入是一段数据(例如某些文本)的矢量表示.

that is meant to preserve aspects of its content and/or its meaning.

它被用于保留其内容和/或含义的方面.

text embedding models that take as input a text string and produce as output an embedding vector.

文本嵌入模型将文本字符串作为输入, 并将嵌入向量作为输出.

Embeddings are useful for search, clustering, recommendations, anomaly detection, classification, and more.

嵌入对于搜索、聚类、推荐、异常检测、分类等非常有用.

can be used to measure the relatedness between two pieces of text

可用于衡量两段文本之间的相关性

Token 词元/代币

Text generation and embeddings models process text in chunks called tokens. A token is a single unit of text, such as a word or a subword. (as English words)

Token 是文本生成和嵌入模型处理文本的块,称为词元. 词元是文本的单个单位,例如单词或子词. (如英语单词), 可以理解成, 在 LLM(Large Language Model) 中, Token 是最小的文本单位, 他维护着一个词表, 词表中的每个词都有一个对应的 Token.

tokenization = token + ization

As a rough rule of thumb, 1 token is approximately 4 characters or 0.75 words for English text.

根据粗略的经验,1 个标记大约相当于 4 个字符或 0.75 个英文单词. 可以使用英语做 prompt , 并要求用中文输出, 来节省 token.

The limit is that for a text generation model the prompt and the generated output must be no more than the model’s maximum context limit.

对于文本生成模型, 提示和生成的输出的总和不得超过模型的最大上下文长度.

For embeddings models (which do not output tokens), the input must be shorter than the model’s maximum context length.

对于嵌入模型(不输出标记), 输入必须比模型的最大上下文长度短.

Both input and output tokens count towards the context limit.

输入和输出标记都计入上下文限制.

Counting tokens for chat API calls.(use Python function)

Large Multimodal Model 大型多模态模型

GPT-4 is a large multimodal model (accepting text or image inputs and outputting text)

GPT-4 是一个大型多模态模型(接受文本或图像输入并输出文本)

Multilingual(Multiple Language) capabilities 多语言能力

DALL-E

DALL·E is a AI system that can create realistic images and art from a description in natural language.

DALL·E 是一个人工智能系统, 可以根据自然语言的描述创建逼真的图像和艺术.

Text To Speech (TTS) 文本转语音

TTS is an AI model that converts text to natural sounding spoken text.

TTS 是一种人工智能模型,可将文本转换为听起来自然的语音文本.

Whisper 耳语

Whisper is a general-purpose speech recognition model.

Whisper 是一种 通用目的 的语音识别模型.

Moderation 适度(审查模型) censorship model

The Moderation models are designed to check whether content complies with OpenAI’s usage policies.

审核模型旨在检查内容是否符合 OpenAI 的使用政策.

The models provide classification capabilities(分类能力) that look for content in the following categories: hate(仇恨), hate/threatening(仇恨/威胁), self-harm(自残), sexual(性), sexual/minors(性/未成年性), violence(暴力), and violence/graphic(暴力图像).

Frequency and presence penalties (penal adj.刑事的) (频率和存在惩罚)

can be used to reduce the possibility of sampling repetitive sequences of tokens.

可以用来减少采样重复标记序列的可能性.

如果目的只是稍微减少重复样本,那么惩罚系数的合理值约为 0.1 到 1.如果目标是强烈抑制重复,那么可以将系数增加到 2,但这会显着降低样本的质量.负值可用于增加重复的可能性.

Prompt Engineering 提示词工程

Prompt engineering can be used to improve model inference and reduce the likelihood of the model hallucinating.

提示词工程可用于改善模型推理, 减少模型产生幻觉的可能性.

Temperature Parameter 温度参数

Lower values for temperature result in more consistent outputs (e.g. 0.2)

较低的温度值会产生更一致的输出(例如 0.2)

higher values generate more diverse(difference) and creative results (e.g. 1.0).

较高的值会产生更多样化和创造性的结果(例如 1.0).

The temperature can range is from 0 to 2.

温度范围是从 0 到 2.

Function call 函数调用

connect LLM to external tools. (e.g. sending an email, making a reservation, or generating code)

将大型语言模型连接到外部工具

Fine-tuning (微调) (精细的调整)

Fine-tuning improves on few-shot learning by training on many more examples than can fit in the prompt.

微调通过训练比 prompt 中可以容纳的更多示例, 来改进少样本学习.

Once a model has been fine-tuned, you won’t need to provide as many examples in the prompt.

一旦模型被微调, 你就不需要在 prompt 中提供太多的示例.

Fine-tuning is a method for customizing a model to better fit(vt. 安装;使……适应;) specific task, such as role-playing.

微调是自定义个性化模型的一种方法, 通过微调, 可以让模型更好地适应特定的任务. 例如指定的角色扮演(role-playing).

Few-Shot Learning (少样本训练)

Few-shot learning is a method for training a model on a small number of examples.

少样本学习是一种在少量示例上训练模型的方法.

For example, u can input a few prompt to the model, and the model can generate the output based on the prompt.

例如, 您可以向模型输入几个提示, 模型可以根据提示生成输出.

AGI (Artificial General Intelligence) 人工通用智能

AGI is a hypothetical AI that can understand and learn any intellectual task that a human being can.

AGI 是一种假设的人工智能, 可以理解和学习人类可以理解和学习的任何智力任务.

DPO(Direct Perfer Optimal) 直接偏好优化

DPO 是一种稳定且高效的方法, 用于微调 (fine-tuning) LLMs, 以便生成符合用户偏好的输出.

能够在不依赖复杂的基于人类反馈的强化学习 (Reinforcement Learning based on Human Feedback) 的情况下, 实现精准控制.

NLP(Natural Language Processing) 自然语言处理

CV (Computer Vision) 计算机视觉

Author: WhaleFall

Permalink: https://www.whaleluo.top/artificialintelligence/chatgpt-api-study/

文章默认使用 CC BY-NC-SA 4.0 协议进行许可,使用时请注意遵守协议。

Comments