반응형
블로그 이미지
개발자로서 현장에서 일하면서 새로 접하는 기술들이나 알게된 정보 등을 정리하기 위한 블로그입니다. 운 좋게 미국에서 큰 회사들의 프로젝트에서 컬설턴트로 일하고 있어서 새로운 기술들을 접할 기회가 많이 있습니다. 미국의 IT 프로젝트에서 사용되는 툴들에 대해 많은 분들과 정보를 공유하고 싶습니다.
솔웅

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

글 보관함

카테고리

Engines - openai.Engine.list(),

2023. 1. 17. 02:24 | Posted by 솔웅


반응형

https://beta.openai.com/docs/api-reference/engines

 

Engines

 
The Engines endpoints are deprecated.
 
엔진 엔드포인트는 더 이상 사용되지 않습니다.
 

Please use their replacement, Models, instead. Learn more.

대신 대체 모델을 사용하십시오. 더 알아보기.

 

These endpoints describe and provide access to the various engines available in the API.

이러한 endpoints 은 API에서 사용할 수 있는 다양한 엔진에 대한 액세스를 설명하고 제공합니다.

 

List engines

Deprecated

GET https://api.openai.com/v1/engines

Lists the currently available (non-finetuned) models, and provides basic information about each one such as the owner and availability.

현재 사용 가능한(미세 조정되지 않은) 모델을 나열하고 소유자 및 가용성과 같은 각 모델에 대한 기본 정보를 제공합니다.

 

 

Retrieve engine

Deprecated 사용되지 않음

GET https://api.openai.com/v1/engines/{engine_id}

Retrieves a model instance, providing basic information about it such as the owner and availability.

소유자 및 가용성과 같은 기본 정보를 제공하는 모델 인스턴스를 검색합니다.

 

Path parameters

engine_id
string
Required

The ID of the engine to use for this request

반응형

Moderations - openai.Moderation.create()

2023. 1. 17. 02:19 | Posted by 솔웅


반응형

https://beta.openai.com/docs/api-reference/moderations

 

Moderations (중재)

Given a input text, outputs if the model classifies it as violating OpenAI's content policy.

입력 텍스트가 주어지면 모델이 OpenAI의 콘텐츠 정책을 위반하는 것으로 분류하면 출력합니다.

 

Related guide: Moderations

 

 

Create moderation

POST https://api.openai.com/v1/moderations

Classifies if text violates OpenAI's Content Policy

텍스트가 OpenAI의 콘텐츠 정책을 위반하는지 분류합니다.

 

Request body

input
string or array
Required

The input text to classify

분류할 입력 텍스트

 

 

model
string
Optional
 
Defaults to text-moderation-latest
 
기본값은 text-moderation-latest입니다.

Two content moderations models are available: text-moderation-stable and text-moderation-latest.

두 가지 콘텐츠 조정 모델(text-moderation-stable 및 text-moderation-latest)을 사용할 수 있습니다.

 

The default is text-moderation-latest which will be automatically upgraded over time. This ensures you are always using our most accurate model. If you use text-moderation-stable, we will provide advanced notice before updating the model. Accuracy of text-moderation-stable may be slightly lower than for text-moderation-latest.

 

기본값은 시간이 지남에 따라 자동으로 업그레이드되는 text-moderation-latest입니다. 이렇게 하면 항상 가장 정확한 모델을 사용할 수 있습니다. text-moderation-stable을 사용할 경우 모델 업데이트 전 사전 공지를 드립니다. text-moderation-stable의 정확도는 text-moderation-latest보다 약간 낮을 수 있습니다.

 

반응형


반응형

https://beta.openai.com/docs/api-reference/fine-tunes

 

Fine-tunes

Manage fine-tuning jobs to tailor a model to your specific training data.

미세 조정 작업을 관리하여 특정 학습 데이터에 맞게 모델을 맞춤화합니다.

 

Related guide: Fine-tune models

 

 

Create fine-tune

Beta

POST https://api.openai.com/v1/fine-tunes

Creates a job that fine-tunes a specified model from a given dataset.

지정된 데이터 세트에서 지정된 모델을 미세 조정하는 작업을 만듭니다.

 

Response includes details of the enqueued job including job status and the name of the fine-tuned models once complete.

 

응답에는 완료되면 작업 상태 및 미세 조정된 모델의 이름을 포함하여 대기열에 추가된 작업의 세부 정보가 포함됩니다.

 

Learn more about Fine-tuning 

 

 

 

 

 

Request body

training_file
string
Required

The ID of an uploaded file that contains training data.

교육 데이터가 포함된 업로드된 파일의 ID입니다.

 

See upload file for how to upload a file.

파일 업로드 방법은 파일 업로드를 참조하세요.

 

Your dataset must be formatted as a JSONL file, where each training example is a JSON object with the keys "prompt" and "completion". Additionally, you must upload your file with the purpose fine-tune.

 

데이터 세트는 JSONL 파일로 형식화되어야 합니다. 여기서 각 교육 예제는 "prompt" 및 "completion" 키가 있는 JSON 개체입니다. 또한 미세 조정 목적으로 파일을 업로드해야 합니다.

 

See the fine-tuning guide for more details.

 

자세한 내용은 미세 조정 가이드를 참조하세요.

 

 

validation_file
string
Optional

The ID of an uploaded file that contains validation data.

유효성 검사 데이터가 포함된 업로드된 파일의 ID입니다.

 

If you provide this file, the data is used to generate validation metrics periodically during fine-tuning. These metrics can be viewed in the fine-tuning results file. Your train and validation data should be mutually exclusive.

 

이 파일을 제공하면 미세 조정 중에 정기적으로 유효성 검사 지표를 생성하는 데 데이터가 사용됩니다. 이러한 메트릭은 미세 조정 결과 파일에서 볼 수 있습니다. 학습 및 검증 데이터는 상호 배타적이어야 합니다.

 

Your dataset must be formatted as a JSONL file, where each validation example is a JSON object with the keys "prompt" and "completion". Additionally, you must upload your file with the purpose fine-tune.

 

데이터 세트는 JSONL 파일로 형식화되어야 합니다. 여기서 각 검증 예제는 "prompt" 및 "completion" 키가 있는 JSON 개체입니다. 또한 미세 조정 목적으로 파일을 업로드해야 합니다.

 

See the fine-tuning guide for more details.

 

자세한 내용은 미세 조정 가이드를 참조하세요.

 

model
string
Optional
Defaults to curie

The name of the base model to fine-tune. You can select one of "ada", "babbage", "curie", "davinci", or a fine-tuned model created after 2022-04-21. To learn more about these models, see the Models documentation.

 

미세 조정할 기본 모델의 이름입니다. "ada", "babbage", "curie", "davinci" 또는 2022-04-21 이후 생성된 미세 조정된 모델 중 하나를 선택할 수 있습니다. 이러한 모델에 대한 자세한 내용은 모델 설명서를 참조하십시오.

 

 

n_epochs
integer
Optional
Defaults to 4

The number of epochs to train the model for. An epoch refers to one full cycle through the training dataset.

모델을 훈련할 에포크 수입니다. 에포크는 교육 데이터 세트를 통한 하나의 전체 주기를 나타냅니다.

 

 

batch_size
integer
Optional
Defaults to null

The batch size to use for training. The batch size is the number of training examples used to train a single forward and backward pass.

교육에 사용할 배치 크기입니다. 배치 크기는 단일 정방향 및 역방향 패스를 훈련하는 데 사용되는 훈련 예제의 수입니다.

 

By default, the batch size will be dynamically configured to be ~0.2% of the number of examples in the training set, capped at 256 - in general, we've found that larger batch sizes tend to work better for larger datasets.

 

기본적으로 배치 크기는 훈련 세트에 있는 예제 수의 ~0.2%로 동적으로 구성되며 최대 256개로 제한됩니다. 일반적으로 배치 크기가 클수록 데이터 세트가 더 잘 작동하는 경향이 있습니다.

 

learning_rate_multiplier
number
Optional
Defaults to null

The learning rate multiplier to use for training. The fine-tuning learning rate is the original learning rate used for pretraining multiplied by this value.

훈련에 사용할 학습률 승수입니다. 미세 조정 학습률은 사전 훈련에 사용된 원래 학습률에 이 값을 곱한 것입니다.

 

By default, the learning rate multiplier is the 0.05, 0.1, or 0.2 depending on final batch_size (larger learning rates tend to perform better with larger batch sizes). We recommend experimenting with values in the range 0.02 to 0.2 to see what produces the best results.

 

기본적으로 학습률 승수는 최종 batch_size에 따라 0.05, 0.1 또는 0.2입니다(배치 크기가 클수록 학습률이 높을수록 더 잘 수행되는 경향이 있음). 0.02에서 0.2 범위의 값으로 실험하여 최상의 결과를 생성하는 것이 무엇인지 확인하는 것이 좋습니다.

 

 

prompt_loss_weight
number
Optional
Defaults to 0.01

The weight to use for loss on the prompt tokens. This controls how much the model tries to learn to generate the prompt (as compared to the completion which always has a weight of 1.0), and can add a stabilizing effect to training when completions are short.

프롬프트 토큰에서 손실에 사용할 가중치입니다. 이것은 모델이 프롬프트를 생성하기 위해 학습을 시도하는 정도를 제어하고(항상 가중치가 1.0인 완료와 비교하여) 완료가 짧을 때 훈련에 안정화 효과를 추가할 수 있습니다.

 

If prompts are extremely long (relative to completions), it may make sense to reduce this weight so as to avoid over-prioritizing learning the prompt.

 

프롬프트가 매우 긴 경우(완료에 비해) 프롬프트 학습에 과도한 우선순위를 두지 않도록 이 가중치를 줄이는 것이 좋습니다.

 

compute_classification_metrics
boolean
Optional
Defaults to false

If set, we calculate classification-specific metrics such as accuracy and F-1 score using the validation set at the end of every epoch. These metrics can be viewed in the results file.

 

설정된 경우 매 에포크가 끝날 때마다 검증 세트를 사용하여 정확도 및 F-1 점수와 같은 분류별 메트릭을 계산합니다. 이러한 메트릭은 결과 파일에서 볼 수 있습니다.

 

In order to compute classification metrics, you must provide a validation_file. Additionally, you must specify classification_n_classes for multiclass classification or classification_positive_class for binary classification.

 

분류 메트릭을 계산하려면 validation_file을 제공해야 합니다. 또한 다중 클래스 분류의 경우 classification_n_classes를 지정하고 이진 분류의 경우 classification_positive_class를 지정해야 합니다.

 

classification_n_classes
integer
Optional
Defaults to null

The number of classes in a classification task.

분류 작업의 클래스 수입니다.

 

This parameter is required for multiclass classification.

 

이 매개변수는 다중 클래스 분류에 필요합니다.

 

 

classification_positive_class
string
Optional
Defaults to null

The positive class in binary classification.

이진 분류의 포지티브 클래스입니다.

 

This parameter is needed to generate precision, recall, and F1 metrics when doing binary classification.

 

이 매개변수는 이진 분류를 수행할 때 정밀도, 재현율 및 F1 메트릭을 생성하는 데 필요합니다.

 

 

classification_betas
array
Optional
Defaults to null

If this is provided, we calculate F-beta scores at the specified beta values. The F-beta score is a generalization of F-1 score. This is only used for binary classification.

이것이 제공되면 지정된 베타 값에서 F-베타 점수를 계산합니다. F-베타 점수는 F-1 점수를 일반화한 것입니다. 이진 분류에만 사용됩니다.

 

With a beta of 1 (i.e. the F-1 score), precision and recall are given the same weight. A larger beta score puts more weight on recall and less on precision. A smaller beta score puts more weight on precision and less on recall.

 

베타 1(즉, F-1 점수)에서는 정밀도와 재현율에 동일한 가중치가 부여됩니다. 베타 점수가 클수록 재현율에 더 많은 가중치를 부여하고 정밀도에는 덜 적용합니다. 베타 점수가 작을수록 정밀도에 더 많은 가중치를 부여하고 재현율에 더 적은 가중치를 둡니다.

 

suffix
string
Optional
Defaults to null

A string of up to 40 characters that will be added to your fine-tuned model name.

미세 조정된 모델 이름에 추가될 최대 40자의 문자열입니다.

 

For example, a suffix of "custom-model-name" would produce a model name like ada:ft-your-org:custom-model-name-2022-02-15-04-21-04.

 

예를 들어 "custom-model-name" 접미사는 ada:ft-your-org:custom-model-name-2022-02-15-04-21-04와 같은 모델 이름을 생성합니다.

 

 

List fine-tunes

Beta

GET https://api.openai.com/v1/fine-tunes

List your organization's fine-tuning jobs

여러분 조직의 미세 조정 작업들의 리스트를 보여 줍니다.

 

 

 

Retrieve fine-tune

Beta

GET https://api.openai.com/v1/fine-tunes/{fine_tune_id}

Gets info about the fine-tune job.

미세 조정 작업에 대한 정보를 얻습니다.

 

Response

 

{
  "id": "ft-AF1WoRqd3aJAHsqc9NY7iL8F",
  "object": "fine-tune",
  "model": "curie",
  "created_at": 1614807352,
  "events": [
    {
      "object": "fine-tune-event",
      "created_at": 1614807352,
      "level": "info",
      "message": "Job enqueued. Waiting for jobs ahead to complete. Queue number: 0."
    },
    {
      "object": "fine-tune-event",
      "created_at": 1614807356,
      "level": "info",
      "message": "Job started."
    },
    {
      "object": "fine-tune-event",
      "created_at": 1614807861,
      "level": "info",
      "message": "Uploaded snapshot: curie:ft-acmeco-2021-03-03-21-44-20."
    },
    {
      "object": "fine-tune-event",
      "created_at": 1614807864,
      "level": "info",
      "message": "Uploaded result files: file-QQm6ZpqdNwAaVC3aSz5sWwLT."
    },
    {
      "object": "fine-tune-event",
      "created_at": 1614807864,
      "level": "info",
      "message": "Job succeeded."
    }
  ],
  "fine_tuned_model": "curie:ft-acmeco-2021-03-03-21-44-20",
  "hyperparams": {
    "batch_size": 4,
    "learning_rate_multiplier": 0.1,
    "n_epochs": 4,
    "prompt_loss_weight": 0.1,
  },
  "organization_id": "org-...",
  "result_files": [
    {
      "id": "file-QQm6ZpqdNwAaVC3aSz5sWwLT",
      "object": "file",
      "bytes": 81509,
      "created_at": 1614807863,
      "filename": "compiled_results.csv",
      "purpose": "fine-tune-results"
    }
  ],
  "status": "succeeded",
  "validation_files": [],
  "training_files": [
    {
      "id": "file-XGinujblHPwGLSztz8cPS8XY",
      "object": "file",
      "bytes": 1547276,
      "created_at": 1610062281,
      "filename": "my-data-train.jsonl",
      "purpose": "fine-tune-train"
    }
  ],
  "updated_at": 1614807865,
}

Learn more about Fine-tuning

Path parameters

fine_tune_id
string
Required

The ID of the fine-tune job

미세 조정 작업의 아이디 입니다.

 

 

Cancel fine-tune

Beta

POST https://api.openai.com/v1/fine-tunes/{fine_tune_id}/cancel

Immediately cancel a fine-tune job.

미세 조정 작업을 즉각적으로 취소합니다.

 

 

Path parameters

fine_tune_id
string
Required

The ID of the fine-tune job to cancel

취소하기 위한 미세조정 작업의 아이디 입니다.

 

 

List fine-tune events

Beta

GET https://api.openai.com/v1/fine-tunes/{fine_tune_id}/events

Get fine-grained status updates for a fine-tune job.

 

미세 조정 작업을 위해 세분화된 상태 업데이트를 받습니다.

 

Path parameters

fine_tune_id
string
Required

The ID of the fine-tune job to get events for.

이벤트를 가져올 미세 조정 작업의 ID입니다.

 

Query parameters

stream
boolean
Optional
Defaults to false

Whether to stream events for the fine-tune job. If set to true, events will be sent as data-only server-sent events as they become available. The stream will terminate with a data: [DONE] message when the job is finished (succeeded, cancelled, or failed).

 

미세 조정 작업에 대한 이벤트를 스트리밍할지 여부입니다. true로 설정하면 이벤트가 사용 가능해지면 데이터 전용 서버 전송 이벤트로 전송됩니다. 스트림은 작업이 완료되면(성공, 취소 또는 실패) data: [DONE] 메시지와 함께 종료됩니다.

 

If set to false, only events generated so far will be returned.

 

false로 설정하면 지금까지 생성된 이벤트만 반환됩니다.

 

Delete fine-tune model

Beta

DELETE https://api.openai.com/v1/models/{model}

Delete a fine-tuned model. You must have the Owner role in your organization.

미세 조정 모델을 삭제 합니다. 해당 조직의 Owner 롤을 가지고 있어야 합니다.

 

Path parameters

model
string
Required

The model to delete

삭제 될 모델

 

 

 

 

반응형


반응형

https://beta.openai.com/docs/api-reference/files

 

Files

Files are used to upload documents that can be used with features like Fine-tuning.

파일은 미세 조정과 같은 기능과 함께 사용할 수 있는 문서를 업로드하는 데 사용됩니다.

 

List files

GET https://api.openai.com/v1/files

Returns a list of files that belong to the user's organization.

사용자의 조직에 속한 파일 목록을 반환합니다.

 

 

https://beta.openai.com/docs/api-reference/files/upload 

 

Upload file

POST https://api.openai.com/v1/files

Upload a file that contains document(s) to be used across various endpoints/features. Currently, the size of all the files uploaded by one organization can be up to 1 GB. Please contact us if you need to increase the storage limit.

다양한 엔드포인트/기능(endpoints/features)에서 사용할 문서가 포함된 파일을 업로드합니다. 현재 한 조직에서 업로드하는 모든 파일의 크기는 최대 1GB입니다. 저장 한도를 늘려야 하는 경우 당사에 문의하십시오.

 

 

Request body

file
string
Required

Name of the JSON Lines file to be uploaded.

업로드할 JSON Lines 파일의 이름입니다.

 

If the purpose is set to "fine-tune", each line is a JSON record with "prompt" and "completion" fields representing your training examples.

 

목적이 "미세 조정"으로 설정된 경우 각 줄은 교육 예제를 나타내는 "프롬프트" 및 "완료" 필드가 있는 JSON 레코드입니다.

 

purpose
string
Required

The intended purpose of the uploaded documents.

Use "fine-tune" for Fine-tuning. This allows us to validate the format of the uploaded file.

 

미세 조정에는 " Fine-tuning"을 사용하십시오. 이렇게 하면 업로드된 파일의 형식을 확인할 수 있습니다.

 

https://beta.openai.com/docs/api-reference/files/delete

 

Delete file

DELETE https://api.openai.com/v1/files/{file_id}

Delete a file.

파일을 지웁니다.

 

Path parameters

file_id
string
Required

The ID of the file to use for this request.

이 요청에서 사용할 파일의 아이디 입니다.

 

https://beta.openai.com/docs/api-reference/files/retrieve

 

Retrieve file

GET https://api.openai.com/v1/files/{file_id}

Returns information about a specific file.

특정 파일에 대한 정보를 반환합니다.

 

Path parameters

file_id
string
Required

The ID of the file to use for this request

이 요청에서 사용할 파일의 아이디 입니다.

 

 

https://beta.openai.com/docs/api-reference/files/retrieve-content

 

Retrieve file content

GET https://api.openai.com/v1/files/{file_id}/content

Returns the contents of the specified file

특정 파일의 내용을 반환합니다.

 

import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
content = openai.File.download("file-XjGxS3KTG0uNmNOK362iJua3")

Path parameters

file_id
string
Required

The ID of the file to use for this request

이 요청에서 사용할 파일의 아이디 입니다.

반응형

Embeddings - openai.Embedding.create()

2023. 1. 17. 01:11 | Posted by 솔웅


반응형

https://beta.openai.com/docs/api-reference/embeddings

 

Embeddings

Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms.

기계 학습 모델 및 알고리즘에서 쉽게 사용할 수 있는 주어진 입력의 벡터 표현을 가져옵니다.

 

Related guide: Embeddings

 

 

Create embeddings

POST https://api.openai.com/v1/embeddings

Creates an embedding vector representing the input text.

입력 텍스트를 표현하는 embedding 벡터를 만듭니다.

 

 

Request body

model
string
Required

ID of the model to use. You can use the List models API to see all of your available models, or see our Model overview for descriptions of them.

사용할 모델의 ID입니다. 모델 목록 API를 사용하여 사용 가능한 모든 모델을 보거나 모델 개요에서 설명을 볼 수 있습니다.

 

 

input
string or array
Required

Input text to get embeddings for, encoded as a string or array of tokens. To get embeddings for multiple inputs in a single request, pass an array of strings or array of token arrays. Each input must not exceed 8192 tokens in length.

문자열 또는 토큰 배열로 인코딩된 임베딩을 가져올 입력 텍스트입니다. 단일 요청에서 여러 입력에 대한 임베딩을 가져오려면 문자열 배열 또는 토큰 배열 배열을 전달합니다. 각 입력은 길이가 8192 토큰을 초과할 수 없습니다.

 

user
string
Optional

A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. Learn more.

OpenAI가 남용을 모니터링하고 탐지하는 데 도움이 될 수 있는 최종 사용자를 나타내는 고유 식별자입니다. 더 알아보기.

 

반응형


반응형

https://beta.openai.com/docs/api-reference/images

 

Images

Given a prompt and/or an input image, the model will generate a new image.

프롬프트 and/or 입력 이미지가 주어지면 모델이 새 이미지를 생성합니다.

 

Related guide: Image generation

 

 

Create image

POST https://api.openai.com/v1/images/generations

Creates an image given a prompt.

프롬프트가 주어지면 이미지를 생성합니다.

 

Request body

prompt
string
Required

A text description of the desired image(s). The maximum length is 1000 characters.

원하는 이미지에 대한 텍스트 설명입니다. 최대 길이는 1000자입니다.

 

n
integer
Optional
Defaults to 1

The number of images to generate. Must be between 1 and 10.

생성할 이미지 수입니다. 1에서 10 사이여야 합니다.

 

size
string
Optional
Defaults to 1024x1024

The size of the generated images. Must be one of 256x256, 512x512, or 1024x1024.

생성된 이미지의 크기입니다. 256x256, 512x512 또는 1024x1024 중 하나여야 합니다.

 

response_format
string
Optional
Defaults to url

The format in which the generated images are returned. Must be one of url or b64_json.

생성된 이미지가 반환되는 형식입니다. url 또는 b64_json 중 하나여야 합니다.

 

user
string
Optional

A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. Learn more.

OpenAI가 남용을 모니터링하고 탐지하는 데 도움이 될 수 있는 최종 사용자를 나타내는 고유 식별자입니다. 더 알아보기.

 

 

https://beta.openai.com/docs/api-reference/images/create-edit

Create image edit

POST https://api.openai.com/v1/images/edits

Creates an edited or extended image given an original image and a prompt.

원본 이미지와 프롬프트가 주어지면 편집되거나 확장된 이미지를 생성합니다.

 

Request body

image
string
Required

The image to edit. Must be a valid PNG file, less than 4MB, and square. If mask is not provided, image must have transparency, which will be used as the mask.

편집할 이미지입니다. 유효한 PNG 파일이어야 하며 4MB 미만의 정사각형이어야 합니다. 마스크를 제공하지 않으면 이미지에 투명도가 있어야 마스크로 사용됩니다.

 

mask
string
Optional

An additional image whose fully transparent areas (e.g. where alpha is zero) indicate where image should be edited. Must be a valid PNG file, less than 4MB, and have the same dimensions as image.

완전히 투명한 영역(예: 알파가 0인 경우)이 있는 추가 이미지는 이미지를 편집해야 하는 위치를 나타냅니다. 4MB 미만의 유효한 PNG 파일이어야 하며 이미지와 크기가 같아야 합니다.

 

prompt
string
Required

A text description of the desired image(s). The maximum length is 1000 characters.

원하는 이미지에 대한 텍스트 설명입니다. 최대 길이는 1000자입니다.

 

n
integer
Optional
Defaults to 1

The number of images to generate. Must be between 1 and 10.

생성할 이미지 수입니다. 1에서 10 사이여야 합니다.

 

size
string
Optional
Defaults to 1024x1024

The size of the generated images. Must be one of 256x256, 512x512, or 1024x1024.

생성된 이미지의 크기입니다. 256x256, 512x512 또는 1024x1024 중 하나여야 합니다.

 

response_format
string
Optional
Defaults to url

The format in which the generated images are returned. Must be one of url or b64_json.

생성된 이미지가 반환되는 형식입니다. url 또는 b64_json 중 하나여야 합니다.

 

user
string
Optional

A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. Learn more.

OpenAI가 남용을 모니터링하고 탐지하는 데 도움이 될 수 있는 최종 사용자를 나타내는 고유 식별자입니다. 더 알아보기.

 

https://beta.openai.com/docs/api-reference/images/create-variation

 

Create image variation

POST https://api.openai.com/v1/images/variations

Creates a variation of a given image.

주어진 이미지의 변형을 만듭니다.

 

Request body

image
string
Required

The image to use as the basis for the variation(s). Must be a valid PNG file, less than 4MB, and square.

변형의 기초로 사용할 이미지입니다. 유효한 PNG 파일이어야 하며 4MB 미만의 정사각형이어야 합니다.

 

n
integer
Optional
Defaults to 1

The number of images to generate. Must be between 1 and 10.

생성할 이미지 수입니다. 1에서 10 사이여야 합니다.

 

size
string
Optional
Defaults to 1024x1024

The size of the generated images. Must be one of 256x256, 512x512, or 1024x1024.

생성된 이미지의 크기입니다. 256x256, 512x512 또는 1024x1024 중 하나여야 합니다.

 

response_format
string
Optional
Defaults to url

The format in which the generated images are returned. Must be one of url or b64_json.

생성된 이미지가 반환되는 형식입니다. url 또는 b64_json 중 하나여야 합니다.

 

user
string
Optional

A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. Learn more.

OpenAI가 남용을 모니터링하고 탐지하는 데 도움이 될 수 있는 최종 사용자를 나타내는 고유 식별자입니다. 더 알아보기.

 

반응형

Edits - openai.Edit.create()

2023. 1. 17. 00:58 | Posted by 솔웅


반응형

https://beta.openai.com/docs/api-reference/edits

 

Create edit

POST https://api.openai.com/v1/edits

Creates a new edit for the provided input, instruction, and parameters

제공된 입력, 지침 및 매개변수에 대한 새 편집을 생성합니다.

 

Request body

model
string
Required

ID of the model to use. You can use the List models API to see all of your available models, or see our Model overview for descriptions of them.

사용할 모델의 ID입니다. 모델 목록 API를 사용하여 사용 가능한 모든 모델을 보거나 모델 개요에서 설명을 볼 수 있습니다.

 

input
string
Optional
Defaults to ''

The input text to use as a starting point for the edit.

편집의 시작점으로 사용할 입력 텍스트입니다.

 

instruction
string
Required

The instruction that tells the model how to edit the prompt.

프롬프트를 편집하는 방법을 모델에 알려주는 명령입니다.

 

n
integer
Optional
Defaults to 1

How many edits to generate for the input and instruction.

입력 및 명령어에 대해 생성할 편집 횟수입니다.

 

temperature
number
Optional
Defaults to 1

What sampling temperature to use. Higher values means the model will take more risks. Try 0.9 for more creative applications, and 0 (argmax sampling) for ones with a well-defined answer.

사용할 샘플링 온도(temperature). 값이 높을수록 모델이 더 많은 위험을 감수하게 됩니다. 더 창의적인 응용 프로그램에는 0.9를, 잘 정의된 답이 있는 응용 프로그램에는 0(argmax 샘플링)을 사용해 보십시오.

 

We generally recommend altering this or top_p but not both.

 

일반적으로 temperature 또는 top_p를 변경하는 것이 좋지만 둘 다 변경하는 것은 권장하지 않습니다.

 

top_p
number
Optional
Defaults to 1

An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.

모델이 top_p 확률 질량으로 토큰의 결과를 고려하는 핵 샘플링이라고 하는 온도(temperature )를 사용한 샘플링의 대안입니다. 따라서 0.1은 상위 10% 확률 질량을 구성하는 토큰만 고려됨을 의미합니다.

 

We generally recommend altering this or temperature but not both.

 

일반적으로 top_p 또는 온도를 변경하는 것이 좋지만 둘 다 변경하는 것은 권장하지 않습니다.

 

 

반응형

Completions - openai.Completion.create()

2023. 1. 17. 00:43 | Posted by 솔웅


반응형

https://beta.openai.com/docs/api-reference/completions

 

Completions

Given a prompt, the model will return one or more predicted completions, and can also return the probabilities of alternative tokens at each position.

 

프롬프트가 주어지면 모델은 하나 이상의 예상 완료(Completion)를 반환하고 각 위치에서 대체 토큰의 확률을 반환할 수도 있습니다.

 

Create completion

POST https://api.openai.com/v1/completions

Creates a completion for the provided prompt and parameters

제공된 프롬프트 및 매개변수에 대한 완성(completion)을 생성합니다.

 

 

Request body

model
string
Required

ID of the model to use. You can use the List models API to see all of your available models, or see our Model overview for descriptions of them.

사용할 모델의 ID입니다. 모델 목록 API를 사용하여 사용 가능한 모든 모델을 보거나 모델 개요에서 설명을 볼 수 있습니다.

 

prompt
string or array
Optional
Defaults to <|endoftext|>

The prompt(s) to generate completions for, encoded as a string, array of strings, array of tokens, or array of token arrays.

문자열, 문자열 배열, 토큰 배열 또는 토큰 배열 배열로 인코딩된 완성(completions )을 생성하는 프롬프트입니다.

 

Note that <|endoftext|> is the document separator that the model sees during training, so if a prompt is not specified the model will generate as if from the beginning of a new document.

 

<|endoftext|>는 훈련 중에 모델이 보는 문서 구분 기호이므로 프롬프트가 지정되지 않으면 모델이 새 문서의 시작 부분에서 생성되는 것처럼 생성됩니다.

 

suffix
string
Optional
Defaults to null

The suffix that comes after a completion of inserted text.

삽입된 텍스트가 완료된 뒤에 오는 접미사.

 

max_tokens
integer
Optional
Defaults to 16

The maximum number of tokens to generate in the completion.

completion 에서 생성할 수 있는 최대 토큰 수입니다.

 

The token count of your prompt plus max_tokens cannot exceed the model's context length. Most models have a context length of 2048 tokens (except for the newest models, which support 4096).

 

프롬프트의 토큰 수에 max_tokens를 더한 값은 모델의 컨텍스트 길이를 초과할 수 없습니다. 대부분의 모델은 컨텍스트 길이가 2048 토큰입니다(4096을 지원하는 최신 모델 제외).

 

temperature
number
Optional
Defaults to 1

What sampling temperature to use. Higher values means the model will take more risks. Try 0.9 for more creative applications, and 0 (argmax sampling) for ones with a well-defined answer.

사용할 샘플링 온도. 값이 높을수록 모델이 더 많은 위험을 감수하게 됩니다. 더 창의적인 응용 프로그램에는 0.9를, 잘 정의된 답이 있는 응용 프로그램에는 0(argmax 샘플링)을 사용해 보십시오.

 

We generally recommend altering this or top_p but not both.

 

일반적으로 temperature나  top_p를 변경하는 것이 좋지만 둘 다 변경하는 것은 권장하지 않습니다.

 

top_p
number
Optional
Defaults to 1

An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.

모델이 top_p 확률 질량으로 토큰의 결과를 고려하는 핵 샘플링이라고 하는 온도(temperature)를 사용한 샘플링의 대안입니다. 따라서 0.1은 상위 10% 확률 질량을 구성하는 토큰만 고려됨을 의미합니다.

 

We generally recommend altering this or temperature but not both.

 

일반적으로 top_p 또는 온도 (temperature) 를 변경하는 것이 좋지만 둘 다 변경하는 것은 권장하지 않습니다.

 

n
integer
Optional
Defaults to 1

How many completions to generate for each prompt.

각 프롬프트에 대해 생성할 완료 수입니다.

 

Note: Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for max_tokens and stop.

 

참고: 이 매개변수는 많은 완료를 생성하기 때문에 토큰 할당량을 빠르게 소비할 수 있습니다. 신중하게 사용하고 max_tokens 및 중지에 대한 합리적인 설정이 있는지 확인하십시오.

 

stream
boolean
Optional
Defaults to false

Whether to stream back partial progress. If set, tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message.

부분 진행 상황을 스트리밍할지 여부입니다. 설정되면 토큰이 사용 가능해지면 데이터 전용 서버 전송 이벤트로 전송되며, 스트림은 data: [DONE] 메시지로 종료됩니다.

 

logprobs
integer
Optional
Defaults to null

Include the log probabilities on the logprobs most likely tokens, as well the chosen tokens. For example, if logprobs is 5, the API will return a list of the 5 most likely tokens. The API will always return the logprob of the sampled token, so there may be up to logprobs+1 elements in the response.

logprobs 가장 가능성이 높은 토큰과 선택한 토큰에 대한 로그 확률을 포함합니다. 예를 들어 logprobs가 5이면 API는 가능성이 가장 높은 5개의 토큰 목록을 반환합니다. API는 항상 샘플링된 토큰의 logprob를 반환하므로 응답에 최대 logprobs+1 요소가 있을 수 있습니다.

 

The maximum value for logprobs is 5. If you need more than this, please contact us through our Help center and describe your use case.

 

logprobs의 최대 값은 5입니다. 이보다 더 필요한 경우 고객 센터를 통해 문의하여 사용 사례를 설명하십시오.

 

echo
boolean
Optional
Defaults to false

Echo back the prompt in addition to the completion

완료(completion)에 더해서 프롬프트를 반환합니다.

 

stop
string or array
Optional
Defaults to null

Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence.

API가 추가 토큰 생성을 중지하는 최대 4개의 시퀀스. 반환된 텍스트에는 중지 시퀀스가 포함되지 않습니다.

 

presence_penalty
number
Optional
Defaults to 0

Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.

-2.0에서 2.0 사이의 숫자입니다. 양수 값은 지금까지 텍스트에 나타나는지 여부에 따라 새 토큰에 페널티를 주어 모델이 새 주제에 대해 이야기할 가능성을 높입니다.

 

See more information about frequency and presence penalties.

 
 
frequency_penalty
number
Optional
Defaults to 0

Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.

-2.0에서 2.0 사이의 숫자입니다. 양수 값은 지금까지 텍스트의 기존 빈도를 기반으로 새 토큰에 페널티를 주어 모델이 동일한 줄을 그대로 반복할 가능성을 줄입니다.

 

See more information about frequency and presence penalties.

 
 
best_of
integer
Optional
Defaults to 1

Generates best_of completions server-side and returns the "best" (the one with the highest log probability per token). Results cannot be streamed.

서버측에서 best_of 완료를 생성하고 "최고"(토큰당 로그 확률이 가장 높은 항목)를 반환합니다. 결과를 스트리밍할 수 없습니다.

 

When used with n, best_of controls the number of candidate completions and n specifies how many to return – best_of must be greater than n.

 

n과 함께 사용하는 경우 best_of는 후보 완료 수를 제어하고 n은 반환할 수를 지정합니다. best_of는 n보다 커야 합니다.

 

Note: Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for max_tokens and stop.

 

참고: 이 매개변수는 많은 완료를 생성하기 때문에 토큰 할당량을 빠르게 소비할 수 있습니다. 신중하게 사용하고 max_tokens 및 중지에 대한 합리적인 설정이 있는지 확인하십시오.

 

logit_bias
map
Optional
Defaults to null

Modify the likelihood of specified tokens appearing in the completion.

완료(completion)에 지정된 토큰이 나타날 가능성을 수정합니다.

 

Accepts a json object that maps tokens (specified by their token ID in the GPT tokenizer) to an associated bias value from -100 to 100. You can use this tokenizer tool (which works for both GPT-2 and GPT-3) to convert text to token IDs. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token.

 

토큰(GPT 토크나이저의 토큰 ID로 지정됨)을 -100에서 100 사이의 관련 바이어스 값으로 매핑하는 json 개체를 허용합니다. 이 토크나이저 도구(GPT-2 및 GPT-3 모두에서 작동)를 사용하여 변환할 수 있습니다. 토큰 ID에 대한 텍스트. 수학적으로 바이어스는 샘플링 전에 모델에 의해 생성된 로짓에 추가됩니다. 정확한 효과는 모델마다 다르지만 -1과 1 사이의 값은 선택 가능성을 낮추거나 높여야 합니다. -100 또는 100과 같은 값은 관련 토큰을 금지하거나 배타적으로 선택해야 합니다.

 

As an example, you can pass {"50256": -100} to prevent the <|endoftext|> token from being generated.

 

예를 들어 {"50256": -100}을 전달하여 <|endoftext|> 토큰이 생성되지 않도록 할 수 있습니다.

 

user
string
Optional

A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. Learn more.

OpenAI가 남용을 모니터링하고 탐지하는 데 도움이 될 수 있는 최종 사용자를 나타내는 고유 식별자입니다. 

반응형


반응형

https://beta.openai.com/docs/api-reference/models

 

List and describe the various models available in the API. You can refer to the Models documentation to understand what models are available and the differences between them.

 

API에서 사용할 수 있는 다양한 모델을 나열하고 설명합니다. 모델 설명서를 참조하여 사용 가능한 모델과 차이점을 이해할 수 있습니다.

 

https://coronasdk.tistory.com/1212

 

Get Started - Models

https://beta.openai.com/docs/models/overview OpenAI API An API for accessing new AI models developed by OpenAI beta.openai.com Models Overview The OpenAI API is powered by a family of models with different capabilities and price points. You can also custom

coronasdk.tistory.com

 

List models

GET https://api.openai.com/v1/models

Lists the currently available models, and provides basic information about each one such as the owner and availability.

현재 사용 가능한 모델을 나열하고 소유자 및 가용성과 같은 각 모델에 대한 기본 정보를 제공합니다.

 

 

Retrieve model

GET https://api.openai.com/v1/models/{model}

Retrieves a model instance, providing basic information about the model such as the owner and permissioning.

소유자 및 권한과 같은 모델에 대한 기본 정보를 제공하는 모델 인스턴스를 검색합니다.

Path parameters

https://beta.openai.com/docs/api-reference/models/retrieve#models/retrieve-model

model
string
Required

The ID of the model to use for this request

요청을 위해 사용되는 모델의 아이디.

 

 

 

 

반응형


반응형

https://beta.openai.com/docs/api-reference/making-requests

 

 

Making requests

You can paste the command below into your terminal to run your first API request. Make sure to replace YOUR_API_KEY with your secret API key.

 

아래 명령을 터미널에 붙여넣어 첫 번째 API 요청을 실행할 수 있습니다. YOUR_API_KEY를 비밀 API 키로 바꾸십시오.

 

curl https://api.openai.com/v1/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{"model": "text-davinci-003", "prompt": "Say this is a test", "temperature": 0, "max_tokens": 7}'

 

This request queries the Davinci model to complete the text starting with a prompt of "Say this is a test". The max_tokens parameter sets an upper bound on how many tokens the API will return. You should get a response back that resembles the following:

 

이 요청은 Davinci 모델을 쿼리하여 "Say this is a test"라는 프롬프트로 시작하는 텍스트를 완성합니다. max_tokens 매개변수는 API가 반환할 토큰 수에 대한 상한을 설정합니다. 다음과 유사한 응답을 받아야 합니다.

 

{
    "id": "cmpl-GERzeJQ4lvqPk8SkZu4XMIuR",
    "object": "text_completion",
    "created": 1586839808,
    "model": "text-davinci:003",
    "choices": [
        {
            "text": "\n\nThis is indeed a test",
            "index": 0,
            "logprobs": null,
            "finish_reason": "length"
        }
    ],
    "usage": {
        "prompt_tokens": 5,
        "completion_tokens": 7,
        "total_tokens": 12
    }
}

 

이제 첫 번째 완료를 생성했습니다. 프롬프트와 완료 텍스트(echo 매개변수를 true로 설정한 경우 API가 수행함)를 연결하면 결과 텍스트는 "Say this is a test. This is really test."입니다. API가 텍스트를 다시 스트리밍하도록(데이터 전용 서버 전송 이벤트로) 스트림 매개변수를 true로 설정할 수도 있습니다.

 

 

반응형