This short text will introduce a way to install the software used by scientists, log in to a Google account, and, guided by instructions, configure artificial intelligence to think the way you think. The configured artificial intelligence is capable of solving complex tasks by breaking them down into stages. After creating a model based on your way of thinking, the artificial intelligence is tested by asking a question with an already known answer - its effectiveness is checked. Everything you created during this lesson remains yours, which means you can use and improve your AI algorithm. My recommendation for improvement is to select a newer version of the Google artificial intelligence algorithm - currently used is gemini-2.0-flash (may be relevant after some time).
About 30 min.
Computer
Jupiter Notebook software (free)
Gmail account
About 1h 30 min.
Computer
Jupiter Notebook software (free)
Gmail account
In this stage, we will download the software and, after logging into a Google account, generate a secret key so that we can use the artificial intelligence tool for our searches.
1. Visit the website Anaconda (https://www.anaconda.com/) and click on the "Free Download" button there (see image). Now you are on the page where you can start the download. Click "Skip registration" (see image) if you are not interested in updates, offers, and other content from the software developers and start the download.
2. Follow the steps to install the program on your computer, and after successfully installing it, open it to make sure everything is working.
* The software is free because it is supported by the giant Nvidia (graphics card manufacturer).
3. Visit Google AI studio by following this link (https://aistudio.google.com/apikey) and click the button to generate an AI key for you. The entire process of obtaining secret codes is shown in the images. We will need the secret key in the next stage, when running AI on your computer. If Google asks for additional steps, for example, creating a project, create it.
You already have all the necessary software, so now you only need to perform the required actions for artificial intelligence to work as you want and answer complex questions accurately. By creating this configured artificial intelligence module, you will be able to use it to answer any questions, and you will also be able to configure it by adding additional logic so that the artificial intelligence represents you.
1. Open the notebook where your commands will be, name the file so you know you can always find it on your computer. You can do this by saving an empty file; when performing this process, you are asked to choose a file name. After saving, you remain in the same file and can use it without saving until the end of your work.
2. Follow the commands and enter instructions for the computer to run the Google artificial intelligence algorithm.
2.1. Install the necessary libraries. They contain all the commands you can use for artificial intelligence to work.
!pip uninstall -qqy jupyterlab
!pip install "google-genai"
2.2. Actions are performed to connect various parts of the library with the variables used in your program.
from google import genai from google.genai import types from IPython.display import HTML, Markdown, display
2.3. The Google key is entered, which connects your program to Google. If you did not save the key, you can access it again by following the same link and the steps shown in the images. If Google asks for additional actions, such as creating a project, create it.
GOOGLE_API_KEY = "*************************"
2.4. We set the user in the system you created and run a test query that answers the question of what artificial intelligence is. The text in quotes "Explain AI to me like I'm a kid." can be edited, for example, by entering a Lithuanian question "Kas yra dirbtinis intelektas".
* To run a test query: place the cursor on the rectangle (code block) containing the system instructions and click. The square with system instructions is colored differently - it becomes active. Then click the Play button on the top bar, as shown in the figure. The procedure is repeated for each system instruction/s starting from the first block at the top. If a star lights up (see figure), it means your system is performing calculations and you have to wait. If it fails, try again. If you are already working with the system, you do not need to rerun the first three elements with code, as they are for entering the initial parameters for your system to work, and subsequent code elements are for performing the settings given to the artificial intelligence.
client = genai.Client(api_key=GOOGLE_API_KEY) response = client.models.generate_content( model="gemini-2.0-flash", contents="Explain AI to me like I'm a kid.") print(response.text)
* You should have a similar configuration to the image below.
2.5. We enter the text that is used to train the artificial intelligence to work by breaking down questions into parts and looking for partial answers, which are then used to generate the final answer.
model_instructions = """ Solve a question answering task with interleaving Thought, Action, Observation steps. Thought can reason about the current situation, Observation is understanding relevant information from an Action's output and Action can be one of three types: (1) , which searches the exact entity on Wikipedia and returns the first paragraph if it exists. If not, it will return some similar entities to search and you can try to search the information from those topics. (2) , which returns the next sentence containing keyword in the current context. This only does exact matches, so keep your searches short. (3) , which returns the answer and finishes the task. """ example1 = """Question Musician and satirist Allie Goertz wrote a song about the "The Simpsons" character Milhouse, who Matt Groening named after who? Thought 1 The question simplifies to "The Simpsons" character Milhouse is named after who. I only need to search Milhouse and find who it is named after. Action 1 Observation 1 Milhouse Mussolini Van Houten is a recurring character in the Fox animated television series The Simpsons voiced by Pamela Hayden and created by Matt Groening. Thought 2 The paragraph does not tell who Milhouse is named after, maybe I can look up "named after". Action 2 Observation 2 Milhouse was named after U.S. president Richard Nixon, whose middle name was Milhous. Thought 3 Milhouse was named after U.S. president Richard Nixon, so the answer is Richard Nixon. Action 3 """ example2 = """Question What is the elevation range for the area that the eastern sector of the Colorado orogeny extends into? Thought 1 I need to search Colorado orogeny, find the area that the eastern sector of the Colorado orogeny extends into, then find the elevation range of the area. Action 1 Observation 1 The Colorado orogeny was an episode of mountain building (an orogeny) in Colorado and surrounding areas. Thought 2 It does not mention the eastern sector. So I need to look up eastern sector. Action 2 Observation 2 The eastern sector extends into the High Plains and is called the Central Plains orogeny. Thought 3 The eastern sector of Colorado orogeny extends into the High Plains. So I need to search High Plains and find its elevation range. Action 3 Observation 3 High Plains refers to one of two distinct land regions Thought 4 I need to instead search High Plains (United States). Action 4 Observation 4 The High Plains are a subregion of the Great Plains. From east to west, the High Plains rise in elevation from around 1,800 to 7,000 ft (550 to 2,130m). Thought 5 High Plains rise in elevation from around 1,800 to 7,000 ft, so the answer is 1,800 to 7,000 ft. Action 5 """
2.6. A process fragment is entered that generates the response. After running the system, you will get the result of the test question - answer.
question = """Question Who was the youngest author listed on the transformers NLP paper? """ react_config = types.GenerateContentConfig( stop_sequences=["\nObservation"], system_instruction=model_instructions + example1 + example2, ) react_chat = client.chats.create( model='gemini-2.0-flash', config=react_config, ) resp = react_chat.send_message(question) print(resp.text)
3. After performing all the steps, you should get an answer generated by artificial intelligence, similar to the illustration (see illustration). If it doesn't work, check if there are any extra spaces created in your version and if each line of code starts at the beginning of the margin, as in the example. Up to now, you have a fully functioning artificial intelligence algorithm working according to the ReAct configuration. The question "Who was the youngest author listed on the transformers NLP paper?" was asked, and the answer "Aidan N. Gomez" was received.
The artificial intelligence is fully configured to work, but we will perform one additional action to make it easy to enter the desired question to be answered the next time you log in. In summary, when connecting for the second time, you will need two parameters - a new Google key, which you can get by following the previous steps (the Google key is valid for a limited time for security reasons) and the question you want to ask the artificial intelligence.
1. Enter the parameter so that next time you can assign a value to this parameter and by clicking run, the artificial intelligence you created returns an answer.
question = "kiek dabar valandų?"
start = '"""Question' end = '"""' question_code = start + question + end react_config = types.GenerateContentConfig( system_instruction=model_instructions + example1 + example2, ) react_chat = client.chats.create( model='gemini-2.0-flash', config=react_config, ) resp = react_chat.send_message(question_code) print(resp.text)
The artificial intelligence is already working, but we want it to think similarly to us. In this step, we will train the artificial intelligence to work in our way and check if the obtained answer to a template question is as accurate as in the previous example. The answer should be the same as in the Google example I presented in the third stage. The artificial intelligence is already working, but we want it to think similarly to us. In this step, we will train the artificial intelligence to work in our way and check if the obtained answer to a template question is as accurate as in the previous example. The answer should be the same as in the Google example I presented in the third stage.
1. Corrections are made to the text block you used to train the artificial intelligence. This block will be edited now and after fully generating the question-answer chain. Now, a correction is made to the first parameter "model_instructions" - it is replaced with the updated parameter, so we copy the entire text related to this parameter and replace it with the updated text:
model_instructions = """ Solve a question answering task with interleaving Thought, Action, Observation steps. Thought can reason about the current situation, Observation is understanding relevant information from an Action's output and Action can be one of three types: (1) , which searches the exact entity on web, databases and all possible sources then returns content if it exists. If not, it will return some similar entities to search and you can try to search the information from those topics. (2) , which returns the next sentence containing keyword in the current context. This only does exact matches, so keep your searches short. (3) , which returns the answer and finishes the task. """
2. The command that launches the artificial intelligence is changed, a new setting is introduced that changes the algorithm's operation and stops it after the first question. This does not create a full chain, but only a part of it.
question = "How to connect with more potential clients?"
start = '"""Question' end = '"""' question_code = start + question + end react_config = types.GenerateContentConfig( stop_sequences=["\nObservation"], system_instruction=model_instructions + example1 + example2, ) react_chat = client.chats.create( model='gemini-2.0-flash', config=react_config, ) resp = react_chat.send_message(question_code) print(resp.text)
* The obtained answer (see figure) is the first part of the chain. Evaluating this artificial intelligence solution to seek the answer by taking the most direct path, I decided to improve the chain formation and start solving the problem in a more abstract way. Since my plan is to look at this question more abstractly, I will rewrite and create a draft that has a different chain formation than recommended by artificial intelligence. Therefore, I first write Thought 1 in the draft and summarize it into Action 1. In the final result, the first part of my chain looks like in the image. Having the first search text (prompt), I perform a standard search in Gemini set to their latest algorithm and write down the result as Observation. See figure.
3. The obtained answer is added to Observation. Then, a thought is formed that will be added as the beginning of the second chain. I select the relevant information from the previously generated Observation and write down the question that leads to the answer to the main question. My obtained answer, especially the last line, answers the question of what people believe in the most, so I copy this text and add the next question that came to my mind. The final text I write next to Thought looks like in the image.
4. To continue forming the chain, I need to formulate a clear search term, one that summarizes the previously written Thought. I write a generalized statement in the draft next to Action, mark this statement with a special tag lookup before and after the statement so that the algorithm understands this search as ongoing and links it to the previously generated answers. Then, using this statement, I perform a search in Gemini AI to get the Observation. Special tagging is not required in a regular search.
5. A new question is entered, which is partially related to the previously obtained Observation value. A chain is created by repeating the action and approaching the answer. When Observation returns a value close to the answer, we write this value into the previously generated Action with the tag. In my case, the chain has seven threads (attached file).
Download file "Jesus' sales strategy"6. The created chain is entered as an example based on which the artificial intelligence will generate an analysis-based answer to the question for you. We leave the first example and change the second example. Later, the first example can also be changed, which we currently leave; however, after performing this correction, it is necessary to check if the created artificial intelligence returns the correct answer to the initial question. After inserting your example, on the basis of which the artificial intelligence will generate answers to questions, it is necessary to align it correctly, leaving spaces between Thought, Action, and Observation as in the example.
* The algorithm code should be the same as in stage 3, without the additional parameter that returns only the first part of the chain.
7. Perform the test by asking the question used before (Who was the youngest author listed on the transformers NLP paper?) and expect the answer to be the same as in the second stage (Aidan N. Gomez) - the same as provided in the Google ReAct algorithm method example. In my case, the answer is the same, and during the solution, more accurate information about the authors was found, and sources were provided.
To further improve the artificial intelligence and adapt it to a specific type of thinking, continue working and add more examples you generated.
You can find the original text by following this link: gemini