【问题标题】:What is suffix and prefix prompt in openai Codex?openai Codex 中的后缀和前缀提示是什么?
【发布时间】:2022-08-10 06:41:06
【问题描述】:

除了 Codex 中的前缀提示之外,我一直在尝试了解后缀提示是什么。

他们提供了example

def get_largest_prime_factor(n):
    if n < 2:
        return False
    def is_prime(n): >  for i in range(2, n): >  if n % i == 0: >  return False >  return True >     largest = 1
    for j in range(2, n + 1):
        if n % j == 0 and is_prime(j):
    return largest

从这个例子中我不清楚如何创建后缀提示?

我理解的是后缀提示是代码插入模型。我的用例也是insert 模式,即代码需要在代码 sn-p 中间更新。

谁能提供一个 sn-p 显示我如何使用后缀提示以便 Codex 在插入模式下工作?

    标签: deep-learning openai gpt-2 codex gpt-3


    【解决方案1】:

    这个 python 示例对我有用。

    import os
    import openai
    
    openai.api_key = os.getenv("OPENAI_API_KEY")
    
    # Example per https://beta.openai.com/docs/guides/completion/inserting-text
    prompt="I went to college at Boston University. After getting my degree, I decided to make a change. A big change!"
    suffix="Now, I can’t get enough of the Pacific Ocean!"
    
    # Use "suffix" parameter documented in
    # https://beta.openai.com/docs/api-reference/completions/create#completions/create-suffix
    response = openai.Completion.create(
                model="text-davinci-002",
                prompt=prompt,
                suffix=suffix,
                temperature=0.6
            )
    
    # Print completion
    print( response["choices"][0]["text"] )
    
    # Typical output
    # "I moved to California! I love the weather and all the new adventures it brings"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-29
      • 1970-01-01
      • 2015-01-26
      相关资源
      最近更新 更多