Skip to content

Commit

Permalink
Bagatur/update replicate nb (langchain-ai#10605)
Browse files Browse the repository at this point in the history
  • Loading branch information
baskaryan authored Sep 14, 2023
1 parent bc6b933 commit 48a4efc
Showing 1 changed file with 46 additions and 52 deletions.
98 changes: 46 additions & 52 deletions docs/extras/integrations/llms/replicate.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"cell_type": "code",
"execution_count": 7,
"metadata": {
"scrolled": true,
"tags": []
},
"outputs": [
Expand Down Expand Up @@ -96,7 +97,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 18,
"metadata": {
"tags": []
},
Expand All @@ -119,24 +120,24 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 19,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'1. Dogs do not have the ability to operate a vehicle.\\n2. Dogs do not have hands or fingers to manipulate the steering wheel and pedals.\\n3. Dogs do not have the cognitive ability to understand traffic laws and road signs.\\n4. Dogs do not have the physical strength to operate the pedals and steering wheel.\\n\\nTherefore, the answer is no, a dog cannot drive a car.\\n\\nThe reasoning steps are:\\n\\n1. Dogs do not have the ability to operate a vehicle.\\n2. Dogs do not have hands or fingers to manipulate the steering wheel and pedals.\\n3. Dogs do not have the cognitive ability to understand traffic laws and road signs.\\n4. Dogs do not have the physical strength to operate the pedals and steering wheel.\\n\\nThe answer is no, a dog cannot drive a car.'"
"'1. Dogs do not have the ability to operate complex machinery like cars.\\n2. Dogs do not have human-like intelligence or cognitive abilities to understand the concept of driving.\\n3. Dogs do not have the physical ability to use their paws to press pedals or turn a steering wheel.\\n4. Therefore, a dog cannot drive a car.'"
]
},
"execution_count": 3,
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"llm = Replicate(\n",
" model=\"a16z-infra/llama13b-v2-chat:df7690f1994d94e96ad9d568eac121aecf50684a0b0963b25a41cc40061269e5\",\n",
" input={\"temperature\": 0.75, \"max_length\": 500, \"top_p\": 1},\n",
" model_kwargs={\"temperature\": 0.75, \"max_length\": 500, \"top_p\": 1},\n",
")\n",
"prompt = \"\"\"\n",
"User: Answer the following yes/no question by reasoning step by step. Can a dog drive a car?\n",
Expand Down Expand Up @@ -164,7 +165,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 20,
"metadata": {
"tags": []
},
Expand All @@ -177,16 +178,16 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 21,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'Yes, dogs can drive cars as long as they are trained to do so and under proper supervision. When driving a vehicle, dogs need sufficient rest periods and breaks to ensure their safety and well-being. The dog has to be able to see clearly out of the driver’s window, have access to water and food while driving and also be restrained in some way during these times. If necessary, two dogs can safely ride together in one car where neither dog drives (the passenger rides with someone who is qualified to supervise them). When it comes time for them to get home after a day of driving, most dogs want nothing more than to get back into their bed\\n\\n'"
"'No, dogs lack some of the brain functions required to operate a motor vehicle. They cannot focus and react in time to accelerate or brake correctly. Additionally, they do not have enough muscle control to properly operate a steering wheel.\\n\\n'"
]
},
"execution_count": 5,
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -208,28 +209,28 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 22,
"metadata": {},
"outputs": [],
"source": [
"text2image = Replicate(\n",
" model=\"stability-ai/stable-diffusion:db21e45d3f7023abc2a46ee38a23973f6dce16bb082a930b0c49861f96d1e5bf\",\n",
" input={\"image_dimensions\": \"512x512\"},\n",
" model_kwargs={\"image_dimensions\": \"512x512\"},\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 23,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'https://pbxt.replicate.delivery/KhTfVxYI9nyf7UExThmESBaW7dYr2IqrFDg5rGEoULTdSSkRA/out-0.png'"
"'https://pbxt.replicate.delivery/bqQq4KtzwrrYL9Bub9e7NvMTDeEMm5E9VZueTXkLE7kWumIjA/out-0.png'"
]
},
"execution_count": 7,
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -248,17 +249,17 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 24,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Collecting Pillow\n",
" Using cached Pillow-10.0.0-cp39-cp39-manylinux_2_28_x86_64.whl (3.4 MB)\n",
"Installing collected packages: Pillow\n",
"Successfully installed Pillow-10.0.0\n"
"Requirement already satisfied: Pillow in /Users/bagatur/langchain/.venv/lib/python3.9/site-packages (9.5.0)\n",
"\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m23.2\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m23.2.1\u001b[0m\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n"
]
}
],
Expand Down Expand Up @@ -292,18 +293,14 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 26,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1. Dogs do not have the ability to operate complex machinery like cars.\n",
"2. Dogs do not have hands or fingers to grasp and manipulate objects like steering wheels and pedals.\n",
"3. Dogs do not have the cognitive ability to understand traffic laws and road signs.\n",
"\n",
"Therefore, the answer is no, a dog cannot drive a car."
"1. Dogs do not have the physical ability to operate a vehicle."
]
}
],
Expand All @@ -314,7 +311,7 @@
" streaming=True,\n",
" callbacks=[StreamingStdOutCallbackHandler()],\n",
" model=\"a16z-infra/llama13b-v2-chat:df7690f1994d94e96ad9d568eac121aecf50684a0b0963b25a41cc40061269e5\",\n",
" input={\"temperature\": 0.75, \"max_length\": 500, \"top_p\": 1},\n",
" model_kwargs={\"temperature\": 0.75, \"max_length\": 500, \"top_p\": 1},\n",
")\n",
"prompt = \"\"\"\n",
"User: Answer the following yes/no question by reasoning step by step. Can a dog drive a car?\n",
Expand All @@ -333,7 +330,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 27,
"metadata": {},
"outputs": [
{
Expand All @@ -343,23 +340,20 @@
"Raw output:\n",
" There are several ways to learn Python, and the best method for you will depend on your learning style and goals. Here are a few suggestions:\n",
"\n",
"1. Online tutorials and courses: Websites such as Codecademy, Coursera, and edX offer interactive coding lessons and courses on Python. These can be a great way to get started, especially if you prefer a self-paced approach.\n",
"2. Books: There are many excellent books on Python that can provide a comprehensive introduction to the language. Some popular options include \"Python Crash Course\" by Eric Matthes, \"Learning Python\" by Mark Lutz, and \"Automate the Boring Stuff with Python\" by Al Sweigart.\n",
"3. Online communities: Participating in online communities such as Reddit's r/learnpython community or Python communities on Discord can be a great way to get support and feedback as you learn.\n",
"4. Practice: The best way to learn Python is by doing. Start by writing simple programs and gradually work your way up to more complex projects.\n",
"5. Find a mentor: Having a mentor who is experienced in Python can be a great way to get guidance and feedback as you learn.\n",
"6. Join online meetups and events: Joining online meetups and events can be a great way to connect with other Python learners and get a sense of the community.\n",
"7. Use a Python IDE: An Integrated Development Environment (IDE) is a software application that provides an interface for writing, debugging, and testing code. Using a Python IDE such as PyCharm, VSCode, or Spyder can make writing and debugging Python code much easier.\n",
"8. Learn by building: One of the best ways to learn Python is by building projects. Start with small projects and gradually work your way up to more complex ones.\n",
"9. Learn from others: Look at other people's code, understand how it works and try to implement it in your own way.\n",
"10. Learn the basics of programming: Before diving into Python, it's important to understand the basics of programming. Learn the basic concepts such as data types, variables, loops, conditional statements, functions, etc.\n",
"1. Online tutorials and courses: Websites such as Codecademy, Coursera, and edX offer interactive coding lessons and courses that can help you get started with Python. These courses are often designed for beginners and cover the basics of Python programming.\n",
"2. Books: There are many books available that can teach you Python, ranging from introductory texts to more advanced manuals. Some popular options include \"Python Crash Course\" by Eric Matthes, \"Automate the Boring Stuff with Python\" by Al Sweigart, and \"Python for Data Analysis\" by Wes McKinney.\n",
"3. Videos: YouTube and other video platforms have a wealth of tutorials and lectures on Python programming. Many of these videos are created by experienced programmers and can provide detailed explanations and examples of Python concepts.\n",
"4. Practice: One of the best ways to learn Python is to practice writing code. Start with simple programs and gradually work your way up to more complex projects. As you gain experience, you'll become more comfortable with the language and develop a better understanding of its capabilities.\n",
"5. Join a community: There are many online communities and forums dedicated to Python programming, such as Reddit's r/learnpython community. These communities can provide support, resources, and feedback as you learn.\n",
"6. Take online courses: Many universities and organizations offer online courses on Python programming. These courses can provide a structured learning experience and often include exercises and assignments to help you practice your skills.\n",
"7. Use a Python IDE: An Integrated Development Environment (IDE) is a software application that provides an interface for writing, debugging, and testing code. Popular Python IDEs include PyCharm, Visual Studio Code, and Spyder. These tools can help you write more efficient code and provide features such as code completion, debugging, and project management.\n",
"\n",
"\n",
"Please let me know\n",
"Raw output runtime: 26.067544750000003 seconds\n",
"Which of the above options do you think is the best way to learn Python?\n",
"Raw output runtime: 25.27470933299992 seconds\n",
"Stopped output:\n",
" There are several ways to learn Python, and the best method for you will depend on your learning style and goals. Here are a few suggestions:\n",
"Stopped output runtime: 25.669324958000004 seconds\n"
" There are several ways to learn Python, and the best method for you will depend on your learning style and goals. Here are some suggestions:\n",
"Stopped output runtime: 25.77039254200008 seconds\n"
]
}
],
Expand All @@ -368,7 +362,7 @@
"\n",
"llm = Replicate(\n",
" model=\"a16z-infra/llama13b-v2-chat:df7690f1994d94e96ad9d568eac121aecf50684a0b0963b25a41cc40061269e5\",\n",
" input={\"temperature\": 0.01, \"max_length\": 500, \"top_p\": 1},\n",
" model_kwargs={\"temperature\": 0.01, \"max_length\": 500, \"top_p\": 1},\n",
")\n",
"\n",
"prompt = \"\"\"\n",
Expand Down Expand Up @@ -398,7 +392,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 28,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -414,7 +408,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 29,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -435,7 +429,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 30,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -456,7 +450,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 31,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -476,7 +470,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 32,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -496,7 +490,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 33,
"metadata": {},
"outputs": [
{
Expand All @@ -506,16 +500,16 @@
"\n",
"\n",
"\u001b[1m> Entering new SimpleSequentialChain chain...\u001b[0m\n",
"\u001b[36;1m\u001b[1;3mColorful socks could be named \"Dazzle Socks\" or \"Barefoot Innovation.\"\n",
"\u001b[36;1m\u001b[1;3mColorful socks could be named after a song by The Beatles or a color (yellow, blue, pink). A good combination of letters and digits would be 6399. Apple also owns the domain 6399.com so this could be reserved for the Company.\n",
"\n",
"\u001b[0m\n",
"\u001b[33;1m\u001b[1;3mA colorful pair of socks could represent Dazzle Socks, a fun and innovative company! The color blue might symbolize skyrockets, while yellow might suggest sunshine. Red could refer to blood in the water, inspiring aggression and action. Orange might stand for golden opportunities in the sand - maybe even leading us to our breakthroughs. Green could connote nature and money, signifying wealth and sustainability. Finally, white suggests purity and cleanliness, keeping us on track without being overly restrictive. Together, these colors create a unique and lively palette from which to design a logo.\n",
"\u001b[33;1m\u001b[1;3mA colorful sock with the numbers 3, 9, and 99 screen printed in yellow, blue, and pink, respectively.\n",
"\n",
"\u001b[0m\n",
"\u001b[38;5;200m\u001b[1;3mhttps://pbxt.replicate.delivery/WebsLVtue2rl9kXNJY6rxdfZqDcVq28bmjkcYuXKqSicnkIjA/out-0.png\u001b[0m\n",
"\u001b[38;5;200m\u001b[1;3mhttps://pbxt.replicate.delivery/P8Oy3pZ7DyaAC1nbJTxNw95D1A3gCPfi2arqlPGlfG9WYTkRA/out-0.png\u001b[0m\n",
"\n",
"\u001b[1m> Finished chain.\u001b[0m\n",
"https://pbxt.replicate.delivery/WebsLVtue2rl9kXNJY6rxdfZqDcVq28bmjkcYuXKqSicnkIjA/out-0.png\n"
"https://pbxt.replicate.delivery/P8Oy3pZ7DyaAC1nbJTxNw95D1A3gCPfi2arqlPGlfG9WYTkRA/out-0.png\n"
]
}
],
Expand Down

0 comments on commit 48a4efc

Please sign in to comment.