GPT (Generative Pre-trained Transformer) is OpenAI’s family of foundation language models. Trained on large amounts of text and code, GPT models can generate and translate text, answer questions, and help write code. GPT-4 was also described as able to handle language and images. section 2.1
For developers, a GPT model is useful for producing a function or routine from a prompt, not for assuming an entire application will be ready to deploy. A request can specify the programming language, SDK, and desired output. Responses can vary between runs, so inspect generated code and test it against the task. section 1.3.4
Listing 1.1 “Hello, World!” calling OpenAI service
import os
from openai import OpenAI
gpt_model = "gpt-3.5-turbo"
# Replace with your actual OpenAI API key
client = OpenAI(api_key='your-api-key')
# Generate English text
response_english = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{
"role": "user",
"content": "Hello, World!"
}
],
max_tokens=50
)
english_text = response_english.choices[0].message.content.strip()
print(english_text)
# Translate English text to French
response_french = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{
"role": "user",
"content": "Translate the following English
text to French: " + english_text
}
],
max_tokens=100
)
# This prints the translation to French
print(response_french.choices[0].message.content.strip())
The Python listing calls GPT-3.5 Turbo through the OpenAI API, then makes a second call to translate the first response into French. It is illustrative: its API key is embedded in code, which is not an established best practice. section 1.3.4
If prompting alone does not meet a specific requirement, fine-tuning is another option. For example, GPT-3.5 Turbo can be adapted to reply only with emoji names in Microsoft Teams format. Define evaluation criteria, compare the base model with the task’s baseline, prepare training data, and evaluate the fine-tuned result. Prompt engineering and retrieval-augmented generation can still be used alongside fine-tuning; training and repeated revisions take time. section 9.2 section 9.3

















