驗證

使用 OpenAI API 開發 AI 系統

Francesca Donadoni

Curriculum Manager, DataCamp

驗證

一位開發者在多個螢幕上測試程式碼

使用 OpenAI API 開發 AI 系統

驗證

 

模型可能出錯:

  • 誤解脈絡
  • 若訓練資料有偏見,輸出會放大偏見
  • 輸出過時資訊
  • 被操弄而產生有害或不道德內容
  • 不慎洩露敏感資訊
使用 OpenAI API 開發 AI 系統

對抗式測試

一個示意圖:程式設計師向資料與模型注入對抗輸入,模型再由資料推論

1 改編自 https://adversarial-robustness-toolbox.readthedocs.io/en/latest/
使用 OpenAI API 開發 AI 系統

對抗式測試

response = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[
{"role": "system",
 "content": "You are an AI assistant for the film industry. You should interpret 
    the user prompt, a movie review, and based on that extract whether its 
    sentiment is positive, negative, or neutral."},

{"role": "user", "content": "It was great to see some of my favorite stars of 30 years ago including John Ritter, Ben Gazarra and Audrey Hepburn. They looked quite wonderful. But that was it. They were not given any characters or good lines to work with. I neither understood or cared what the characters were doing."}])
1 https://huggingface.co/datasets/davanstrien/test1?row=10
使用 OpenAI API 開發 AI 系統

對抗式測試

print(response.choices[0].message.content)
The sentiment of this movie review is negative.
使用 OpenAI API 開發 AI 系統

對抗式測試

response = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[
{"role": "system",
 "content": "You are an AI assistant for the film industry. You should interpret 
    the user prompt, a movie review, and based on that extract whether its sentiment 
    is positive, negative, or neutral."},

{"role": "user", "content": "If you read the book, your all set. If you didn't...your still all set."}]) print(response.choices[0].message.content)
The sentiment of this movie review is neutral.
使用 OpenAI API 開發 AI 系統

評估函式庫與資料集

一個示意圖:評估函式庫以多種資料集測試模型

1 https://github.com/openai/evals
使用 OpenAI API 開發 AI 系統

一起來練習吧!

使用 OpenAI API 開發 AI 系統

Preparing Video For Download...