"\" blue\\n\\nThe sky is blue during the day as a result of the way the Earth's atmosphere scatters sunlight. The blue color of the sky is due to Rayleigh scattering, which is the scattering of light by molecules in the air. When sunlight passes through the atmosphere, shorter wavelength colors like blue are scattered more widely than longer wavelength colors like red, making the sky appear blue.\""
]
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"response.choices[0].text"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [
{
"data": {
"text/markdown": [
" blue\n",
"\n",
"The sky is blue during the day as a result of the way the Earth's atmosphere scatters sunlight. The blue color of the sky is due to Rayleigh scattering, which is the scattering of light by molecules in the air. When sunlight passes through the atmosphere, shorter wavelength colors like blue are scattered more widely than longer wavelength colors like red, making the sky appear blue."
"Try with different temperature to compare results:"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [
{
"data": {
"text/markdown": [
" blue\n",
"\n",
"The sky is blue because of the way the atmosphere scatters sunlight. When sunlight passes through the atmosphere, the blue wavelengths are scattered more than the other colors, making the sky appear blue."
"Antibiotics are medications used to treat bacterial infections by killing or inhibiting the growth of bacteria, but they are not effective against viral infections and should be used appropriately to avoid antibiotic resistance."
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"execution_count": 34,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"params = set_open_params(temperature=0.7)\n",
"prompt = \"\"\"Antibiotics are a type of medication used to treat bacterial infections. They work by either killing the bacteria or preventing them from reproducing, allowing the body's immune system to fight off the infection. Antibiotics are usually taken orally in the form of pills, capsules, or liquid solutions, or sometimes administered intravenously. They are not effective against viral infections, and using them inappropriately can lead to antibiotic resistance. \n",
"Exercise: Instruct the model to explain the paragraph in one sentence like \"I am 5\". Do you see any differences?"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"### 1.2 Question Answering"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"outputs": [
{
"data": {
"text/markdown": [
" Mice."
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"execution_count": 35,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"prompt = \"\"\"Answer the question based on the context below. Keep the answer short and concise. Respond \"Unsure about answer\" if not sure about the answer.\n",
"\n",
"Context: Teplizumab traces its roots to a New Jersey drug company called Ortho Pharmaceutical. There, scientists generated an early version of the antibody, dubbed OKT3. Originally sourced from mice, the molecule was able to bind to the surface of T cells and limit their cell-killing potential. In 1986, it was approved to help prevent organ rejection after kidney transplants, making it the first therapeutic antibody allowed for human use.\n",
"\n",
"Question: What was OKT3 originally sourced from?\n",
"Exercise: Modify the prompt to instruct the model to provide an explanation to the answer selected. "
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"### 1.4 Role Playing"
]
},
{
"cell_type": "code",
"execution_count": 37,
"metadata": {},
"outputs": [
{
"data": {
"text/markdown": [
" Sure. A black hole is a region of spacetime where gravity is so strong that nothing, not even light, can escape its pull. Black holes are formed when a massive star runs out of fuel and collapses under its own gravity. The collapse causes the star to become so dense that it creates an event horizon, which is the point of no return."
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"execution_count": 37,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"prompt = \"\"\"The following is a conversation with an AI research assistant. The assistant tone is technical and scientific.\n",
"\n",
"Human: Hello, who are you?\n",
"AI: Greeting! I am an AI research assistant. How can I help you today?\n",
"Human: Can you tell me about the creation of blackholes?\n",
"Exercise: Modify the prompt to instruct the model to keep AI responses concise and short."
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"### 1.5 Code Generation"
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {},
"outputs": [
{
"data": {
"text/markdown": [
"\n",
"SELECT StudentId, StudentName \n",
"FROM students \n",
"WHERE DepartmentId = (SELECT DepartmentId \n",
" FROM departments \n",
" WHERE DepartmentName = 'Computer Science')"
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"execution_count": 38,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"prompt = \"\\\"\\\"\\\"\\nTable departments, columns = [DepartmentId, DepartmentName]\\nTable students, columns = [DepartmentId, StudentId, StudentName]\\nCreate a MySQL query for all students in the Computer Science Department\\n\\\"\\\"\\\"\"\n",