A GPT model is a generative language model used to follow prompts, produce text, and handle tasks such as chat, instruction following, and code completion. “GPT” sounds grandly futuristic; choosing one is often more about the job, speed, cost, and input limit. section 1.5 section 1.6
Choose a model flavor by matching its practical trade-offs to the task:
- Use chat-oriented GPT-3.5 Turbo for general-purpose conversational work; its instruct variant emphasizes instruction following. section 1.5
- Use code-davinci-002 for programming-oriented code completion, rather than treating every model as the same tool wearing a different hat. section 1.5
- Consider specialized or cheaper GPT-3 variants when a task is narrow, such as sentiment classification or simple conversation. section 1.6
- Budget prompt and response space together: token limits and context windows constrain how much material a request can contain and how detailed its answer can be. section 1.3
Classify product reviews with a GPT model
Send each review with a tightly specified prompt—return only “positive” or “negative”—and set temperature to 0 for consistent output. Compare the resulting labels with known labels rather than assuming the model got every tweet right; neutral and irrelevant items can be misclassified, and API rate limits can interrupt larger runs. section 8.4
GPT is useful beyond a chat window when paired with tools and automation. A transcript can be turned into a searchable document and queried for a meeting’s relevant points; a document index can answer focused questions about a dataset. The model may save time and coding effort, but it still needs verification when results matter. section 8.1 section 1.0
def analyze_gpt35(text):
messages = [
{"role": "system", "content": """You are trained to analyze and \
detect the sentiment of given text. If you're unsure of an \
answer, you can say "not sure" and recommend users to review \
manually."""},
{"role": "user", "content": f"""Analyze the following product \
review and determine if the sentiment is: positive or \
negative. Return answer in single word as either positive or \
negative: {text}"""}
]
response = openai.ChatCompletion.create(model="gpt-3.5-turbo",\
messages=messages, max_tokens=100, temperature=0)
response_text = response.choices[0].message.content.strip().lower()
return response_text
This Python request shows the moving parts of a GPT-3.5 sentiment call: system guidance, a constrained user prompt, a model name, token cap, and temperature. section 8.4

















