The AI Enthusiast

Directing AI Model with Prompt Engineering

Cover Image for Directing AI Model with Prompt Engineering
Equan P.

Prompt engineering is a process of creating a prompt (question or command) that directs a language model along a specific path, facilitating specific tasks and limiting the scope of the language model's output. The goal is to ensure that the language model understands and answers questions correctly and relevantly.
As an example of using prompt engineering with GPT-3, the process can be broken down as follows:

Task Identification
First, define the task that you want the language model to perform, such as predicting a decision or answering a question.

Prompt Creation
Create a prompt that directs the model to the specified task. For example, a prompt for the task of predicting a decision could be: "Based on this information, what would you do?"

Fine-tuning involves modifying the existing model by providing specific task examples related to the prompt and adjusting the model parameters to better answer those tasks. This can help improve the model's ability to understand and answer specific questions or commands and ensure that the model output aligns with the desired outcome.
In general, fine-tuning is the process of modifying a model to recognize input and output patterns with specific characteristics.

Test the fine-tuned model to ensure that it can accurately and relevantly answer questions based on the defined task.

If necessary, refine the model by adding more training data or adjusting parameters to ensure that the model has good capabilities for answering the defined task.

Food Recipe Chatbot

Let's take an example of prompt engineering for a chatbot, say we want a chatbot that specifically answers and suggests food recipes.
The model we'll use, for instance, is text-davinci-003, a GPT-3 model from OpenAI. Here are the steps that can be taken to create a food recipe chatbot using the GPT-3 model:

Task Identification
Determine the main task of the chatbot, such as:
- Answering questions about food recipes
- Provide recipe suggestions
- and others.

Training Data Preparation
Collect training data on food recipes, such as recipe questions, recipe suggestions, and food ingredient information.
There are many sources of data available on the Internet or in physical documents that can be digitized and used as data to train the model to become a food recipe chatbot.

Prompt Creation
Create a prompt that focuses the model on the specified task, such as: "What food recipe do you want today?", "Give me a recipe suggestion for tonight." or "What is the recipe for Rawon?"
OpenAI provides documentation on data that can be used to train the model. This data is called a Dataset.
The dataset format used to train the model is JSONL.

{"prompt":<text>, "completion": <text_completion>}
{"prompt":<text>, "completion": <text_completion>}

For example, a dataset could be:

{"prompt": "roti panggang\npanaskan oven pada suhu 150 derajat Celsius.",
"completion": " dalam wadah besar, campurkan tepung terigu, gula, dan baking powder. Tambahkan telur, mentega, dan susu. Aduk rata. Tuang adonan ke loyang yang sudah dialasi kertas baking. Panggang selama 25-30 menit atau hingga matang."}

{"prompt": "sapi goreng\nsiapkan bahan-bahan: 200 gram daging sapi, 3 siung bawang putih, 1 sdt garam, 1 sdt merica, 1 sdt gula pasir, 1 sdt kecap manis.",
"completion": "potong-potong daging sapi menjadi potongan kecil-kecil. Tumbuk bawang putih halus. Campurkan bawang putih, garam, merica, gula pasir, dan kecap manis ke dalam wadah. Aduk rata. Masukkan daging sapi, aduk hingga rata. Diamkan selama 15 menit. Panaskan minyak dalam wajan, tumis bumbu dan daging sapi hingga matang. Sajikan dengan nasi hangat."}

The dataset determines the quality of the model, so to create a good dataset, the following things need to be considered:

✅ Data Quality, meaning the data must be clean from irrelevant data.
✅ Data Annotation
. Consider annotating the data to add structure to the text, making it easier for the model to learn the relationships between ingredients, instructions, and recipes. Annotations can include labeling ingredients, steps, and recipe titles.
✅ Data Preprocessing. Pre-process the data by formatting all text to lowercase, removing punctuation, and tokenizing the text into smaller units, such as words or subwords.
OpenAI provides guidelines on preparing datasets to train the GPT-3 model and tools to ensure that the dataset is up to standard.

Fine-tuning the GPT-3 model is the process of training the dataset to the GPT-3 model. Remember that this process is not free because we use computer resources in the cloud.
Fine-tuning the Davinci model is credited at $0.0300 / 1K tokens with 1000 tokens being approximately 750 words. So, for example, with training data of 100,000 words, it would cost around $4.
OpenAI provides rules and tools for fine-tuning the GPT-3 model.

Test the model using test data to ensure that the model can accurately and relevantly answer questions about food recipes.
Testing can be done manually, which means trying queries based on the trained model. OpenAI can be tried in the playground.

If necessary, improve the model by adding more training data or adjusting the model parameters to enhance the model's ability to answer questions about food recipes.

Insight Corner

Cover Image for Auto-GPT, The Future of Autonomous AI Agent

Auto-GPT, The Future of Autonomous AI Agent

The Do-It-All Machine. This is a to-do list that completes itself. Yes, you read that correctly. Some people say that Auto-GPT is one example of AGI, which stands for Artificial General Intelligence, which refers to a type of artificial intelligence that has the ability to understand, learn, and apply knowledge across a wide range of tasks and domains, much like a human. It contrasts with narrow or specialized AI, which is designed to perform specific tasks or solve particular problems. An AGI system would be capable of learning any intellectual task that a human can do, adapting to new situations, and exhibiting a high level of autonomy.

Equan P.
Cover Image for The Next Generation of ChatBot - Visual ChatGPT

The Next Generation of ChatBot - Visual ChatGPT

Could we build a ChatGPT-like system that also supports image understanding and generation? One intuitive idea is to train a multi-modal conversational model. However, building such a system would consume a large amount of data and computational resources. Besides, another challenge comes that what if we want to incorporate modalities beyond languages and images, like videos or voices? Would it be necessary to train a totally new multi-modality model every time when it comes to new modalities or functions?

Equan P.