Mendesain perintah teks

Halaman ini memberikan ringkasan dan panduan umum untuk mendesain prompt teks.


Jika ingin mengikuti panduan langkah demi langkah untuk tugas ini langsung di Konsol Google Cloud, klik Pandu saya:

Pandu saya


Model yang didukung

  • text-bison
  • text-bison-32k
  • text-unicorn
  • gemini-1.0-pro

Struktur perintah

Anda dapat menambahkan informasi kontekstual, petunjuk, contoh, pertanyaan, daftar, dan jenis konten teks lainnya yang dapat Anda pikirkan. Memberi label konten teks dengan menambahkan awalan ke teks. Awalan dapat berupa kata atau frasa yang diakhiri dengan titik dua (:), seperti contoh berikut.

  • Teks:
  • Pertanyaan:
  • Jawaban:
  • Kategori:
  • Opsi:

Anda dapat menggunakan awalan apa pun yang diinginkan, tetapi Anda mungkin mendapati bahwa beberapa awalan berfungsi lebih baik daripada yang lain untuk tugas tertentu. Anda juga harus memastikan bahwa Anda merujuk ke awalan secara konsisten dalam perintah tersebut.

Referensi tidak konsisten: Petunjuk menggunakan istilah sentiment dan tweet, tetapi awalannya adalah Teks: dan Jawaban:.


Classify the sentiment of the following tweet as positive or negative.
Text: I love chocolate.
Answer:
      

Referensi yang konsisten: Awalan Text: dan Sentimen: cocok dengan istilah yang digunakan dalam instruksi.


Classify the sentiment of the following text as positive or negative.
Text: I love chocolate.
Sentiment:
      

Jenis tugas umum

Anda dapat membuat perintah teks untuk menangani sejumlah tugas. Beberapa tugas yang paling umum adalah klasifikasi, ringkasan, dan ekstraksi. Anda dapat mempelajari lebih lanjut cara mendesain perintah teks untuk tugas umum ini di halaman berikut:

Perintah klasifikasi

Tugas klasifikasi menetapkan class atau kategori ke teks. Anda dapat menentukan daftar kategori yang akan dipilih atau membiarkan model memilih dari kategorinya sendiri. Halaman ini menunjukkan cara membuat perintah yang mengklasifikasikan teks.

Kasus penggunaan klasifikasi

Berikut adalah kasus penggunaan umum untuk klasifikasi teks:

  • Deteksi penipuan: Mengklasifikasikan apakah transaksi dalam data keuangan palsu atau tidak.
  • Pemfilteran spam: Mengidentifikasi apakah email merupakan spam atau bukan.
  • Analisis sentimen: Mengklasifikasikan sentimen yang disampaikan dalam teks sebagai positif atau negatif. Misalnya, Anda dapat mengklasifikasikan ulasan film atau email sebagai positif atau negatif.
  • Moderasi konten: Mengidentifikasi dan melaporkan konten yang mungkin berbahaya, seperti bahasa menyinggung atau phishing.

Praktik terbaik untuk perintah klasifikasi

Coba setel suhu ke nol dan top-K ke satu. Tugas klasifikasi biasanya bersifat deterministik, sehingga setelan ini sering kali memberikan hasil terbaik.

Contoh perintah klasifikasi

Gunakan contoh berikut untuk mempelajari cara mendesain perintah klasifikasi untuk berbagai kasus penggunaan.

Perintah analisis sentimen

Analisis sentimen mengevaluasi teks dan mengklasifikasikannya sebagai positif atau negatif. Menyertakan analisis sentimen dalam perintah berguna saat menganalisis konten seperti ulasan, masukan, dan email.

Perintah berikut mengklasifikasikan sentimen ulasan:


Give the sentiment of this review.
Review: This is a shoe I will wear with black dress pants or jeans when I need comfort and a little style, but I am not impressed. This is a very flimsy shoe with little support at all. Unlike any other shoes I've purchased in the past. It looks nice, but it's not comfortable.
  

Negative
  

Anda dapat meminta model agar menampilkan alasan di balik jawabannya dengan memintanya untuk menjelaskan alasannya.


Give the sentiment of this review and explain your reasoning.
Review: This is a shoe I will wear with black dress pants or jeans when I need comfort and a little style, but I am not impressed. This is a very flimsy shoe with little support at all. Unlike any other shoes I've purchased in the past. It looks nice, but it's not comfortable.
  

Negative

The reviewer expresses disappointment with the shoe's lack of support and comfort, despite its stylish appearance. The reviewer also mentions that the shoe is flimsy and not like any other shoes they have purchased in the past. They say that the shoe looks nice, but it's not comfortable, which suggests that the style of the shoe is not enough to compensate for its lack of comfort.
  

Anda juga bisa membuat model untuk menghasilkan respons lebih terstruktur yang mencakup sentimen dan penjelasan alasan model memilih sentimen tersebut.


For the given review, return a JSON object that has the fields sentiment and explanation. Acceptable values for sentiment are Positive or Negative. The explanation field contains text that explains the sentiment.
Review: This is a shoe I will wear with black dress pants or jeans when I need comfort and a little style, but I am not impressed. This is a very flimsy shoe with little support at all. Unlike any other shoes I've purchased in the past. It looks nice, but it's not comfortable.
  

```
{
"sentiment": "Negative",
"explanation": "The reviewer is not impressed with the shoe, calling it flimsy and lacking support. They also say that it is not comfortable, despite looking nice."
}
```
  

Perintah klasifikasi konten

Perintah berikut mengklasifikasikan email pelanggan berdasarkan permintaan dalam kontennya.


Classify the text as one of the following categories:
- increase credit limit
- cancel credit card
- charge dispute

Text: I lost my wallet yesterday so I need to cancel my credit card and get a new one. My card number is 1234.
Category:
  

cancel credit card
  

Jika permintaan dalam email tidak jelas, Anda mungkin perlu mengirimkannya ke layanan pelanggan untuk mendapatkan informasi selengkapnya. Untuk melakukannya, tambahkan kategori "layanan pelanggan" dan instruksikan model untuk menerapkan kategori ini ke pencilan yang memerlukan informasi lebih lanjut.


Classify the text as one of the following categories:
- increase credit limit
- cancel credit card
- charge dispute
If the text doesn't fit any categories, classify it as the following:
- customer service

Text: I want to remodel my bathroom. What are my options?
Category:
  

Customer service
  

Opsi lain untuk menangani email yang memerlukan lebih banyak informasi adalah dengan menyertakan contoh hal yang harus dilakukan dengan pencilan yang tidak sesuai dengan kategori lainnya.


Classify the text as one of the following categories:
- increase credit limit
- cancel credit card
- charge dispute
- customer service

Text: I need to buy a car.
Category: customer service
Text: But I was in Chicago.
Category: customer service
Text: Where are my papers?
Category: customer service

Text: I want to remodel my bathroom.
Category:
  

customer service
  

Perintah klasifikasi film

Perintah berikut mengklasifikasikan film yang sebaiknya Anda tonton bersamanya.


Classify the following movie as one of the following categories:
- watch alone
- watch with friends
- watch with family
- watch on a date

Text: The Goonies
Category:
  

Watch with friends
  

Anda mungkin perlu menentukan kategori Anda sendiri. Misalnya, Anda memiliki hotel hewan peliharaan bernama Remi Inn yang menayangkan film tentang hewan peliharaan. Kriteria pemilihan film dapat berupa:

  • Karakter utama harus hewan.
  • Filmnya harus menggembirakan.
  • Film tidak boleh berupa kartun.

Perintah berikut mengklasifikasikan film yang cocok dengan tiga kriteria tersebut sebagai Remi-tastic dan yang lainnya sebagai Bark-fest.


Remi-tastic movies must meet the following criteria:
- The main character must be an animal.
- The movie must be family friendly.
- The movie cannot be a cartoon.
If a movie is not Remi-tastic, then it is Bark-fest.

Classify the movie as one of the following categories:
- Remi-tastic
- Bark-fest

Text: The Adventures of Milo and Otis
Category:
  

Remi-tastic
  

Untuk memeriksa apakah model menggunakan kriteria atau memilih klasifikasi secara acak, perintah berikut menyertakan petunjuk untuk menampilkan alasan klasifikasinya.


Remi-tastic movies must meet the following criteria:
- The main character must be an animal.
- The movie must be family friendly.
- The movie cannot be a cartoon.
If a movie is not Remi-tastic, then it is Bark-fest.

Classify the movie as one of the following categories:
- Remi-tastic
- Bark-fest
Explain why.

Text: The Adventures of Milo and Otis
Category:
  

Remi-tastic

Explanation: "The Adventures of Milo and Otis" is a live-action animal adventure movie featuring two main characters: Milo, a cat, and Otis, a pug. The movie is suitable for families of all ages and is not a cartoon. Therefore, it meets all three criteria for being Remi-tastic.
  

Perintah pembuatan ringkasan

Tugas membuat ringkasan mengekstrak informasi yang paling penting dari teks. Anda dapat memberikan informasi dalam perintah untuk membantu model membuat ringkasan, atau meminta model untuk membuat ringkasan sendiri. Halaman ini menunjukkan cara mendesain prompt untuk membuat berbagai jenis ringkasan.

Kasus penggunaan pembuatan ringkasan

Berikut adalah kasus penggunaan umum untuk pembuatan ringkasan:

  • Merangkum teks: Meringkas konten teks seperti berikut:
    • Artikel berita.
    • Makalah penelitian.
    • Dokumen hukum.
    • Dokumen keuangan.
    • Dokumen teknis.
    • Masukan pelanggan.
  • Pembuatan konten: Membuat konten untuk artikel, blog, atau deskripsi produk.

Praktik terbaik

Gunakan panduan berikut untuk membuat ringkasan teks yang optimal:

  • Tentukan karakteristik yang ingin Anda sertakan dalam ringkasan.
  • Untuk ringkasan materi iklan lainnya, tentukan suhu yang lebih tinggi, nilai top-K dan top-P. Untuk mengetahui informasi selengkapnya, pelajari parameter temperature, topK, dan topP dalam Definisi parameter teks.
  • Saat menulis perintah, berfokuslah pada tujuan ringkasan dan hal yang ingin Anda dapatkan darinya.

Contoh perintah pembuatan ringkasan

Gunakan contoh berikut untuk mempelajari cara mendesain petunjuk ringkasan untuk berbagai kasus penggunaan.

Perintah pembuatan ringkasan artikel

Perintah berikut meringkas poin utama sebuah artikel:


Provide a summary for the following article:
The efficient-market hypothesis (EMH) is a hypothesis in financial economics that states that asset prices reflect all available information. A direct implication is that it is impossible to 'beat the market' consistently on a risk-adjusted basis since market prices should only react to new information. Because the EMH is formulated in terms of risk adjustment, it only makes testable predictions when coupled with a particular model of risk. As a result, research in financial economics since at least the 1990s has focused on market anomalies, that is, deviations from specific models of risk. The idea that financial market returns are difficult to predict goes back to Bachelier, Mandelbrot, and Samuelson, but is closely associated with Eugene Fama, in part due to his influential 1970 review of the theoretical and empirical research. The EMH provides the basic logic for modern risk-based theories of asset prices, and frameworks such as consumption-based asset pricing and intermediary asset pricing can be thought of as the combination of a model of risk with the EMH. Many decades of empirical research on return predictability has found mixed evidence. Research in the 1950s and 1960s often found a lack of predictability (e.g. Ball and Brown 1968; Fama, Fisher, Jensen, and Roll 1969), yet the 1980s-2000s saw an explosion of discovered return predictors (e.g. Rosenberg, Reid, and Lanstein 1985; Campbell and Shiller 1988; Jegadeesh and Titman 1993). Since the 2010s, studies have often found that return predictability has become more elusive, as predictability fails to work out-of-sample (Goyal and Welch 2008), or has been weakened by advances in trading technology and investor learning (Chordia, Subrahmanyam, and Tong 2014; McLean and Pontiff 2016; Martineau 2021).
  

Summary:
The efficient-market hypothesis (EMH) is a theory in financial economics that states that asset prices reflect all available information. This implies that it is impossible to consistently beat the market on a risk-adjusted basis. The EMH has been extensively researched, with mixed results. Some studies have found evidence of return predictability, while others have not. Recent research suggests that return predictability has become more elusive in recent years due to advances in trading technology and investor learning. The EMH provides the basis for modern risk-based theories of asset prices and frameworks such as consumption-based asset pricing and intermediary asset pricing.
  

Anda juga dapat menentukan jenis ringkasan yang diinginkan. Misalnya, jurnal akademis dan ilmiah sering kali menyertakan abstrak artikelnya. Perintah berikut meminta model untuk menulis abstrak untuk teks:


Write an abstract for this text:
The efficient-market hypothesis (EMH) is a hypothesis in financial economics that states that asset prices reflect all available information. A direct implication is that it is impossible to 'beat the market' consistently on a risk-adjusted basis since market prices should only react to new information. Because the EMH is formulated in terms of risk adjustment, it only makes testable predictions when coupled with a particular model of risk. As a result, research in financial economics since at least the 1990s has focused on market anomalies, that is, deviations from specific models of risk. The idea that financial market returns are difficult to predict goes back to Bachelier, Mandelbrot, and Samuelson, but is closely associated with Eugene Fama, in part due to his influential 1970 review of the theoretical and empirical research. The EMH provides the basic logic for modern risk-based theories of asset prices, and frameworks such as consumption-based asset pricing and intermediary asset pricing can be thought of as the combination of a model of risk with the EMH. Many decades of empirical research on return predictability has found mixed evidence. Research in the 1950s and 1960s often found a lack of predictability (e.g. Ball and Brown 1968; Fama, Fisher, Jensen, and Roll 1969), yet the 1980s-2000s saw an explosion of discovered return predictors (e.g. Rosenberg, Reid, and Lanstein 1985; Campbell and Shiller 1988; Jegadeesh and Titman 1993). Since the 2010s, studies have often found that return predictability has become more elusive, as predictability fails to work out-of-sample (Goyal and Welch 2008), or has been weakened by advances in trading technology and investor learning (Chordia, Subrahmanyam, and Tong 2014; McLean and Pontiff 2016; Martineau 2021).
  

The efficient-market hypothesis (EMH) posits that asset prices reflect all available information, making it challenging to consistently outperform the market on a risk-adjusted basis. This hypothesis has profoundly shaped modern risk-based theories of asset pricing, such as consumption-based and intermediary asset pricing. Empirical research on return predictability has yielded mixed results, with earlier studies often showing a lack of predictability while more recent ones have identified return predictors that later failed out-of-sample or were weakened by advances in trading technology and investor learning. This text delves into the theoretical underpinnings of the EMH, its implications for market anomalies and return predictability, and the ongoing debate surrounding the EMH's validity in the face of empirical evidence.
  

Perintah yang digunakan untuk membuat judul artikel mirip dengan perintah yang menggunakan frasa pendek untuk meringkas artikel. Perintah ringkasan berikut menampilkan judul untuk sebuah artikel.


Write a creative title for this text. Give three options.
Text: The efficient-market hypothesis (EMH) is a hypothesis in financial economics that states that asset prices reflect all available information. A direct implication is that it is impossible to 'beat the market' consistently on a risk-adjusted basis since market prices should only react to new information. Because the EMH is formulated in terms of risk adjustment, it only makes testable predictions when coupled with a particular model of risk. As a result, research in financial economics since at least the 1990s has focused on market anomalies, that is, deviations from specific models of risk. The idea that financial market returns are difficult to predict goes back to Bachelier, Mandelbrot, and Samuelson, but is closely associated with Eugene Fama, in part due to his influential 1970 review of the theoretical and empirical research. The EMH provides the basic logic for modern risk-based theories of asset prices, and frameworks such as consumption-based asset pricing and intermediary asset pricing can be thought of as the combination of a model of risk with the EMH. Many decades of empirical research on return predictability has found mixed evidence. Research in the 1950s and 1960s often found a lack of predictability (e.g. Ball and Brown 1968; Fama, Fisher, Jensen, and Roll 1969), yet the 1980s-2000s saw an explosion of discovered return predictors (e.g. Rosenberg, Reid, and Lanstein 1985; Campbell and Shiller 1988; Jegadeesh and Titman 1993). Since the 2010s, studies have often found that return predictability has become more elusive, as predictability fails to work out-of-sample (Goyal and Welch 2008), or has been weakened by advances in trading technology and investor learning (Chordia, Subrahmanyam, and Tong 2014; McLean and Pontiff 2016; Martineau 2021).
  

1. The Efficient Market Hypothesis: Can Market Prices Be Predicted?
2. The EMH and Market Anomalies: A Tale of Predictability and Elusive Returns
3. The Evolution of Market Efficiency: From Bachelier to Fama and Beyond
  

Perintah pembuatan ringkasan chat

Perintah berikut merangkum log chat dukungan pelanggan:


Summarize the following conversation.
Service Rep: How may I assist you today?
Customer: I need to change the shipping address for an order.
Service Rep: Ok, I can help you with that if the order has not been fulfilled from our warehouse yet. But if it has already shipped, then you will need to contact the shipping provider. Do you have the order ID?
Customer: Yes, it's 88986367.
Service Rep: One minute please while I pull up your order information.
Customer: No problem
Service Rep: Ok, it looks like your order was shipped from our warehouse 2 days ago. It is now in the hands of the shipping provider, so you will need to contact them to update your delivery details. You can track your order with the shipping provider here: https://www.shippingprovider.com
Customer: Sigh, ok.
Service Rep: Is there anything else I can help you with today?
Customer: No, thanks.
  

A customer called to inquire about changing the shipping address for their order. Unfortunately, their order had already been shipped, so the service representative provided a shipping provider link to the customer to track their order and contact them for any address updates.
  

Perintah ringkasan tokenisasi hashtag

Tokenisasi hashtag adalah bentuk ringkasan dengan model mengekstrak kata dan frasa dari teks yang mewakili teks secara keseluruhan.

Berikut adalah contoh perintah yang menggunakan tokenisasi hashtag:


Create some hashtags for this tweet:
Google Cloud
@googlecloud
·
Feb 25
We heard it through the grapevine:
- Document AI Workbench is GA and ready for production use through APIs and the Google Cloud Console
- Deliver higher model accuracy with Workbench
- Build production-ready models faster with Workbench

Read more ↓
  

- #DocumentAIWorkbench
- #GA
- #ProductionReady
- #ModelAccuracy
- #BuildFaster
- #DocumentProcessing
- #DataAnnotation
- #MachineLearning
- #AIPlatform
- #GoogleCloud
  

Perintah ekstraksi

Perintah ekstraksi memungkinkan Anda mengekstrak informasi tertentu dari teks.

Kasus penggunaan

Berikut adalah kasus penggunaan umum untuk ekstraksi:

  • Pengenalan entity bernama (NER): Mengekstrak entity bernama dari teks, termasuk orang, tempat, organisasi, dan tanggal.
  • Ekstraksi hubungan: Mengekstrak hubungan antara entity dalam teks, seperti hubungan keluarga antar-orang.
  • Ekstraksi peristiwa: Mengekstrak peristiwa dari teks, seperti pencapaian project dan peluncuran produk.
  • Jawaban pertanyaan: Mengekstrak informasi dari teks untuk menjawab pertanyaan.

Praktik terbaik

Coba setel suhu ke nol dan top-K ke satu. Tugas ekstraksi biasanya bersifat deterministik, sehingga setelan ini sering kali memberikan hasil terbaik. Untuk mengetahui informasi selengkapnya, pelajari parameter temperature dan topK dalam Definisi parameter teks.

Contoh tugas ekstraksi

Gunakan contoh berikut untuk mempelajari cara mendesain perintah ekstraksi untuk berbagai kasus penggunaan.

Menggunakan ekstraksi untuk menjawab pertanyaan

Perintah berikut menyertakan konteks dan pertanyaan. Model menelusuri konteks untuk informasi yang menjawab pertanyaan.


Context: There is evidence that there have been significant changes in Amazon rainforest vegetation over the last 21,000 years through the Last Glacial Maximum (LGM) and subsequent deglaciation. Analyses of sediment deposits from Amazon basin paleo lakes and from the Amazon Fan indicate that rainfall in the basin during the LGM was lower than for the present, and this was almost certainly associated with reduced moist tropical vegetation cover in the basin. There is debate, however, over how extensive this reduction was. Some scientists argue that the rainforest was reduced to small, isolated refugia separated by open forest and grassland; other scientists argue that the rainforest remained largely intact but extended less far to the north, south, and east than is seen today. This debate has proved difficult to resolve because the practical limitations of working in the rainforest mean that data sampling is biased away from the center of the Amazon basin, and both explanations are reasonably well supported by the available data.
Q: What does LGM stands for?
A:
  

Last Glacial Maximum
  

Format teks yang diekstrak

Anda dapat mengekstrak informasi dari sumber teks dan mengaturnya ke dalam format terstruktur. Format perintah berikut yang mengekstrak teks sebagai file JSON:


Extract the technical specifications from the text below in a JSON format. Valid fields are name, network, ram, processor, storage, and color.
Text: Google Pixel 7, 5G network, 8GB RAM, Tensor G2 processor, 128GB of storage, Lemongrass
JSON:
  

```
{
"name": "Google Pixel 7",
"network": "5G",
"ram": "8GB",
"processor": "Tensor G2",
"storage": "128GB",
"color": "Lemongrass"
}
```
  

Langkah selanjutnya