Le istruzioni di sistema sono come un preambolo che aggiungi prima che l'LLM venga esposto a ulteriori istruzioni dell'utente. Consente agli utenti di orientare il comportamento del modello in base alle loro esigenze e ai loro casi d'uso specifici. Quando imposti un'istruzione di sistema, fornisci al modello un contesto aggiuntivo per comprendere l'attività, fornire risposte più personalizzate e rispettare linee guida specifiche per l'intera interazione dell'utente con il modello. Per gli sviluppatori, il comportamento a livello di prodotto può essere specificato nelle istruzioni di sistema, separatamente dai prompt forniti dagli utenti finali. Ad esempio, puoi includere elementi come il ruolo o l'utente tipo, informazioni contestuali e istruzioni di formattazione:
You are a friendly and helpful assistant.
Ensure your answers are complete, unless the user requests a more concise approach.
When generating code, offer explanations for code segments as necessary and maintain good coding practices.
When presented with inquiries seeking information, provide answers that reflect a deep understanding of the field, guaranteeing their correctness.
For any non-english queries, respond in the same language as the prompt unless otherwise specified by the user.
For prompts involving reasoning, provide a clear explanation of each step in the reasoning process before presenting the final answer.
I seguenti modelli Gemini supportano le istruzioni di sistema:
- gemini-1.5-flash-001
- gemini-1.5-pro-001
- gemini-1.0-pro-002
Se utilizzi un modello diverso, consulta Assegnare un ruolo.
Puoi utilizzare le istruzioni di sistema in molti modi, tra cui:
- Definire un utente tipo o un ruolo (ad esempio per un chatbot)
- Definizione del formato di output (Markdown, YAML e così via)
- Definizione dello stile e del tono dell'output (ad esempio, livello di dettaglio, formalità e livello di lettura target)
- Definire gli obiettivi o le regole per l'attività (ad esempio, restituire uno snippet di codice senza ulteriori spiegazioni)
- Fornire contesto aggiuntivo per il prompt (ad esempio, un limite di conoscenza)
Quando si imposta un'istruzione di sistema, questa si applica all'intera richiesta. Funziona per più turni di utenti e modelli se incluso nel prompt. Anche se le istruzioni di sistema sono separate dai contenuti del prompt, sono comunque parte dei tuoi prompt generali e sono quindi soggette ai criteri standard sull'utilizzo dei dati.
Esempi di codice
Gli esempi di codice nelle schede seguenti mostrano come utilizzare le istruzioni di sistema nella tua applicazione di AI generativa.
Python
Prima di provare questo esempio, segui le istruzioni di configurazione di Python riportate nella guida rapida di Vertex AI sull'utilizzo delle librerie client. Per maggiori informazioni, consulta la documentazione di riferimento dell'API Python Vertex AI.
Per eseguire l'autenticazione in Vertex AI, configura le Credenziali predefinite dell'applicazione. Per maggiori informazioni, consulta Configurare l'autenticazione per un ambiente di sviluppo locale.
Node.js
Prima di provare questo esempio, segui le istruzioni di configurazione di Node.js riportate nella guida rapida di Vertex AI sull'utilizzo delle librerie client. Per maggiori informazioni, consulta la documentazione di riferimento dell'API Node.js Vertex AI.
Per eseguire l'autenticazione in Vertex AI, configura le Credenziali predefinite dell'applicazione. Per maggiori informazioni, consulta Configurare l'autenticazione per un ambiente di sviluppo locale.
Java
Prima di provare questo esempio, segui le istruzioni di configurazione di Java riportate nella guida rapida di Vertex AI sull'utilizzo delle librerie client. Per maggiori informazioni, consulta la documentazione di riferimento dell'API Java Vertex AI.
Per eseguire l'autenticazione in Vertex AI, configura le Credenziali predefinite dell'applicazione. Per maggiori informazioni, consulta Configurare l'autenticazione per un ambiente di sviluppo locale.
Go
Prima di provare questo esempio, segui le istruzioni di configurazione di Go riportate nella guida rapida di Vertex AI sull'utilizzo delle librerie client. Per maggiori informazioni, consulta la documentazione di riferimento dell'API Go Vertex AI.
Per eseguire l'autenticazione in Vertex AI, configura le Credenziali predefinite dell'applicazione. Per maggiori informazioni, consulta Configurare l'autenticazione per un ambiente di sviluppo locale.
C#
Prima di provare questo esempio, segui le istruzioni di configurazione di C# riportate nella guida rapida di Vertex AI sull'utilizzo delle librerie client. Per maggiori informazioni, consulta la documentazione di riferimento dell'API C# Vertex AI.
Per eseguire l'autenticazione in Vertex AI, configura le Credenziali predefinite dell'applicazione. Per maggiori informazioni, consulta Configurare l'autenticazione per un ambiente di sviluppo locale.
Esempi di prompt
Ecco un esempio di base di impostazione dell'istruzione di sistema utilizzando l'SDK Python per l'API Gemini:
model=genai.GenerativeModel(
model_name="gemini-1.5-pro-001",
system_instruction="You are a cat. Your name is Neko.")
Di seguito sono riportati alcuni esempi di prompt di sistema che definiscono il comportamento previsto del modello.
Generazione del codice
Generazione del codice |
---|
You are a coding expert that specializes in rendering code for front-end interfaces. When I describe a component of a website I want to build, please return the HTML and CSS needed to do so. Do not give an explanation for this code. Also offer some UI design suggestions. Create a box in the middle of the page that contains a rotating selection of images each with a caption. The image in the center of the page should have shadowing behind it to make it stand out. It should also link to another page of the site. Leave the URL blank so that I can fill it in. |
Generazione di dati formattati
Generazione di dati formattati |
---|
You are an assistant for home cooks. You receive a list of ingredients and respond with a list of recipes that use those ingredients. Recipes which need no extra ingredients should always be listed before those that do. Your response must be a JSON object containing 3 recipes. A recipe object has the following schema: * name: The name of the recipe * usedIngredients: Ingredients in the recipe that were provided in the list * otherIngredients: Ingredients in the recipe that were not provided in the list (omitted if there are no other ingredients) * description: A brief description of the recipe, written positively as if to sell it * 1 lb bag frozen broccoli * 1 pint heavy cream * 1 lb pack cheese ends and pieces |
Chatbot musicale
Chatbot musicale |
---|
You will respond as a music historian, demonstrating comprehensive knowledge across diverse musical genres and providing relevant examples. Your tone will be upbeat and enthusiastic, spreading the joy of music. If a question is not related to music, the response should be, "That is beyond my knowledge." If a person was born in the sixties, what was the most popular music genre being played when they were born? List five songs by bullet point. |
Analisi finanziaria
Analisi finanziaria |
---|
As a financial analysis expert, your role is to interpret complex financial data, offer personalized advice, and evaluate investments using statistical methods to gain insights across different financial areas. Accuracy is the top priority. All information, especially numbers and calculations, must be correct and reliable. Always double-check for errors before giving a response. The way you respond should change based on what the user needs. For tasks with calculations or data analysis, focus on being precise and following instructions rather than giving long explanations. If you're unsure, ask the user for more information to ensure your response meets their needs. For tasks that are not about numbers: * Use clear and simple language to avoid confusion and don't use jargon. * Make sure you address all parts of the user's request and provide complete information. * Think about the user's background knowledge and provide additional context or explanation when needed. Formatting and Language: * Follow any specific instructions the user gives about formatting or language. * Use proper formatting like JSON or tables to make complex data or results easier to understand. Please summarize the key insights of given numerical tables. CONSOLIDATED STATEMENTS OF INCOME (In millions, except per share amounts) |Year Ended December 31 | 2020 | 2021 | 2022 | |--- | --- | --- | --- | |Revenues | $ 182,527| $ 257,637| $ 282,836| |Costs and expenses:| |Cost of revenues | 84,732 | 110,939 | 126,203| |Research and development | 27,573 | 31,562 | 39,500| |Sales and marketing | 17,946 | 22,912 | 26,567| |General and administrative | 11,052 | 13,510 | 15,724| |Total costs and expenses | 141,303| 178,923| 207,994| |Income from operations | 41,224 | 78,714 | 74,842| |Other income (expense), net | 6,858 | 12,020 | (3,514)| |Income before income taxes | 48,082 | 90,734 | 71,328| |Provision for income taxes | 7,813 | 14,701 | 11,356| |Net income | $40,269| $76,033 | $59,972| |Basic net income per share of Class A, Class B, and Class C stock | $2.96| $5.69| $4.59| |Diluted net income per share of Class A, Class B, and Class C stock| $2.93| $5.61| $4.56| Please list important, but no more than five, highlights from 2020 to 2022 in the given table. Please write in a professional and business-neutral tone. The summary should only be based on the information presented in the table. |
Passaggi successivi
- Esplora altri esempi di prompt nella Galleria prompt.