首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在GPT-3上保存预培训的API?

如何在GPT-3上保存预培训的API?
EN

Stack Overflow用户
提问于 2021-04-29 22:07:10
回答 1查看 193关注 0票数 2

我有个关于GPT-3的问题。如我们所知,我们可以给网络提供一些例子,并“调整”模型。

examples.

  • Reuse
  1. 向模型显示示例。
  2. 保存这些API。

代码语言:javascript
复制
import openai

class Example():
    """Stores an input, output pair and formats it to prime the model."""
def __init__(self, inp, out):
    self.input = inp
    self.output = out

def get_input(self):
    """Returns the input of the example."""
    return self.input

def get_output(self):
    """Returns the intended output of the example."""
    return self.output

def format(self):
    """Formats the input, output pair."""
    return f"input: {self.input}\noutput: {self.output}\n"


class GPT:
    """The main class for a user to interface with the OpenAI API.
    A user can add examples and set parameters of the API request."""
def __init__(self, engine='davinci',
             temperature=0.5,
             max_tokens=100):
    self.examples = []
    self.engine = engine
    self.temperature = temperature
    self.max_tokens = max_tokens

def add_example(self, ex):
    """Adds an example to the object. Example must be an instance
    of the Example class."""
    assert isinstance(ex, Example), "Please create an Example object."
    self.examples.append(ex.format())

现在,当我对模型使用“给予”示例时,我有以下代码:

代码语言:javascript
复制
gpt2 = GPT(engine="davinci", temperature=0.5, max_tokens=100)
gpt2.add_example(Example('Two plus two equals four', '2 + 2 = 4'))
gpt2.add_example(Example('The integral from zero to infinity', '\\int_0^{\\infty}'))

prompt1 = "x squared plus y squared plus equals z squared"
output1 = gpt2.submit_request(prompt1)

然而,我无法保存这个“预培训”API.每次我要重新训练它的时候-有什么方法可以重用它吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-05-22 20:19:07

每次我必须重新训练它的时候,

--有什么方法可以重用它吗?

不,没有任何方法可以重用它。你混淆了术语:你不需要训练GPT-3,你需要把例子传递给提示符。由于您没有任何类型的容器可以存储以前的结果(从而“培训”您的模型),所以每次都需要传递包含任务的示例。

完善工程过程(从而降低每项要求的成本)是一个困难的过程,将需要很长的时间来反复试验。

不过,让我们诚实地说:即使每次都通过这些例子,GPT-3仍然是极具成本效益的。根据您的具体情况,您(平均)只需要花费几百个令牌来完成与Davinci的复杂完成。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67325687

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档