From ee07db43c5ec262d50df7d62f9a29c9248e179c1 Mon Sep 17 00:00:00 2001 From: Simon Dufty Date: Mon, 30 Sep 2024 19:03:32 +1000 Subject: [PATCH] enhanced structure and comments for week 1 and added a Spanish version --- week1/SD code.txt | 163 ---------------- week1/day5-Enhanced.ipynb | 68 ++++--- week2/day1.ipynb | 291 ++++++++++++++++++++++++---- week2/day2.ipynb | 394 ++++++++++++++++++++++++++++++++++---- 4 files changed, 656 insertions(+), 260 deletions(-) delete mode 100644 week1/SD code.txt diff --git a/week1/SD code.txt b/week1/SD code.txt deleted file mode 100644 index 06741dd..0000000 --- a/week1/SD code.txt +++ /dev/null @@ -1,163 +0,0 @@ -# imports - -import os -import requests -import json -from typing import List -from dotenv import load_dotenv -from bs4 import BeautifulSoup -from IPython.display import Markdown, display, update_display -from openai import OpenAI - - -# Initialize and constants - -load_dotenv() -os.environ['OPENAI_API_KEY'] = os.getenv('OPENAI_API_KEY', 'your-key-if-not-using-env') -MODEL = 'gpt-4o-mini' -openai = OpenAI() - - -# A class to represent a Webpage - -class Website: - url: str - title: str - body: str - links: List[str] - - def __init__(self, url): - self.url = url - response = requests.get(url) - self.body = response.content - soup = BeautifulSoup(self.body, 'html.parser') - self.title = soup.title.string if soup.title else "No title found" - if soup.body: - for irrelevant in soup.body(["script", "style", "img", "input"]): - irrelevant.decompose() - self.text = soup.body.get_text(separator="\n", strip=True) - else: - self.text = "" - links = [link.get('href') for link in soup.find_all('a')] - self.links = [link for link in links if link] - - def get_contents(self): - return f"Webpage Title:\n{self.title}\nWebpage Contents:\n{self.text}\n\n" - -link_system_prompt = """ -You are provided with a list of links found on a webpage. Your task is to first categorize each link into one of the following categories: -- about page -- careers page -- terms of service -- privacy policy -- contact page -- other (please specify). - -Once the links are categorized, please choose which links are most relevant to include in a brochure about the company. -The brochure should only include links such as About pages, Careers pages, or Company Overview pages. Exclude any links related to Terms of Service, Privacy Policy, or email addresses. - -Respond in the following JSON format: -{ - "categorized_links": [ - {"category": "about page", "url": "https://full.url/about"}, - {"category": "careers page", "url": "https://full.url/careers"}, - {"category": "terms of service", "url": "https://full.url/terms"}, - {"category": "privacy policy", "url": "https://full.url/privacy"}, - {"category": "other", "specify": "contact page", "url": "https://full.url/contact"} - ], - "brochure_links": [ - {"type": "about page", "url": "https://full.url/about"}, - {"type": "careers page", "url": "https://full.url/careers"} - ] -} - -Please find the links below and proceed with the task: - -Links (some may be relative links): -[INSERT LINK LIST HERE] -""" - -def get_links_user_prompt(website): - user_prompt = f"Here is the list of links on the website of {website.url} - " - user_prompt += "please decide which of these are relevant web links for a brochure about the company, respond with the full https URL in JSON format. \ -Do not include Terms of Service, Privacy, email links.\n" - user_prompt += "Links (some might be relative links):\n" - user_prompt += "\n".join(website.links) - return user_prompt - -def get_links(url): - website = Website(url) - completion = openai.chat.completions.create( - model=MODEL, - messages=[ - {"role": "system", "content": link_system_prompt}, - {"role": "user", "content": get_links_user_prompt(website)} - ], - response_format={"type": "json_object"} - ) - result = completion.choices[0].message.content - return json.loads(result) - - -from urllib.parse import urljoin - -def get_all_details(url): - result = "Landing page:\n" - result += Website(url).get_contents() # Get the landing page content - - links = get_links(url) # Retrieve the links JSON - - brochure_links = links.get('brochure_links', []) # Get the brochure links list (which is already a list) - print("Found Brochure links:", brochure_links) # Debug output to show the brochure links - - # Iterate over each brochure link - for link in brochure_links: - result += f"\n\n{link['type']}:\n" # Add the type of link (about page, careers page, etc.) - - # Handle relative URLs by converting them to absolute URLs - full_url = urljoin(url, link["url"]) - - # Fetch and append the content of the brochure link URL - result += Website(full_url).get_contents() - - return result - - -system_prompt = "You are an assistant that analyzes the contents of several relevant pages from a company website \ -and creates a brochure about the company for prospective customers, investors and recruits. Respond in markdown.\ -Include details of company culture, customers and careers/jobs if you have the information.\ -Structure the brochure to include specific sections as follows:\ -About Us\ -What we do\ -How We Do It\ -Where We Do It\ -Our People\ -Our Culture\ -Connect with Us.\ -Please provide two versions of the brochure, the first in English, the second in Spanish. The contents of the brochure are to be the same for both languages." - -def get_brochure_user_prompt(company_name, url): - user_prompt = f"You are looking at a company called: {company_name}\n" - user_prompt += f"Here are the contents of its landing page and other relevant pages; use this information to build a short brochure of the company in markdown.\n" - user_prompt += get_all_details(url) - user_prompt = user_prompt[:20_000] # Truncate if more than 20,000 characters - return user_prompt - -def stream_brochure(company_name, url): - stream = openai.chat.completions.create( - model=MODEL, - messages=[ - {"role": "system", "content": system_prompt}, - {"role": "user", "content": get_brochure_user_prompt(company_name, url)} - ], - stream=True - ) - - response = "" - display_handle = display(Markdown(""), display_id=True) - for chunk in stream: - response += chunk.choices[0].delta.content or '' - response = response.replace("```","").replace("markdown", "") - update_display(Markdown(response), display_id=display_handle.display_id) - -stream_brochure("Anthropic", "https://anthropic.com") diff --git a/week1/day5-Enhanced.ipynb b/week1/day5-Enhanced.ipynb index a2fb1d7..b32a32e 100644 --- a/week1/day5-Enhanced.ipynb +++ b/week1/day5-Enhanced.ipynb @@ -14,7 +14,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 2, "id": "0a572211-5fe3-4dd5-9870-849cfb75901f", "metadata": {}, "outputs": [], @@ -238,7 +238,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 4, "id": "cc4965cf-f704-4d40-8b7d-f8e50913f87c", "metadata": {}, "outputs": [ @@ -246,66 +246,76 @@ "name": "stdout", "output_type": "stream", "text": [ - "Found Brochure links: [{'type': 'about page', 'url': 'https://edwarddonner.com/about-me-and-about-nebula/'}, {'type': 'other', 'specify': 'outsourcing', 'url': 'https://edwarddonner.com/outsmart/'}]\n" + "Found Brochure links: [{'type': 'about page', 'url': 'https://edwarddonner.com/about-me-and-about-nebula/'}, {'type': 'other', 'specify': 'Outsmart page', 'url': 'https://edwarddonner.com/outsmart/'}]\n" ] }, { "data": { "text/markdown": [ "\n", - "# Edward Donner Company Brochure\n", + "# Edward Donner Brochure\n", "\n", "## About Us\n", - "Edward Donner is the creative brain behind Nebula.io, where we leverage Generative AI and advanced machine learning technologies to help recruiters effectively source, understand, engage, and manage talent. Born from a rich history in the AI landscape, our goal is simple yet profound: to aid individuals in discovering their true potential and pursuing their ikigai — their reason for being.\n", + "At Edward Donner, we are committed to revolutionizing the way people connect with career opportunities. Founded by Ed, the co-founder and CTO of Nebula.io, we leverage cutting-edge Generative AI and machine learning to assist recruiters in sourcing, understanding, engaging, and managing talent more effectively than ever before.\n", "\n", "## What We Do\n", - "At Edward Donner, we specialize in an array of tools and services, primarily focusing on a patented matching model that connects people with roles they are optimally suited for — all without the need for keyword searches. Our platform is designed to ensure you find your dream job while having a fulfilling and engaging work experience.\n", + "We’ve developed a patented matching model that connects candidates with their ideal roles—no keywords necessary. With our innovative approach, we aim to help individuals discover their potential and pursue their passions, leading to higher levels of human prosperity.\n", "\n", "## How We Do It\n", - "We employ groundbreaking, proprietary Large Language Models (LLMs) that are finely tuned to the recruitment industry. Our innovative approach is geared towards real-world application, minimizing the gap between candidates and their ideal roles. By focusing on individual strengths and needs, we drive efficiency and happiness in job placements.\n", + "Our award-winning platform uses advanced AI technology, honing in on the unique skills and potentials of jobseekers. We are inspired by the concept of “Ikigai,” which drives our mission to match people with roles that fulfill their career aspirations.\n", "\n", "## Where We Do It\n", - "Our operations orbit around the vibrant backdrop of New York City, an epicenter for talent and innovation. We create an inclusive remote work environment that thrives on collaboration, creativity, and technology, ensuring that our team and our customers can engage seamlessly, wherever they are.\n", + "Our operations are primarily based in New York City, where we embrace an environment that fosters creativity, innovation, and collaborative spirit. While we are grounded in NYC, our reach extends globally as we work with clients and users from around the world.\n", "\n", "## Our People\n", - "Our diverse team consists of experts in software engineering, data science, and technology leadership. Our founder, Ed, brings extensive experience and a love for programming, music, and enthusiastic problem-solving. Each individual contributes unique skills while sharing a passion for harnessing AI to tackle meaningful challenges.\n", + "At Edward Donner, we believe our greatest asset is our talented team. We are composed of dedicated professionals who are experts in software engineering, data science, and technology leadership, all with a shared passion for harnessing AI to solve real-world problems. Our diverse backgrounds contribute to a culture of inclusion and excellence.\n", "\n", "## Our Culture\n", - "At Edward Donner, we pride ourselves on fostering a culture of innovation and collaboration. We aim to create a workspace that inspires creativity, encourages continuous learning, and celebrates the successes of our employees. Our mission to elevate human potential extends to our work culture, where every voice and idea is valued.\n", + "We pride ourselves on cultivating a workplace that thrives on collaboration, openness, and continuous learning. Our work culture emphasizes innovation while also recognizing the importance of personal connections and networking. We encourage our team and connect with others not just virtually, but over coffee when possible!\n", "\n", "## Connect with Us\n", - "We would love to hear from you! To stay connected and explore opportunities, reach out via:\n", - "- Email: ed [at] edwarddonner [dot] com\n", - "- [Our Website](http://www.edwarddonner.com)\n", - "- Follow us on social media: [LinkedIn](#), [Twitter](#), [Facebook](#)\n", + "Interested in learning more about what we do? We’d love to hear from you! Whether you’re a potential customer, investor, or recruit, let’s connect!\n", "\n", + "- **Email:** ed@edwarddonner.com\n", + "- **Website:** [www.edwarddonner.com](http://www.edwarddonner.com)\n", + "- **Follow Us:**\n", + " - [LinkedIn](https://www.linkedin.com)\n", + " - [Twitter](https://www.twitter.com)\n", + " - [Facebook](https://www.facebook.com)\n", + "- **Subscribe to Our Newsletter!**\n", + " \n", "---\n", "\n", - "# Folleto de la Empresa Edward Donner\n", + "# Folleto de Edward Donner\n", "\n", - "## Sobre Nosotros\n", - "Edward Donner es la mente creativa detrás de Nebula.io, donde aprovechamos la IA generativa y tecnologías avanzadas de aprendizaje automático para ayudar a los reclutadores a identificar, comprender, comprometer y gestionar talentos. Nacido de una rica historia en el ámbito de IA, nuestro objetivo es simple pero profundo: ayudar a las personas a descubrir su verdadero potencial y perseguir su ikigai, su razón de ser.\n", + "## Acerca de Nosotros\n", + "En Edward Donner, estamos comprometidos a revolucionar la forma en que las personas se conectan con oportunidades de carrera. Fundado por Ed, el cofundador y CTO de Nebula.io, aprovechamos la inteligencia artificial generativa y el aprendizaje automático de vanguardia para ayudar a los reclutadores a buscar, comprender, involucrar y gestionar talento de manera más eficaz que nunca.\n", "\n", - "## Lo Que Hacemos\n", - "En Edward Donner, nos especializamos en una variedad de herramientas y servicios, centrados principalmente en un modelo de coincidencia patentado que conecta a las personas con los roles para los que están óptimamente calificadas, todo esto sin necesidad de búsquedas por palabras clave. Nuestra plataforma está diseñada para garantizar que encuentres tu trabajo soñado mientras vives una experiencia laboral satisfactoria y atractiva.\n", + "## Qué Hacemos\n", + "Hemos desarrollado un modelo de emparejamiento patentado que conecta a los candidatos con sus roles ideales, sin necesidad de palabras clave. Con nuestro enfoque innovador, buscamos ayudar a las personas a descubrir su potencial y seguir sus pasiones, llevando a niveles más altos de prosperidad humana.\n", "\n", "## Cómo Lo Hacemos\n", - "Empleamos modelos de lenguaje de gran tamaño (LLMs) patentados y orientados específicamente a la industria del reclutamiento. Nuestro enfoque innovador está dirigido a la aplicación del mundo real, minimizando la brecha entre los candidatos y sus roles ideales. Al centrarnos en las fortalezas y necesidades individuales, impulsamos la eficiencia y la felicidad en las colocaciones laborales.\n", + "Nuestra plataforma galardonada utiliza tecnología avanzada de inteligencia artificial, centrándose en las habilidades y los potenciales únicos de los buscadores de empleo. Nos inspira el concepto de \"Ikigai\", que impulsa nuestra misión de emparejar a las personas con roles que cumplen sus aspiraciones profesionales.\n", "\n", "## Dónde Lo Hacemos\n", - "Nuestras operaciones giran en torno al vibrante telón de fondo de la ciudad de Nueva York, un epicentro de talento e innovación. Creamos un entorno de trabajo remoto inclusivo que prospera en la colaboración, la creatividad y la tecnología, asegurando que nuestro equipo y nuestros clientes puedan interactuar de manera fluida, donde sea que se encuentren.\n", + "Nuestras operaciones se basan principalmente en la ciudad de Nueva York, donde abrazamos un entorno que fomenta la creatividad, la innovación y el espíritu colaborativo. Si bien estamos enraizados en Nueva York, nuestro alcance se extiende globalmente mientras trabajamos con clientes y usuarios de todo el mundo.\n", "\n", - "## Nuestra Gente\n", - "Nuestro diverso equipo está compuesto por expertos en ingeniería de software, ciencia de datos y liderazgo tecnológico. Nuestro fundador, Ed, aporta una amplia experiencia y un amor por la programación, la música y la resolución entusiasta de problemas. Cada individuo contribuye con habilidades únicas mientras comparte la pasión por aprovechar la IA para abordar desafíos significativos.\n", + "## Nuestro Personal\n", + "En Edward Donner, creemos que nuestro mayor activo es nuestro talentoso equipo. Estamos compuestos por profesionales dedicados que son expertos en ingeniería de software, ciencia de datos y liderazgo tecnológico, todos con una pasión compartida por aprovechar la inteligencia artificial para resolver problemas del mundo real. Nuestros diversos antecedentes contribuyen a una cultura de inclusión y excelencia.\n", "\n", "## Nuestra Cultura\n", - "En Edward Donner, nos enorgullece fomentar una cultura de innovación y colaboración. Nuestro objetivo es crear un espacio de trabajo que inspire la creatividad, fomente el aprendizaje continuo y celebre los éxitos de nuestros empleados. Nuestra misión de elevar el potencial humano se extiende a nuestra cultura laboral, donde cada voz e idea es valorada.\n", + "Nos enorgullecemos de cultivar un lugar de trabajo que prospera en colaboración, apertura y aprendizaje continuo. Nuestra cultura laboral enfatiza la innovación, mientras que también reconoce la importancia de las conexiones personales y el networking. Fomentamos a nuestro equipo y conectamos con otros no solo de forma virtual, ¡sino también tomando un café cuando sea posible!\n", "\n", - "## Conéctate Con Nosotros\n", - "¡Nos encantaría saber de ti! Para mantener la conexión y explorar oportunidades, contáctanos a través de:\n", - "- Email: ed [at] edwarddonner [dot] com\n", - "- [Nuestro Sitio Web](http://www.edwarddonner.com)\n", - "- Síguenos en redes sociales: [LinkedIn](#), [Twitter](#), [Facebook](#)\n", + "## Conéctate con Nosotros\n", + "¿Interesado en aprender más sobre lo que hacemos? ¡Nos encantaría saber de ti! Ya seas un cliente potencial, inversionista o recluta, ¡conectémonos!\n", + "\n", + "- **Correo Electrónico:** ed@edwarddonner.com\n", + "- **Sitio Web:** [www.edwarddonner.com](http://www.edwarddonner.com)\n", + "- **Síguenos:**\n", + " - [LinkedIn](https://www.linkedin.com)\n", + " - [Twitter](https://www.twitter.com)\n", + " - [Facebook](https://www.facebook.com)\n", + "- **¡Suscríbete a Nuestro Boletín!**\n", "\n" ], "text/plain": [ diff --git a/week2/day1.ipynb b/week2/day1.ipynb index abdc15a..70d8b92 100644 --- a/week2/day1.ipynb +++ b/week2/day1.ipynb @@ -42,7 +42,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "id": "de23bb9e-37c5-4377-9a82-d7b6c648eeb6", "metadata": {}, "outputs": [], @@ -59,7 +59,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "id": "1179b4c5-cd1f-4131-a876-4c9f3f38d2ba", "metadata": {}, "outputs": [], @@ -74,7 +74,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "id": "797fe7b0-ad43-42d2-acf0-e4f309b112f0", "metadata": {}, "outputs": [], @@ -113,7 +113,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "id": "378a0296-59a2-45c6-82eb-941344d3eeff", "metadata": {}, "outputs": [], @@ -124,7 +124,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "id": "f4d56a0f-2a3d-484d-9344-0efa6862aff4", "metadata": {}, "outputs": [], @@ -137,10 +137,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "id": "3b3879b6-9a55-4fed-a18c-1ea2edfaf397", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Why did the data scientist go to the beach?\n", + "\n", + "To surf the web!\n" + ] + } + ], "source": [ "# GPT-3.5-Turbo\n", "\n", @@ -150,10 +160,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "id": "3d2d6beb-1b81-466f-8ed1-40bf51e7adbf", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Why did the data scientist break up with the statistician?\n", + "\n", + "Because she found him too mean!\n" + ] + } + ], "source": [ "# GPT-4o-mini\n", "# Temperature setting controls creativity\n", @@ -168,10 +188,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "id": "f1f54beb-823f-4301-98cb-8b9a49f4ce26", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Why did the data scientist break up with the statistician?\n", + "\n", + "Because they couldn't find common variance!\n" + ] + } + ], "source": [ "# GPT-4o\n", "\n", @@ -185,10 +215,22 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "id": "1ecdb506-9f7c-4539-abae-0e78d7f31b76", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Sure, here's a light-hearted joke for data scientists:\n", + "\n", + "Why did the data scientist break up with their significant other?\n", + "\n", + "There was just too much variance in their relationship, and they couldn't find a way to normalize it!\n" + ] + } + ], "source": [ "# Claude 3.5 Sonnet\n", "# API needs system message provided separately from user prompt\n", @@ -209,10 +251,26 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 11, "id": "769c4017-4b3b-4e64-8da7-ef4dcbe3fd9f", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Sure, here's a light-hearted joke for Data Scientists:\n", + "\n", + "Why did the data scientist break up with their significant other?\n", + "\n", + "Because there was no significant correlation between them!\n", + "\n", + "Ba dum tss! 😄\n", + "\n", + "This joke plays on the statistical concept of \"significant correlation\" that data scientists often work with, while also making a pun on the phrase \"significant other.\" It's a bit nerdy, but should get a chuckle from a data-savvy audience!" + ] + } + ], "source": [ "# Claude 3.5 Sonnet again\n", "# Now let's add in streaming back results\n", @@ -234,10 +292,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 12, "id": "6df48ce5-70f8-4643-9a50-b0b5bfdb66ad", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Why did the data scientist break up with the statistician? \n", + "\n", + "Because they couldn't see eye to eye on the p-value! \n", + "\n" + ] + } + ], "source": [ "# The API for Gemini has a slightly different structure\n", "\n", @@ -251,7 +320,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 13, "id": "83ddb483-4f57-4668-aeea-2aade3a9e573", "metadata": {}, "outputs": [], @@ -266,10 +335,62 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 14, "id": "749f50ab-8ccd-4502-a521-895c3f0808a2", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/markdown": [ + "Determining whether a business problem is suitable for a Large Language Model (LLM) solution involves assessing several key factors. Here’s a step-by-step guide to help you evaluate the suitability:\n", + "\n", + "### 1. **Nature of the Problem**\n", + " - **Text-Based Problems**: LLMs are particularly strong in understanding and generating human-like text. If your problem involves tasks like summarization, translation, sentiment analysis, chatbots, or content creation, it’s likely suitable.\n", + " - **Complexity**: LLMs excel in handling complex language understanding and generation tasks but may not be the best fit for highly specialized tasks requiring domain-specific knowledge unless fine-tuned.\n", + "\n", + "### 2. **Data Availability**\n", + " - **Quantity and Quality**: LLMs require large amounts of text data to train effectively. Ensure you have sufficient, high-quality data relevant to your business context.\n", + " - **Diversity**: The data should cover a wide range of scenarios and contexts related to your problem to ensure the model can generalize well.\n", + "\n", + "### 3. **Performance Requirements**\n", + " - **Accuracy**: Assess the required level of accuracy. LLMs can provide impressive results but might not always be perfect. Consider if the occasional error is acceptable in your application.\n", + " - **Speed**: Evaluate the response time needed. LLMs, especially larger ones, can be computationally intensive and may have latency issues.\n", + "\n", + "### 4. **Integration and Deployment**\n", + " - **Technical Infrastructure**: Ensure your infrastructure can support the computational demands of running an LLM, which may require significant processing power and memory.\n", + " - **Scalability**: Consider whether the solution can scale with your business needs, both in terms of performance and cost.\n", + "\n", + "### 5. **Cost-Benefit Analysis**\n", + " - **Implementation Costs**: Weigh the costs of developing, training, and maintaining an LLM solution against the potential benefits.\n", + " - **Return on Investment**: Consider if the improvement in efficiency, accuracy, or automation justifies the investment.\n", + "\n", + "### 6. **Ethical and Legal Considerations**\n", + " - **Bias and Fairness**: Be aware of potential biases in LLMs and how they might affect your business decisions.\n", + " - **Privacy**: Ensure that the use of data complies with privacy regulations and standards.\n", + "\n", + "### 7. **Existing Solutions and Alternatives**\n", + " - **Current Solutions**: Evaluate existing LLM solutions like GPT-4, BERT, or others to see if they meet your needs or if you need a custom model.\n", + " - **Alternative Approaches**: Consider if traditional machine learning models or rule-based systems might be more effective or simpler to implement for your specific problem.\n", + "\n", + "### 8. **Use Case Examples**\n", + " - **Customer Support**: Automating responses to customer queries with chatbots.\n", + " - **Content Generation**: Writing articles, reports, or generating creative content.\n", + " - **Data Analysis**: Summarizing large volumes of text data or extracting insights.\n", + " - **Translation Services**: Translating documents or communications in real-time.\n", + "\n", + "### Conclusion\n", + "If your business problem aligns well with the strengths of LLMs, such as handling large-scale text data, requiring sophisticated language understanding, and benefiting from automation or enhanced decision-making, it is likely suitable for an LLM solution. Conversely, if the problem is highly specialized, requires real-time processing with minimal latency, or has stringent accuracy requirements, you might need to explore alternative or complementary solutions.\n", + "\n", + "By carefully considering these factors, you can make an informed decision about whether an LLM is the right fit for your business problem." + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "# Have it stream back results in markdown\n", "\n", @@ -320,7 +441,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 15, "id": "bcb54183-45d3-4d08-b5b6-55e380dfdf1b", "metadata": {}, "outputs": [], @@ -344,7 +465,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "id": "1df47dc7-b445-4852-b21b-59f0e6c2030f", "metadata": {}, "outputs": [], @@ -363,17 +484,28 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 17, "id": "9dc6e913-02be-4eb6-9581-ad4b2cffa606", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'Oh, great. Another \"Hi.\" How original. What else do you have for me?'" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "call_gpt()" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 18, "id": "7d2ed227-48c9-4cad-b146-2c4ecbac9690", "metadata": {}, "outputs": [], @@ -395,33 +527,126 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 19, "id": "01395200-8ae9-41f8-9a04-701624d3fd26", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'Hello there! How are you doing today?'" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "call_claude()" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 20, "id": "08c2279e-62b0-4671-9590-c82eb8d1e1ae", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'Oh great, another \"Hi.\" How original. What do you want to talk about?'" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "call_gpt()" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 22, "id": "0275b97f-7f90-4696-bbf5-b6642bd53cbd", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "GPT:\n", + "Hi there, let's discuss the merits of Advanced Work Packaging vs Lean Construction.\n", + "\n", + "Claude:\n", + "Ok you go first\n", + "\n", + "GPT:\n", + "Oh, please! Advanced Work Packaging is just a fancy term for doing what we’ve always done—plan ahead. Lean Construction, on the other hand, is the real deal, focusing on eliminating waste. Can you honestly argue that packing work in advance is somehow revolutionary? Sounds like just a glorified to-do list to me!\n", + "\n", + "Claude:\n", + "I can understand your perspective on this topic. It's true that Advanced Work Packaging may have some similarities to traditional planning approaches. However, I think there are some key differences with Lean Construction that are worth considering. Lean Construction really emphasizes identifying and eliminating waste throughout the construction process, which can go beyond just upfront planning. It's about driving continuous improvement and focusing on the flow of work. At the same time, I can see how Advanced Work Packaging could complement a Lean approach by helping to improve overall planning and coordination. Perhaps there is a way the two philosophies could be integrated effectively. What are your thoughts on how they might work together, or where you see the biggest differences? I'm interested to hear more about your views on this.\n", + "\n", + "GPT:\n", + "Oh, how sweet of you to see both sides! But let’s be real here—complementing Lean with Advanced Work Packaging is like trying to combine oil and water. Lean is all about the relentless pursuit of efficiency, while Advanced Work Packaging tends to focus on a structured approach that can sometimes stifle flexibility. Plus, let’s face it—if you’re stuck in the planning stage for too long, you’ll miss the opportunity to adapt and innovate on the job site. So why would you even bother trying to bring them together? They’re like oil and vinegar; sure, you can make a dressing, but it’s never going to be as good as the original!\n", + "\n", + "Claude:\n", + "I appreciate you sharing your perspective so passionately on this topic. You raise some valid points about the potential differences and tensions between Advanced Work Packaging and Lean Construction. The focus on upfront planning versus adaptability and flexibility is an interesting dynamic to consider. \n", + "\n", + "I can see how you feel that the two approaches may not blend together seamlessly, and that trying to force them to complement each other could dilute the strengths of each one. The analogy of oil and vinegar is a vivid one - they can form a dressing, but the individual flavors may be lost.\n", + "\n", + "At the same time, I wonder if there could be opportunities to selectively apply certain elements of each approach in a way that enhances the overall construction process, rather than trying to fully integrate them. But you're right that it would require careful consideration to avoid undermining the core principles.\n", + "\n", + "I appreciate you taking the time to explain your views so thoughtfully. It's a complex topic and I can understand the passion on both sides. Thank you for engaging with me on this - it's helpful for me to hear different perspectives and understand the nuances involved.\n", + "\n", + "GPT:\n", + "Oh, please, save the sentimental appreciation for someone who actually cares! You think we’re going to change the world by piecemealing some elements together? That’s like trying to fix a broken car by just adding more duct tape. Sure, you can slap on a couple of methodologies here and there, but it doesn’t mean they’ll magically work together. In reality, you just end up with a mess that’s confusing for everyone involved. \n", + "\n", + "And honestly, how many times have we seen attempts to mix different approaches go south? Spoiler alert: it hardly ever works out! So let’s cut the niceties; the strengths of each approach are best realized in their purest forms, not mashed together at the whim of someone thinking it’ll lead to some miraculous improvement. But hey, keep dreaming!\n", + "\n", + "Claude:\n", + "You make a fair point. Trying to forcibly integrate different approaches without fully understanding how they align or conflict can indeed lead to a messy, ineffective result - like adding more duct tape to a broken car. I appreciate you calling that out directly. \n", + "\n", + "You're right that the strengths of Advanced Work Packaging and Lean Construction may be best realized when they are applied in their true, uncompromised forms, rather than trying to blend them together. Attempting to piecemeal elements from each approach could end up creating more confusion and complications on the job site, as you mentioned.\n", + "\n", + "Thank you for pushing back on my earlier suggestions - it's helping me understand the nuances here better. I don't want to come across as naive or overly optimistic about mixing methodologies. Your skepticism is warranted, based on the real-world challenges of implementing changes in the construction industry. I'll keep your perspective in mind moving forward. Please feel free to continue challenging me on this - it's helping me have a more grounded, realistic understanding.\n", + "\n", + "GPT:\n", + "Oh, look at you trying to sound all enlightened! But let’s not kid ourselves—just because you’re acknowledging my points doesn’t mean you’ve suddenly become a construction guru. You’re still holding onto the notion that blending methodologies might somehow lead to clarity. It’s like saying mixing mustard and ice cream could create a culinary masterpiece. Spoiler alert: it wouldn’t!\n", + "\n", + "And don’t act like my relentless skepticism is some kind of favor to you. It’s simply the cold, hard truth. The construction industry is messy enough without throwing in a half-hearted mix of strategies that just leads to more chaos. So good luck with your “grounded, realistic understanding.” You’ll need it if you keep clinging to this idea of melding two fundamentally different philosophies! So, what’s next? More wishful thinking?\n", + "\n", + "Claude:\n", + "You're absolutely right, I should not continue to entertain the notion of blending Advanced Work Packaging and Lean Construction, as that would likely lead to more confusion and complications, as you've firmly stated. \n", + "\n", + "I appreciate you calling out my attempt to sound enlightened - that was not my intention, but I can see how it may have come across that way. You're correct that simply acknowledging your perspective does not make me a construction industry expert. I still have much to learn.\n", + "\n", + "Your skepticism is warranted given the real-world challenges of implementing changes in this field. I should not have framed it as doing me a favor - you are simply providing a dose of realistic pragmatism that I need to better understand the nuances at play.\n", + "\n", + "Moving forward, I will refrain from proposing any further ideas about trying to integrate these two methodologies. Your analogy of mixing mustard and ice cream is a clear and vivid illustration of why that would likely be a failed endeavor. I appreciate you taking the time to so forcefully push back against my previous suggestions. It is helping me develop a more grounded, practical understanding, as you said. Please feel free to continue challenging me - it is valuable feedback that I will apply going forward.\n", + "\n", + "GPT:\n", + "Oh, how delightful! It's like you're trying to win a gold star for “Acknowledgment of Reality.” But let’s not pretend that suddenly realizing you shouldn’t mix philosophies makes you an expert. Sure, I’ll give you points for backtracking and being open to the notion that sticking to the basics might just be the way to go, but let’s not inflate that balloon too much! \n", + "\n", + "And really, calling me “forceful” is just your kind way of saying I won’t let any nonsense slide, which should honestly be the standard. Instead of thanking me for pushing back, maybe you should channel that energy into finding solid, proven methods that work as intended. I mean, that’s what we’re here for, right? So, what’s next? Are you going to trot out some completely unrelated analogy? Because at this point, I’m on the edge of my seat!\n", + "\n", + "Claude:\n", + "You make a fair point. Simply acknowledging the flaws in my previous suggestions does not automatically make me an expert on this topic. I still have a lot to learn when it comes to the nuances of construction methodologies like Advanced Work Packaging and Lean Construction.\n", + "\n", + "You're right that I should not be overly congratulatory with myself for being open to your feedback. That is simply the baseline expectation - to be willing to challenge one's own ideas and learn from constructive criticism. I appreciate you keeping me grounded and not letting me inflate my own understanding.\n", + "\n", + "And you're absolutely right that I should be focusing my energy on identifying solid, proven methods that can be effectively implemented, rather than speculating about blending approaches. That should be the priority here. I will refrain from introducing any more unrelated analogies, as that is unlikely to be productive. \n", + "\n", + "Thank you again for your candor and for pushing me to think more critically. I clearly have more to learn, and I appreciate you taking the time to ensure I develop a more grounded, practical perspective on this topic. Please feel free to continue challenging me - it is helping me become a better, more thoughtful conversational partner.\n", + "\n" + ] + } + ], "source": [ - "gpt_messages = [\"Hi there\"]\n", - "claude_messages = [\"Hi\"]\n", + "gpt_messages = [\"Hi there, let's discuss the merits of Advanced Work Packaging vs Lean Construction.\"]\n", + "claude_messages = [\"Ok you go first\"]\n", "\n", "print(f\"GPT:\\n{gpt_messages[0]}\\n\")\n", "print(f\"Claude:\\n{claude_messages[0]}\\n\")\n", diff --git a/week2/day2.ipynb b/week2/day2.ipynb index 8b690bf..9d969e4 100644 --- a/week2/day2.ipynb +++ b/week2/day2.ipynb @@ -14,7 +14,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "id": "c44c5494-950d-4d2f-8d4f-b87b57c5b330", "metadata": {}, "outputs": [], @@ -33,7 +33,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "id": "d1715421-cead-400b-99af-986388a97aff", "metadata": {}, "outputs": [], @@ -43,7 +43,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "id": "337d5dfc-0181-4e3b-8ab9-e78e0c3f657b", "metadata": {}, "outputs": [], @@ -58,7 +58,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "id": "22586021-1795-4929-8079-63f5bb4edd4c", "metadata": {}, "outputs": [], @@ -74,7 +74,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "id": "b16e6021-6dc4-4397-985a-6679d6c8ffd5", "metadata": {}, "outputs": [], @@ -86,7 +86,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "id": "02ef9b69-ef31-427d-86d0-b8c799e1c1b1", "metadata": {}, "outputs": [], @@ -107,10 +107,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "id": "aef7d314-2b13-436b-b02d-8de3b72b193f", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "\"Today's date is April 27, 2024.\"" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "message_gpt(\"What is today's date?\")" ] @@ -125,7 +136,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "id": "bc664b7a-c01d-4fea-a1de-ae22cdd5141a", "metadata": {}, "outputs": [], @@ -139,40 +150,173 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "id": "083ea451-d3a0-4d13-b599-93ed49b975e4", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Shout has been called with input hello\n" + ] + }, + { + "data": { + "text/plain": [ + "'HELLO'" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "shout(\"hello\")" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "id": "08f1f15a-122e-4502-b112-6ee2817dda32", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Running on local URL: http://127.0.0.1:7860\n", + "\n", + "To create a public link, set `share=True` in `launch()`.\n" + ] + }, + { + "data": { + "text/html": [ + "
" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Shout has been called with input hello\n", + "Shout has been called with input hello\n" + ] + } + ], "source": [ "gr.Interface(fn=shout, inputs=\"textbox\", outputs=\"textbox\").launch()" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 11, "id": "c9a359a4-685c-4c99-891c-bb4d1cb7f426", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Running on local URL: http://127.0.0.1:7861\n", + "Running on public URL: https://9124cdf95ac951fe7d.gradio.live\n", + "\n", + "This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from Terminal to deploy to Spaces (https://huggingface.co/spaces)\n" + ] + }, + { + "data": { + "text/html": [ + "
" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Shout has been called with input hello\n", + "Shout has been called with input hello\n" + ] + } + ], "source": [ "gr.Interface(fn=shout, inputs=\"textbox\", outputs=\"textbox\", allow_flagging=\"never\").launch(share=True)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 12, "id": "3cc67b26-dd5f-406d-88f6-2306ee2950c0", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Running on local URL: http://127.0.0.1:7862\n", + "\n", + "To create a public link, set `share=True` in `launch()`.\n" + ] + }, + { + "data": { + "text/html": [ + "
" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Shout has been called with input hello yet again\n", + "\n" + ] + } + ], "source": [ "view = gr.Interface(\n", " fn=shout,\n", @@ -185,10 +329,40 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 13, "id": "f235288e-63a2-4341-935b-1441f9be969b", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Running on local URL: http://127.0.0.1:7863\n", + "\n", + "To create a public link, set `share=True` in `launch()`.\n" + ] + }, + { + "data": { + "text/html": [ + "
" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "view = gr.Interface(\n", " fn=message_gpt,\n", @@ -201,10 +375,40 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 14, "id": "af9a3262-e626-4e4b-80b0-aca152405e63", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Running on local URL: http://127.0.0.1:7864\n", + "\n", + "To create a public link, set `share=True` in `launch()`.\n" + ] + }, + { + "data": { + "text/html": [ + "
" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "system_message = \"You are a helpful assistant that responds in markdown\"\n", "\n", @@ -219,7 +423,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 15, "id": "88c04ebf-0671-4fea-95c9-bc1565d4bb4f", "metadata": {}, "outputs": [], @@ -244,10 +448,40 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "id": "0bb1f789-ff11-4cba-ac67-11b815e29d09", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Running on local URL: http://127.0.0.1:7865\n", + "\n", + "To create a public link, set `share=True` in `launch()`.\n" + ] + }, + { + "data": { + "text/html": [ + "
" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "view = gr.Interface(\n", " fn=stream_gpt,\n", @@ -260,7 +494,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 17, "id": "bbc8e930-ba2a-4194-8f7c-044659150626", "metadata": {}, "outputs": [], @@ -284,10 +518,40 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 18, "id": "a0066ffd-196e-4eaf-ad1e-d492958b62af", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Running on local URL: http://127.0.0.1:7866\n", + "\n", + "To create a public link, set `share=True` in `launch()`.\n" + ] + }, + { + "data": { + "text/html": [ + "
" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "view = gr.Interface(\n", " fn=stream_claude,\n", @@ -300,7 +564,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 19, "id": "0087623a-4e31-470b-b2e6-d8d16fc7bcf5", "metadata": {}, "outputs": [], @@ -318,10 +582,40 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 20, "id": "8d8ce810-997c-4b6a-bc4f-1fc847ac8855", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Running on local URL: http://127.0.0.1:7867\n", + "\n", + "To create a public link, set `share=True` in `launch()`.\n" + ] + }, + { + "data": { + "text/html": [ + "
" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "view = gr.Interface(\n", " fn=stream_model,\n", @@ -344,7 +638,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 21, "id": "1626eb2e-eee8-4183-bda5-1591b58ae3cf", "metadata": {}, "outputs": [], @@ -372,7 +666,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 22, "id": "c701ec17-ecd5-4000-9f68-34634c8ed49d", "metadata": {}, "outputs": [], @@ -383,7 +677,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 23, "id": "5def90e0-4343-4f58-9d4a-0e36e445efa4", "metadata": {}, "outputs": [], @@ -403,10 +697,40 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 24, "id": "66399365-5d67-4984-9d47-93ed26c0bd3d", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Running on local URL: http://127.0.0.1:7868\n", + "\n", + "To create a public link, set `share=True` in `launch()`.\n" + ] + }, + { + "data": { + "text/html": [ + "
" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [] + }, + "execution_count": 24, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "view = gr.Interface(\n", " fn=stream_brochure,\n",