Example of a Code-like Prompt for Machine Translation
A code-like prompt for machine translation structures the task similarly to variable assignments in programming. For instance, to translate an English sentence to Chinese, the prompt could be formatted as: [src-lang] = English [tgt-lang] = Chinese [input] = {*sentence*} [output] = ___. In this template, {*sentence*} is a placeholder for the actual input sentence, and the model is expected to generate the translated text following the [output] = field.

0
1
Tags
Ch.2 Generative Models - Foundations of Large Language Models
Foundations of Large Language Models
Foundations of Large Language Models Course
Computing Sciences
Related
Example of a Code-like Prompt for Machine Translation
Example of a Generic Code-like Prompt Template
Name:Content Prompt Formatting Style
Example of a Demonstration in a Code-like Prompt
A developer needs a large language model to perform two tasks on a given text: create a one-sentence summary and extract the names of any people mentioned. Below are two potential prompt structures for this task.
Structure A:
Summarize the following text in one sentence and list the names of any people mentioned. Text: {input_text}Structure B:
[INPUT_TEXT] = "{input_text}" [TASK_1] = Create a one-sentence summary. [TASK_2] = Extract all names of people. [OUTPUT] summary: people:Which of the following statements best analyzes why Structure B is a more effective prompt design for ensuring reliable and consistent results?
Improving Prompt Reliability for Information Extraction
Using Descriptive Prompts for Complex Tasks
Critiquing a Multi-Task Prompt
Example of a Name:Content Prompt for Conversation
Example of a Name:Content Prompt for Question-Answering
Example of a Code-like Prompt for Machine Translation
Storing Prompt Data in Key-Value Formats like JSON
Example of a Code-Style Demonstration for English-to-German Translation
Examples of Key-Value Pairs in a Code-Style Translation Prompt
A developer is building a system to extract structured information from customer support emails. Their initial prompt, 'From the following email, extract the customer's name, order number, and the core issue,' often results in the language model producing a long, narrative paragraph that mixes the requested information with other details. Which of the following best explains why adopting a
name:contentformatting style, where the model is prompted to complete fields likecustomer_name:,order_number:, andissue_summary:, would be a more effective strategy?Designing a Structured Prompt for Recipe Generation
A developer is creating a few-shot prompt to teach a language model how to convert informal user requests into a structured JSON object for an internal API. The goal is to extract the user's name and the item they want to order. Which of the following prompts most effectively uses a clear, key-value formatting style to structure the task and guide the model toward a reliable output?
Example of a Name:Content Prompt for Task Specification
Learn After
A user needs to translate the French sentence 'Bonjour le monde' into Spanish. Based on the principles of creating a clear, code-like prompt structure, which of the following options is the most effective and unambiguous way to format this request for a language model?
Constructing a Machine Translation Prompt
Debugging a Machine Translation Prompt