Marc Alier (Ludo) - Home Page

Pàgina personal i Calaix Desastre

ChatGPT in Practice: Strategies for Optimal Interactions

Posted at — Sep 1, 2023

Table Of Contents

Large Language Models (LLMs) like ChatGPT are a new family of technologies that offer a lot of potential but also come with their own set of challenges. We’re using these AI tools more and more for everything from simple questions to generating complex code. So, it’s important to ask: Do we really understand how to get the best out of them?

In this blog post, we’ll go over some key best practices for using LLMs. We’ll look at the difference between AI-generated content and information from databases or search engines. We’ll also talk about the issue of “hallucinations,” where the model gives you incorrect or misleading information. And we’ll cover why the language you use to ask questions matters for the quality of the answers you get.

Whether you’re just curious or planning to integrate LLMs into your projects, this guide aims to help you use these tools more effectively.

Where does ChatGTP get its answers from

AI-Generated Content

When you ask a question to a Large Language Model like ChatGPT, it generates an answer based on a huge dataset it was trained on. This dataset includes a wide variety of sources, such as websites, books, and articles. But it’s important to know that these models can’t access real-time or updated information. What you get is based on what the model has learned up to a certain point in time.

Additionally, it’s worth noting that the information, while often accurate, is generated in a stochastic or random manner. This means that the possibility of failure or error is always part of the equation. It’s like a secret sauce that can sometimes add flavor but other times spoil the dish.

Search Engine or Database Content

In contrast to AI-generated content, information from search engines, databases, or specialized systems like Wolfram Alpha comes from real-time, factual sources. These platforms often provide peer-reviewed or verified information. Unlike Large Language Models, they can give you the most current data available, whether it’s the latest news, scientific research, or statistical data.


Understanding the difference between these two types of content is crucial. If you’re looking for up-to-date or highly factual information, relying solely on a Large Language Model might not be your best bet. While these models are incredibly versatile and can provide quick answers, they can’t replace the depth and reliability of information you’d get from a specialized database or search engine. However, it’s worth noting that accessing these specialized sources often requires technical skills, like understanding specific user interfaces or programming languages. In contrast, Large Language Models offer the convenience of obtaining information through simple, natural language queries. Knowing when to use each can help you get the most accurate and reliable information, while also considering the ease of access.

Dealing with Hallucinations

What Are Hallucinations?

In the context of Large Language Models (LLMs) like ChatGPT, hallucinations refer to the generation of inaccurate, exaggerated, or completely false information. For example, ChatGPT has been known to invent plausible-sounding answers backed with fake citations, leading users to double-check whether they had accidentally stumbled upon a real phenomenon. In some cases, it has even fabricated financial numbers in news articles or generated fake case precedents in legal briefs.

Hallucinations often occur due to limitations in the training data or the model’s understanding of context. The model doesn’t have the ability to verify the information it generates; it simply produces responses based on patterns in the data it was trained on. This stochastic nature of LLMs means that randomness and the possibility of absolute failure are always part of the equation.

Hallucination Mitigation Strategies

  1. Awareness of Potential Fabrication: The first step is to be aware that LLMs can generate made-up content. This awareness can make you more critical of the answers you receive.
  2. Assess Your Own Expertise: Your ability to judge the quality of the information is tied to your level of expertise on the topic. If you’re knowledgeable in a subject, you’re better equipped to spot inaccuracies.
  3. Critical Evaluation and Validation Strategy: Always critically evaluate the information. Have a strategy for validation that could involve cross-referencing with reliable sources or consulting experts. If something seems too complex or too good to be true, it likely needs further verification.
  4. Test Against Reliable Sources: When unsure, test the information against trusted platforms like search engines or Wikipedia. For generated code, always run and test it to ensure it performs as expected.
  5. Human Review: In high-stakes areas like legal filings, human review is increasingly necessary. Some jurisdictions even require it to ensure the reliability of AI-generated content.

Risk-Adjusted Verification

The steps for verifying information should be proportional to the risks and implications of using it. For critical applications like generated code, extensive testing and expert review are essential. For general knowledge questions, a quick cross-reference with a reliable source may suffice.

By being mindful of the stakes, you can tailor your verification process to take appropriate precautions. This balanced approach allows you to make the most of what Large Language Models offer, while also safeguarding against their limitations and risks.

Practical strategies and use cases of Chatbots like ChatGTP

Language Considerations: for best results, use English

Large Language Models like ChatGPT can understand and generate text in multiple languages. However, for best results, use English. A significant portion of their training data is in English, making their responses in this language more nuanced and accurate. This is especially important for non-English native speakers.

If you need non-English content, a useful strategy for is to first prompt the model in English to get the most accurate response. Once you have that, you can then ask ChatGPT to translate the answer into your desired language. This two-step process often yields more reliable results than directly prompting in a non-English language.

Putting Context i context.

When you’re chatting with ChatGPT, the context includes all the previous conversation you’ve had—both your prompts and the chatbot’s responses. Context is the information that helps the model understand what you’re asking. In Large Language Models like ChatGPT, this context is not just limited to your current query. It also encompasses the entire conversation history, the specific way you phrase your questions, and even the model’s own previous responses. Because the model pays attention to this broader context along with your current prompt and its own training data, it can provide more nuanced and accurate answers. This means that the model not only understands your immediate question but also considers the broader conversation to generate a more context-aware response.

Example 1: Recipe and Shopping List

In this example, ChatGPT uses its own generated recipe as context for creating a relevant shopping list. This shows how the model’s previous output informs its next action, making the interaction more fluid and personalized.

Example 2: Educational Assessment

In this example, you’ve set up a context for ChatGPT to evaluate student responses against a given correct solution. The model will use this context to provide targeted feedback, helping students understand where they might have gone wrong without giving away the correct answer. This is a practical application of how understanding context can lead to more effective educational interactions.

In this extended example, ChatGPT uses the context provided—the correct solution to the equation x+4=7_x_+4=7—to evaluate the students’ responses. It then provides targeted feedback based on how each student’s answer compares to the correct solution. This demonstrates the model’s ability to use context for more nuanced and helpful interactions.

Missing the context is missing the point

Understanding context in your chats with Large Language Models like ChatGPT is crucial. It makes your exchanges more accurate and nuanced. Context helps the model understand the topic, tone, and your specific needs better. This is key for avoiding errors, especially in professional or educational settings. It also allows for more complex interactions, like detailed discussions or using the model for teaching, as shown in our examples.

Source: Fishkin, Rand. “We Analyzed Millions of ChatGPT User Sessions: Visits are Down 29% since May, Programming Assistance is 30% of Use.” SparkToro. Accessed September 3, 2023.

Interestingly, research shows (see figure) that almost half of ChatGPT sessions consist of just one (34.5%) or two (14.5%) prompts. This suggests that a large number of users are not fully utilizing the context-aware capabilities of these models. Only about 35% of sessions have five or more prompts. By not engaging in longer conversations, users miss out on the benefits of context, such as more accurate and nuanced responses, especially in complex queries or discussions.

When interacting with ChatGPT, the way you format your text isn’t just a matter of aesthetics or readability; it also impacts semantics, the meaning behind your words. Proper text formatting acts as a guide for the model, helping it better understand the structure and intent of your query. This, in turn, allows the model to generate responses that are more precise, organized, and tailored to what you’re actually asking for.

Text Formatting: a neat trick in LLM Conversations

When interacting with ChatGPT, the way you format your text isn’t just a matter of aesthetics or readability; it also impacts semantics, the meaning behind words. Proper text formatting acts as a guide for the model, helping it better understand the structure and intent of your query. This, in turn, allows the model to generate responses that are more precise, organized, and tailored to what you’re actually asking for.

Example 3: Using Bullet Points for Multiple Questions

    "Tell me about the benefits of:
    - Solar energy
    - Wind energy"
    - Solar energy is renewable, reduces electricity bills, and has low operating costs.
    - Wind energy is also renewable, cost-effective, and can be built on existing farms."

In this example, the use of bullet points in the prompt helps to clearly separate multiple questions, making it easier for ChatGPT to address each one individually.

Use text formats like a ninja

Beyond the basics of bullet points and numbered lists, you can take advantage of more specialized text formats commonly used in computing to enhance your interactions with ChatGPT. Formats like CSV (Comma-Separated Values), JSON (JavaScript Object Notation), and XML (eXtensible Markup Language) can be employed in your prompts. These formats are particularly useful when you’re dealing with data-heavy queries or need the model to generate responses that can be easily integrated into other software or databases.

For instance, if you have data in an Excel file that you’d like to analyze, you can export it as a CSV and then use that CSV-formatted data in your prompt to ChatGPT. This makes it easier for the model to understand your query and improves the accuracy of its responses. You can even ask ChatGTP : “How do I export data in EXCEL to a CSV File”.

Example 4:

Your prompt:

"Sort the following table by Age in ascending order. The table is in CSV format:

Name,Age,Occupation Alice,34,Engineer Bob,29,Doctor Charlie,45,Teacher David,39,Lawyer Ella,28,Artist

ChatGPT’s response:


Name,Age,Occupation Ella,28,Artist Bob,29,Doctor Alice,34,Engineer David,39,Lawyer Charlie,45,Teacher


A note about Markdown

ChatGPT understands Markdown text formatting, which allows it to display code snippets, tables, headers, links, and even embedded images in its output. However, if you’re using a Markdown-enabled editor for your documents—like Obsidian or Notion—you should be cautious with certain Markdown codes that could disrupt your presentation:

Triple backticks ("`"): These are used for code blocks in Markdown. If you’re not careful, they can mess up the formatting in your Markdown editor. Triple dashes ("-"): These are often used for horizontal lines, which could unintentionally divide your text. Hash symbols ("#", “##”, “###”): These are used for headers. Make sure you use them intentionally to structure your document. Asterisks ("*"): These are used for bullet points. Make sure they are aligned properly to maintain the list structure. Tables: Markdown tables can be useful but also tricky. Ensure the columns align correctly for readability.

Using Markdown in ChatGPT output

Lets go back to the last example, we can ask chatgpt to output the results in a markdown table:

Your prompt:

Sort the following table by Age in ascending order. Format the result **in Markdown**. The table is in CSV format:


ChatGPT’s response:

Name Age Occupation
Ella 28 Artist
Bob 29 Doctor
Alice 34 Engineer
David 39 Lawyer
Charlie 45 Teacher

This way, you get the sorted data in a Markdown table, which you can directly include in your Markdown documents. On the chatGPT page you will see the table above, but if you copy and paste it to a plain text editor you will get something like:


Which is a Markdown representation of a table.

Other uses of text formats and chatbots.

Example: Getting ChatGPT to Work with Graphs

Your prompt:

“Is there any text-based language that can be used to represent graphs?”

ChatGPT Response:

“Yes, there are several text-based languages and formats that can be used to represent graphs. These languages are often used in conjunction with graph visualization or analysis software. Here are some of them:


dotCopy code digraph G { A -> B; B -> C; C -> A; }

(… response continues with several formats : YAML, GML, JSON GRAPH… )

Your Follow-Up Response:

“Generate a .dot file representing a sample graph with the 10 most populated cities in Europe, their high-speed train connections, and the number of kilometers for each direct connection.”

ChatGPT Response:

“Here is a sample .dot file representing a graph of the 10 most populated cities in Europe, along with their high-speed train connections and the distances between them.”

digraph EuropeCities { "London" -> "Paris" [label="450 km"]; "Paris" -> "Madrid" [label="1,050 km"]; "Madrid" -> "Rome" [label="1,400 km"]; "Rome" -> "Berlin" [label="1,100 km"]; "Berlin" -> "Moscow" [label="1,800 km"]; "Moscow" -> "Saint Petersburg" [label="700 km"]; "Saint Petersburg" -> "Kiev" [label="1,100 km"]; "Kiev" -> "Istanbul" [label="1,300 km"]; "Istanbul" -> "Bucharest" [label="600 km"]; "Bucharest" -> "Berlin" [label="1,400 km"]; "London" -> "Berlin" [label="1,100 km"]; "Paris" -> "Berlin" [label="1,050 km"]; "Paris" -> "Rome" [label="1,100 km"]; "Madrid" -> "Berlin" [label="1,900 km"]; "Berlin" -> "Kiev" [label="1,300 km"]; "Moscow" -> "Kiev" [label="870 km"]; "Kiev" -> "Bucharest" [label="800 km"]; "Istanbul" -> "Moscow" [label="2,200 km"]; "Rome" -> "Madrid" [label="1,400 km"]; "Rome" -> "Paris" [label="1,100 km"]; }

Now you can do things like asking ChatGPT to find the optimal path from Madrid to Saint Petersburg and highlight such path on the .dot code. I got GPT-4 to create the code for this graph in two extra prompts. Interestingly GPT-4 used the Dijstra algorithm to solve the problem. I will give you the resulting image and leave it as a challenge.

If you need to know how to generate the image from the .dot code… just ask ChatGPT.

Last prompts

According to research, more than 23% of the use of ChatGPT is related to education. Both teachers and students are using ChatGPT, and the new advanced AI chatbots that are coming online (such as Google’s Bard, Open Assistant, Meta’s Llama 2, etc.) are finding good use cases to assist them in their daily tasks of teaching and learning. A good understanding of these tools, their capabilities, and limitations is crucial for responsible and ethical use, especially in educational settings

In addition to everything covered so far in this article, there are a few final points worth considering:

Thank you for reading to the end.