Dukungan fine tuning Gemini API menyediakan mekanisme untuk mengkurasi output saat Anda memiliki set data kecil yang berisi contoh input/output. Untuk mengetahui detail selengkapnya, lihat Panduan penyesuaian model dan tutorial.
Metode: TunedModels.create
Membuat model yang di-tuning. Periksa progres tuning perantara (jika ada) melalui layanan google.longrunning.Operations
.
Akses status dan hasil melalui layanan Operasi. Contoh: GET /v1/tunedModels/az2mb0bpw6i/operations/000-111-222
Endpoint
posting
https://generativelanguage.googleapis.com/v1beta/tunedModels
Parameter kueri
tunedModelId
string
Opsional. ID unik untuk model yang di-tuning jika ditentukan. Nilai ini harus berisi hingga 40 karakter, karakter pertama harus berupa huruf, karakter terakhir harus berupa huruf atau angka. ID harus cocok dengan ekspresi reguler: [a-z]([a-z0-9-]{0,38}[a-z0-9])?
.
Isi permintaan
Isi permintaan memuat instance TunedModel
.
displayName
string
Opsional. Nama yang akan ditampilkan untuk model ini dalam antarmuka pengguna. Nama tampilan harus berisi maksimal 40 karakter termasuk spasi.
description
string
Opsional. Deskripsi singkat tentang model ini.
tuningTask
object (TuningTask
)
Wajib diisi. Tugas tuning yang membuat model yang di-tuning.
source_model
. Model yang digunakan sebagai titik awal tuning. source_model
hanya dapat berupa salah satu dari berikut:
tunedModelSource
object (TunedModelSource
)
Opsional. TunedModel yang akan digunakan sebagai titik awal untuk melatih model baru.
baseModel
string
Tidak dapat diubah. Nama Model
yang akan di-tuning. Contoh: models/gemini-1.5-flash-001
temperature
number
Opsional. Mengontrol keacakan output.
Nilai dapat memiliki rentang lebih dari [0.0,1.0]
, inklusif. Nilai yang lebih dekat ke 1.0
akan menghasilkan respons yang lebih bervariasi, sedangkan nilai yang lebih dekat ke 0.0
biasanya akan menghasilkan respons yang tidak terlalu mengejutkan dari model.
Nilai ini menentukan nilai default yang digunakan oleh model dasar saat membuat model.
topP
number
Opsional. Untuk pengambilan sampel Nucleus.
Pengambilan sampel inti mempertimbangkan kumpulan token terkecil yang jumlah probabilitasnya minimal topP
.
Nilai ini menentukan nilai default yang digunakan oleh model dasar saat membuat model.
topK
integer
Opsional. Untuk pengambilan sampel Top-k.
Sampling top-k mempertimbangkan kumpulan token topK
yang paling mungkin. Nilai ini menentukan default yang akan digunakan oleh backend saat melakukan panggilan ke model.
Nilai ini menentukan nilai default yang digunakan oleh model dasar saat membuat model.
Contoh permintaan
Python
Isi respons
Resource ini mewakili operasi yang berjalan lama yang merupakan hasil dari panggilan API jaringan.
Jika berhasil, isi respons memuat data dengan struktur berikut:
name
string
Nama server yang ditetapkan, yang hanya bersifat unik dalam layanan yang sama yang awalnya menampilkannya. Jika Anda menggunakan pemetaan HTTP default, name
harus berupa nama resource yang diakhiri dengan operations/{unique_id}
.
metadata
object
Metadata khusus layanan yang terkait dengan operasi. Biasanya berisi informasi kemajuan dan metadata umum seperti waktu pembuatan. Beberapa layanan mungkin tidak menyediakan metadata tersebut. Setiap metode yang menampilkan operasi yang berjalan lama harus mendokumentasikan tipe metadata, jika ada.
Objek yang berisi kolom tipe arbitrer. Kolom tambahan "@type"
berisi URI yang mengidentifikasi jenis. Contoh: { "id": 1234, "@type": "types.example.com/standard/id" }
.
done
boolean
Jika nilainya adalah false
, berarti operasi masih berlangsung. Jika true
, operasi selesai, dan error
atau response
tersedia.
result
. Hasil operasi, yang dapat berupa error
atau response
yang valid. Jika done
== false
, error
atau response
tidak ditetapkan. Jika done
== true
, tepat satu dari error
atau response
dapat ditetapkan. Beberapa layanan mungkin tidak memberikan hasil. result
hanya dapat berupa salah satu dari berikut:
error
object (Status
)
Hasil error operasi jika terjadi kegagalan atau pembatalan.
response
object
Respons operasi yang normal dan berhasil. Jika metode asli tidak menampilkan data saat berhasil, seperti Delete
, responsnya adalah google.protobuf.Empty
. Jika metode asli adalah Get
/Create
/Update
standar, responsnya harus berupa resource. Untuk metode lain, respons harus memiliki jenis XxxResponse
, dengan Xxx
yang merupakan nama metode asli. Misalnya, jika nama metode asli adalah TakeSnapshot()
, jenis respons yang disimpulkan adalah TakeSnapshotResponse
.
Objek yang berisi kolom tipe arbitrer. Kolom tambahan "@type"
berisi URI yang mengidentifikasi jenis. Contoh: { "id": 1234, "@type": "types.example.com/standard/id" }
.
Representasi JSON |
---|
{ "name": string, "metadata": { "@type": string, field1: ..., ... }, "done": boolean, // Union field |
Metode: TunedModels.generateContent
Menghasilkan respons model dengan GenerateContentRequest
input. Lihat panduan pembuatan teks untuk informasi penggunaan yang mendetail. Kemampuan input berbeda-beda antar-model, termasuk model yang disesuaikan. Lihat panduan model dan panduan penyesuaian untuk mengetahui detailnya.
Endpoint
posting
https://generativelanguage.googleapis.com/v1beta/{model=tunedModels/*}:generateContent
Parameter jalur
model
string
Wajib diisi. Nama Model
yang akan digunakan untuk menghasilkan penyelesaian.
Format: name=models/{model}
. Formatnya adalah tunedModels/{tunedmodel}
.
Isi permintaan
Isi permintaan memuat data dengan struktur berikut:
contents[]
object (Content
)
Wajib diisi. Konten percakapan saat ini dengan model.
Untuk kueri satu putaran, ini adalah instance tunggal. Untuk kueri multi-giliran seperti chat, ini adalah kolom berulang yang berisi histori percakapan dan permintaan terbaru.
tools[]
object (Tool
)
Opsional. Daftar Tools
yang dapat digunakan Model
untuk membuat respons berikutnya.
Tool
adalah potongan kode yang memungkinkan sistem berinteraksi dengan sistem eksternal untuk melakukan suatu tindakan, atau serangkaian tindakan, di luar pengetahuan dan cakupan Model
. Tool
yang didukung adalah Function
dan codeExecution
. Lihat panduan Panggilan fungsi dan Eksekusi kode untuk mempelajari lebih lanjut.
toolConfig
object (ToolConfig
)
Opsional. Konfigurasi alat untuk setiap Tool
yang ditentukan dalam permintaan. Lihat Panduan panggilan fungsi untuk contoh penggunaan.
safetySettings[]
object (SafetySetting
)
Opsional. Daftar instance SafetySetting
unik untuk memblokir konten tidak aman.
Hal ini akan diterapkan di GenerateContentRequest.contents
dan GenerateContentResponse.candidates
. Tidak boleh ada lebih dari satu setelan untuk setiap jenis SafetyCategory
. API akan memblokir semua konten dan respons yang gagal memenuhi nilai minimum yang ditetapkan oleh setelan ini. Daftar ini menggantikan setelan default untuk setiap SafetyCategory
yang ditentukan di safetySettings. Jika tidak ada SafetySetting
untuk SafetyCategory
tertentu yang disediakan dalam daftar, API akan menggunakan setelan keamanan default untuk kategori tersebut. Kategori bahaya HARM_CATEGORY_HATE_SPEECH, HARM_CATEGORY_SEXUALLY_EXPLICIT, HARM_CATEGORY_DANGEROUS_CONTENT, HARM_CATEGORY_HARASSMENT didukung. Lihat panduan untuk mendapatkan informasi mendetail tentang setelan keamanan yang tersedia. Lihat juga Panduan keamanan untuk mempelajari cara menyertakan pertimbangan keamanan dalam aplikasi AI.
systemInstruction
object (Content
)
Opsional. Menetapkan petunjuk sistem developer. Saat ini, teks saja.
generationConfig
object (GenerationConfig
)
Opsional. Opsi konfigurasi untuk pembuatan dan output model.
cachedContent
string
Opsional. Nama konten yang di-cache untuk digunakan sebagai konteks untuk menampilkan prediksi. Format: cachedContents/{cachedContent}
Contoh permintaan
Teks
Python
Node.js
Go
Shell
Kotlin
Swift
Dart
Java
Gambar
Python
Node.js
Go
Shell
Kotlin
Swift
Dart
Java
Audio
Python
Node.js
Shell
Video
Python
Node.js
Go
Shell
Python
Shell
Chat
Python
Node.js
Go
Shell
Kotlin
Swift
Dart
Java
Cache
Python
Node.js
Model yang Disesuaikan
Python
Mode JSON
Python
Node.js
Go
Shell
Kotlin
Swift
Dart
Java
Eksekusi kode
Python
Kotlin
Java
Panggilan Fungsi
Python
Node.js
Shell
Kotlin
Swift
Dart
Java
Konfigurasi pembuatan
Python
Node.js
Go
Shell
Kotlin
Swift
Dart
Java
Setelan Keamanan
Python
Node.js
Go
Shell
Kotlin
Swift
Dart
Java
Petunjuk Sistem
Python
Node.js
Go
Shell
Kotlin
Swift
Dart
Java
Isi respons
Jika berhasil, isi respons memuat instance GenerateContentResponse
.
Metode: TunedModels.get
Mendapatkan informasi tentang TunedModel tertentu.
Endpoint
dapatkan
https://generativelanguage.googleapis.com/v1beta/{name=tunedModels/*}
Parameter jalur
name
string
Wajib diisi. Nama resource model.
Format: tunedModels/my-model-id
Formatnya adalah tunedModels/{tunedmodel}
.
Isi permintaan
Isi permintaan harus kosong.
Contoh permintaan
Python
Isi respons
Jika berhasil, isi respons memuat instance TunedModel
.
Metode: TunedModels.list
Mencantumkan model yang telah dibuat.
Endpoint
dapatkan
https://generativelanguage.googleapis.com/v1beta/tunedModels
Parameter kueri
pageSize
integer
Opsional. Jumlah maksimum TunedModels
yang akan ditampilkan (per halaman). Layanan mungkin menampilkan lebih sedikit model yang disesuaikan.
Jika tidak ditentukan, maksimal 10 model yang telah disesuaikan akan ditampilkan. Metode ini menampilkan maksimal 1.000 model per halaman, meskipun Anda meneruskan pageSize yang lebih besar.
pageToken
string
Opsional. Token halaman, diterima dari panggilan tunedModels.list
sebelumnya.
Berikan pageToken
yang ditampilkan oleh satu permintaan sebagai argumen bagi permintaan berikutnya untuk mengambil halaman berikutnya.
Saat memberi nomor halaman, semua parameter lain yang diberikan ke tunedModels.list
harus cocok dengan panggilan yang menyediakan token halaman.
filter
string
Opsional. Filter adalah penelusuran teks lengkap atas deskripsi dan nama tampilan model yang disesuaikan. Secara default, hasil tidak akan menyertakan model yang telah disesuaikan dan dibagikan kepada semua orang.
Operator tambahan: - owner:me - writers:me - reader:me - reader:semua orang
Contoh: "owner:me" akan menampilkan semua model yang telah disesuaikan, yang pemanggilnya memiliki peran pemilik "readers:me" menampilkan semua model yang telah disesuaikan, yang peran pemanggilnya memiliki peran pembaca "readers:everyone" mengembalikan semua model yang telah disesuaikan yang dibagikan dengan semua orang
Isi permintaan
Isi permintaan harus kosong.
Contoh permintaan
Python
Isi respons
Respons dari tunedModels.list
yang berisi daftar Model yang diberi nomor halaman.
Jika berhasil, isi respons memuat data dengan struktur berikut:
tunedModels[]
object (TunedModel
)
Model yang ditampilkan.
nextPageToken
string
Token, yang dapat dikirim sebagai pageToken
untuk mengambil halaman berikutnya.
Jika kolom ini dihilangkan, maka tidak ada lagi halaman.
Representasi JSON |
---|
{
"tunedModels": [
{
object ( |
Metode: TunedModels.patch
Memperbarui model yang di-tuning.
Endpoint
tambalan
https://generativelanguage.googleapis.com/v1beta/{tunedModel.name=tunedModels/*}
PATCH https://generativelanguage.googleapis.com/v1beta/{tunedModel.name=tunedModels/*}
Parameter jalur
tunedModel.name
string
Hanya output. Nama model yang di-tuning. Nama unik akan dibuat saat pembuatan. Contoh: tunedModels/az2mb0bpw6i
Jika displayName ditetapkan saat membuat, bagian ID nama akan ditetapkan dengan menyambungkan kata displayName dengan tanda hubung dan menambahkan bagian acak untuk memberikan keunikan.
Contoh:
- Nama tampilan =
Sentence Translator
- name =
tunedModels/sentence-translator-u3b7m
Formatnya adalahtunedModels/{tunedmodel}
.
Parameter kueri
updateMask
string (FieldMask
format)
Wajib diisi. Daftar kolom yang akan diperbarui.
Ini adalah daftar yang dipisahkan koma yang berisi nama kolom yang sepenuhnya memenuhi syarat. Contoh: "user.displayName,photo"
.
Isi permintaan
Isi permintaan memuat instance TunedModel
.
displayName
string
Opsional. Nama yang akan ditampilkan untuk model ini dalam antarmuka pengguna. Nama tampilan harus berisi maksimal 40 karakter termasuk spasi.
description
string
Opsional. Deskripsi singkat tentang model ini.
tuningTask
object (TuningTask
)
Wajib diisi. Tugas tuning yang membuat model yang di-tuning.
source_model
. Model yang digunakan sebagai titik awal tuning. source_model
hanya dapat berupa salah satu dari berikut:
tunedModelSource
object (TunedModelSource
)
Opsional. TunedModel yang akan digunakan sebagai titik awal untuk melatih model baru.
temperature
number
Opsional. Mengontrol keacakan output.
Nilai dapat memiliki rentang lebih dari [0.0,1.0]
, inklusif. Nilai yang lebih dekat ke 1.0
akan menghasilkan respons yang lebih bervariasi, sedangkan nilai yang lebih dekat ke 0.0
biasanya akan menghasilkan respons yang tidak terlalu mengejutkan dari model.
Nilai ini menentukan nilai default yang digunakan oleh model dasar saat membuat model.
topP
number
Opsional. Untuk pengambilan sampel Nucleus.
Pengambilan sampel inti mempertimbangkan kumpulan token terkecil yang jumlah probabilitasnya minimal topP
.
Nilai ini menentukan nilai default yang digunakan oleh model dasar saat membuat model.
topK
integer
Opsional. Untuk pengambilan sampel Top-k.
Sampling top-k mempertimbangkan kumpulan token topK
yang paling mungkin. Nilai ini menentukan default yang akan digunakan oleh backend saat melakukan panggilan ke model.
Nilai ini menentukan nilai default yang digunakan oleh model dasar saat membuat model.
Isi respons
Jika berhasil, isi respons memuat instance TunedModel
.
Metode: TunedModels.delete
Menghapus model yang di-tuning.
Endpoint
hapus
https://generativelanguage.googleapis.com/v1beta/{name=tunedModels/*}
Parameter jalur
name
string
Wajib diisi. Nama resource model. Format: tunedModels/my-model-id
Formatnya adalah tunedModels/{tunedmodel}
.
Isi permintaan
Isi permintaan harus kosong.
Isi respons
Jika berhasil, isi respons akan kosong.
Resource REST: TunedModels
- Resource: TunedModel
- TunedModelSource
- Status
- TuningTask
- TuningSnapshot
- Set data
- TuningExamples
- TuningExample
- Hyperparameter
- Metode
Resource: TunedModel
Model yang lebih baik yang dibuat menggunakan ModelService.CreateTunedModel.
name
string
Hanya output. Nama model yang di-tuning. Nama unik akan dibuat saat pembuatan. Contoh: tunedModels/az2mb0bpw6i
Jika displayName ditetapkan saat membuat, bagian ID nama akan ditetapkan dengan menyambungkan kata displayName dengan tanda hubung dan menambahkan bagian acak untuk memberikan keunikan.
Contoh:
- Nama tampilan =
Sentence Translator
- nama =
tunedModels/sentence-translator-u3b7m
displayName
string
Opsional. Nama yang akan ditampilkan untuk model ini dalam antarmuka pengguna. Nama tampilan harus berisi maksimal 40 karakter termasuk spasi.
description
string
Opsional. Deskripsi singkat tentang model ini.
state
enum (State
)
Hanya output. Status model yang di-tuning.
createTime
string (Timestamp
format)
Hanya output. Stempel waktu saat model ini dibuat.
Stempel waktu dalam RFC3339 UTC "Zulu" , dengan resolusi nanodetik dan hingga sembilan digit pecahan. Contoh: "2014-10-02T15:01:23Z"
dan "2014-10-02T15:01:23.045123456Z"
.
updateTime
string (Timestamp
format)
Hanya output. Stempel waktu saat model ini diperbarui.
Stempel waktu dalam RFC3339 UTC "Zulu" , dengan resolusi nanodetik dan hingga sembilan digit pecahan. Contoh: "2014-10-02T15:01:23Z"
dan "2014-10-02T15:01:23.045123456Z"
.
tuningTask
object (TuningTask
)
Wajib diisi. Tugas tuning yang membuat model yang di-tuning.
source_model
. Model yang digunakan sebagai titik awal tuning. source_model
hanya dapat berupa salah satu dari berikut:
tunedModelSource
object (TunedModelSource
)
Opsional. TunedModel yang akan digunakan sebagai titik awal untuk melatih model baru.
baseModel
string
Tidak dapat diubah. Nama Model
yang akan di-tuning. Contoh: models/gemini-1.5-flash-001
temperature
number
Opsional. Mengontrol keacakan output.
Nilai dapat memiliki rentang lebih dari [0.0,1.0]
, inklusif. Nilai yang lebih dekat ke 1.0
akan menghasilkan respons yang lebih bervariasi, sedangkan nilai yang lebih dekat ke 0.0
biasanya akan menghasilkan respons yang tidak terlalu mengejutkan dari model.
Nilai ini menentukan nilai default yang digunakan oleh model dasar saat membuat model.
topP
number
Opsional. Untuk pengambilan sampel Nucleus.
Pengambilan sampel inti mempertimbangkan kumpulan token terkecil yang jumlah probabilitasnya minimal topP
.
Nilai ini menentukan nilai default yang digunakan oleh model dasar saat membuat model.
topK
integer
Opsional. Untuk pengambilan sampel Top-k.
Sampling top-k mempertimbangkan kumpulan token topK
yang paling mungkin. Nilai ini menentukan default yang akan digunakan oleh backend saat melakukan panggilan ke model.
Nilai ini menentukan nilai default yang digunakan oleh model dasar saat membuat model.
Representasi JSON |
---|
{ "name": string, "displayName": string, "description": string, "state": enum ( |
TunedModelSource
Model yang disesuaikan sebagai sumber untuk melatih model baru.
tunedModel
string
Tidak dapat diubah. Nama TunedModel
yang akan digunakan sebagai titik awal untuk melatih model baru. Contoh: tunedModels/my-tuned-model
baseModel
string
Hanya output. Nama dasar Model
yang disesuaikan untuk TunedModel
ini. Contoh: models/gemini-1.5-flash-001
Representasi JSON |
---|
{ "tunedModel": string, "baseModel": string } |
Negara Bagian
Status model yang di-tuning.
Enum | |
---|---|
STATE_UNSPECIFIED |
Nilai default. Nilai ini tidak digunakan. |
CREATING |
Model sedang dibuat. |
ACTIVE |
Model ini siap digunakan. |
FAILED |
Model gagal dibuat. |
TuningTask
Menyesuaikan tugas yang membuat model yang telah disesuaikan.
startTime
string (Timestamp
format)
Hanya output. Stempel waktu saat penyesuaian model ini dimulai.
Stempel waktu dalam RFC3339 UTC "Zulu" , dengan resolusi nanodetik dan hingga sembilan digit pecahan. Contoh: "2014-10-02T15:01:23Z"
dan "2014-10-02T15:01:23.045123456Z"
.
completeTime
string (Timestamp
format)
Hanya output. Stempel waktu saat melakukan tuning model ini selesai.
Stempel waktu dalam RFC3339 UTC "Zulu" , dengan resolusi nanodetik dan hingga sembilan digit pecahan. Contoh: "2014-10-02T15:01:23Z"
dan "2014-10-02T15:01:23.045123456Z"
.
snapshots[]
object (TuningSnapshot
)
Hanya output. Metrik yang dikumpulkan selama tuning.
trainingData
object (Dataset
)
Wajib diisi. Input saja. Tidak dapat diubah. Data pelatihan model.
hyperparameters
object (Hyperparameters
)
Tidak dapat diubah. Hyperparameter yang mengontrol proses tuning. Jika tidak diberikan, nilai default akan digunakan.
Representasi JSON |
---|
{ "startTime": string, "completeTime": string, "snapshots": [ { object ( |
TuningSnapshot
Rekam untuk satu langkah tuning.
step
integer
Hanya output. Langkah tuning.
epoch
integer
Hanya output. Epoch yang merupakan bagian dari langkah ini.
meanLoss
number
Hanya output. Rata-rata hilangnya contoh pelatihan untuk langkah ini.
computeTime
string (Timestamp
format)
Hanya output. Stempel waktu saat metrik ini dihitung.
Stempel waktu dalam RFC3339 UTC "Zulu" , dengan resolusi nanodetik dan hingga sembilan digit pecahan. Contoh: "2014-10-02T15:01:23Z"
dan "2014-10-02T15:01:23.045123456Z"
.
Representasi JSON |
---|
{ "step": integer, "epoch": integer, "meanLoss": number, "computeTime": string } |
Set data
Set data untuk pelatihan atau validasi.
dataset
. Data inline atau referensi ke data. dataset
hanya dapat berupa salah satu dari yang berikut:
examples
object (TuningExamples
)
Opsional. Contoh inline.
Representasi JSON |
---|
{ // Union field |
TuningExamples
Sekumpulan contoh tuning. Dapat berupa data pelatihan atau validasi.
examples[]
object (TuningExample
)
Wajib diisi. Contoh. Contoh input bisa untuk teks atau diskusi, tetapi semua contoh dalam kumpulan harus memiliki jenis yang sama.
Representasi JSON |
---|
{
"examples": [
{
object ( |
TuningExample
Satu contoh untuk tuning.
output
string
Wajib diisi. Output model yang diharapkan.
model_input
. Input ke model untuk contoh ini. model_input
hanya dapat berupa salah satu dari berikut:
textInput
string
Opsional. Input model teks.
Representasi JSON |
---|
{ "output": string, // Union field |
Hyperparameter
Hyperparameter yang mengontrol proses tuning. Baca selengkapnya di https://ai.google.dev/docs/model_tuning_guidance
learning_rate_option
. Opsi untuk menentukan kecepatan pembelajaran selama tuning. learning_rate_option
hanya dapat berupa salah satu dari yang berikut:
learningRate
number
Opsional. Tidak dapat diubah. Hyperparameter kecepatan pembelajaran untuk penyesuaian. Jika tidak ditetapkan, nilai default 0,001 atau 0,0002 akan dihitung berdasarkan jumlah contoh pelatihan.
learningRateMultiplier
number
Opsional. Tidak dapat diubah. Pengganda kecepatan pembelajaran digunakan untuk menghitung learningRate akhir berdasarkan nilai default (direkomendasikan). Kecepatan pembelajaran aktual := learningRateMultiplier * Kecepatan pembelajaran default Kecepatan pembelajaran default bergantung pada model dasar dan ukuran set data. Jika tidak disetel, nilai default 1.0 akan digunakan.
epochCount
integer
Tidak dapat diubah. Jumlah epoch pelatihan. Satu epoch adalah satu penerusan data pelatihan. Jika tidak disetel, nilai default 5 akan digunakan.
batchSize
integer
Tidak dapat diubah. Hyperparameter ukuran tumpukan untuk penyesuaian. Jika tidak disetel, jumlah default 4 atau 16 akan digunakan berdasarkan jumlah contoh pelatihan.
Representasi JSON |
---|
{ // Union field |