OpenAI API 0613 update: GPT-3.5-turbo-16k model, function call analysis and usage scenario summary

Table of contents

function call

Official example of function call (I'll write my own after I test it)

Step 1: Call the model with functions and user input through the OpenAI API

Step 2: Call the third-party API according to the response returned by the model

Step 3: Send the returned results of the third-party API to the model and summarize them

new model

GPT-4

GPT-3.5-turbo

model obsolete

price reduction

Embeddings

GPT-3.5-turbo

reference


OpenAI has just released an API update, and I will share it with you as soon as I see it.

 

Original address (this article is based on the original text for simple translation and localization, with a small amount of content added):

Function calling and other API updates​openai.com/blog/function-calling-and-other-api-updates

Main updates:

  • Provide function call capability in Chat Completions API
  • Update more controllable  gpt-4 and  gpt-3.5-turbo version
  • New 16k context version  gpt-3.5-turbo (compared to standard 4k version)
  • embeddings 75% off price of embedding models
  • gpt-3.5-turboInput token price reduced by 25%
  • Announcements  gpt-3.5-turbo-0301 and  gpt-4-0314 deprecation plans for models

All of the above models will follow the data privacy rules introduced in 0301 - all data using the API will not be used for training.

function call

Developers can now submit gpt-4-0613and gpt-3.5-turbo-0613describe functions, and have the model intelligently choose to output a JSON object containing the arguments for calling those functions. This is a new way to more reliably connect GPT's capabilities with external tools and APIs.

These models have been fine-tuned to both detect when a function needs to be called (based on user input) and respond with JSON that conforms to the function's signature. Function calls enable developers to more reliably get structured data from models. For example, developers can:

  • Create chatbots that answer questions by calling external tools such as the ChatGPT plugin.

Turn a query like "Email Anya to see if she wants to get coffee next Friday" into a function call, for example , or "What 's send_email(to: string, body: string)the weather like in Boston?"get_current_weather(location: string, unit: 'celsius' | 'fahrenheit')

  • Convert natural language into API calls or database queries

Convert "Who are my top ten customers this month?" into internal API calls, for example get_customers_by_revenue(start_date: string, end_date: string, limit: int), or "How many orders did Acme, Inc. place last month?" into sql_query(query: string)SQL queries used.

  • Extract structured data from text

Define a extract_people_data(people: [{name: string, birthday: string, location: string}])function called to extract all people mentioned in a Wikipedia article.

These use cases are achieved through /v1/chat/completionsnew parameters in functionsand , which allow developers to describe functions via JSON Schema and optionally require them to call specific functions. function_callPlease check the development document [1] ; if you find a case where the function call can be optimized, you can submit it to evals [2] .

Official example of function call (I'll write my own after I test it)

Ask about the weather: What's the weather like in Boston right now?

Step 1: Call the model with functions and user input through the OpenAI API

curl https://api.openai.com/v1/chat/completions -u :$OPENAI_API_KEY -H 'Content-Type: application/json' -d '{
  "model": "gpt-3.5-turbo-0613",
  "messages": [
    {"role": "user", "content": "What is the weather like in Boston?"}
  ],
  "functions": [
    {
      "name": "get_current_weather",
      "description": "Get the current weather in a given location",
      "parameters": {
        "type": "object",
        "properties": {
          "location": {
            "type": "string",
            "description": "The city and state, e.g. San Francisco, CA"
          },
          "unit": {
            "type": "string",
            "enum": ["celsius", "fahrenheit"]
          }
        },
        "required": ["location"]
      }
    }
  ]
}'

Return example:

{
  "id": "chatcmpl-123",
  ...
  "choices": [{
    "index": 0,
    "message": {
      "role": "assistant",
      "content": null,
      "function_call": {
        "name": "get_current_weather",
        "arguments": "{ \"location\": \"Boston, MA\"}"
      }
    },
    "finish_reason": "function_call"
  }]
}

Step 2: Call the third-party API according to the response returned by the model

For example, query the weather through an interface:

curl https://weatherapi.com/...

Return example:

{ "temperature": 22, "unit": "celsius", "description": "Sunny" }

Step 3: Send the returned results of the third-party API to the model and summarize them

Example request:

curl https://api.openai.com/v1/chat/completions -u :$OPENAI_API_KEY -H 'Content-Type: application/json' -d '{
  "model": "gpt-3.5-turbo-0613",
  "messages": [
    {"role": "user", "content": "What is the weather like in Boston?"},
    {"role": "assistant", "content": null, "function_call": {"name": "get_current_weather", "arguments": "{ "location": "Boston, MA"}"}},
    {"role": "function", "name": "get_current_weather", "content": "{"temperature": "22", "unit": "celsius", "description": "Sunny"}"}
  ],
  "functions": [
    {
      "name": "get_current_weather",
      "description": "Get the current weather in a given location",
      "parameters": {
        "type": "object",
        "properties": {
          "location": {
            "type": "string",
            "description": "The city and state, e.g. San Francisco, CA"
          },
          "unit": {
            "type": "string",
            "enum": ["celsius", "fahrenheit"]
          }
        },
        "required": ["location"]
      }
    }
  ]
}'

Return example:

{
  "id": "chatcmpl-123",
  ...
  "choices": [{
    "index": 0,
    "message": {
      "role": "assistant",
      "content": "The weather in Boston is currently sunny with a temperature of 22 degrees Celsius.",
    },
    "finish_reason": "stop"
  }]
}

From which the reply content can be extracted:

The weather in Boston is currently sunny with a temperature of 22 degrees Celsius.

Since the alpha release of the ChatGPT plugin, we've learned a lot about how to safely get tools and language models to work together. However, there are still some unresolved research questions. For example, a proof-of-concept vulnerability illustrates how untrusted data from tool output can instruct a model to perform unexpected actions. OpenAI is working to mitigate these and other risks. Developers can protect their applications by only using information from trusted tools and by including user confirmation steps before performing actions with real-world impact, such as sending email, posting online, or purchasing.

new model

GPT-4

gpt-4-0613 Includes an updated and improved model with function calls. gpt-4-32k-0613 Contains  gpt-4-0613 the same improvements as and can handle longer text.

With these updates, OpenAI will invite more people on the waitlist [3] to try GPT-4 in the coming weeks, and intends to use this model to remove the waitlist entirely. Thanks to everyone who has been patient, we are looking forward to seeing what you create with GPT-4!

GPT-3.5-turbo

gpt-3.5-turbo-0613Offering the same function calls as GPT-4, and more reliable manipulability through system messages, these two features allow developers to more effectively guide the model's responses.

gpt-3.5-turbo-16kThe context is gpt-3.5-turbo4 times longer and gpt-3.5-turbotwice as expensive: $0.003 per 1K input and $0.004 per 1K output. A context length of 16k means that the model can now support ~20 pages of text in a single request.

model obsolete

Today, we're starting to upgrade and deprecate the initial version of gpt-4and gpt-3.5-turbo, which we announced back in March. Apps using the stable model names ( gpt-3.5-turbo, , gpt-4and ) will be automatically upgraded to the new models above on June 27. gpt-4-32kTo compare model performance between different versions, the Evals library [4] supports public and private evaluations to show how model changes will affect user usage.

Developers who need more time to transition can continue to use the old model by specifying gpt-3.5-turbo-0301, gpt-4-0314or , in the "model" parameter of the API request . gpt-4-32k-0314These old models will remain available until September 13th, after which requests specifying these model names will fail. You can keep up to date on model deprecations via our model deprecation page [5] . This is the first update to these models, so we're eagerly awaiting developer feedback [6] to help us ensure a smooth transition.

price reduction

We will continue to improve system efficiencies and pass these savings on to developers starting today.

Embeddings

text-embedding-ada-002is our most popular embedding model. Today we cut costs by 75% to just $0.0001 per 1K markers.

GPT-3.5-turbo

gpt-3.5-turbois our most popular chat model, providing ChatGPT service for millions of users. Today, we are gpt-3.5-turbo’sreducing the cost of entering tokens by 25%. Developers can now use the model for $0.0015 per 1K input tokens and $0.002 per 1K output tokens, which equates to roughly 700 pages per dollar of service.

gpt-3.5-turbo-16kThe price is $0.003 per 1K input tokens and $0.004 per 1K output tokens.

Developer feedback is the cornerstone of our platform's evolution, and we'll continue to make improvements based on the suggestions we hear. We're excited to see how developers use these latest models and new features in their apps.

reference

  1. ^https://platform.openai.com/docs/guides/gpt/function-calling
  2. ^GitHub - openai/evals: Evals is a framework for evaluating LLMs and LLM systems, and an open-source registry of benchmarks.
  3. ^GPT-4 API waitlist
  4. ^GitHub - openai/evals: Evals is a framework for evaluating LLMs and LLM systems, and an open-source registry of benchmarks.
  5. ^https://platform.openai.com/docs/deprecations/
  6. ^OpenAI Developer Forum

 

Guess you like

Origin blog.csdn.net/qqerrr/article/details/131254255