"**HuggingFace: Empowering AI with Community and Innovation**\n",
"\n",
"Welcome to HuggingFace! Our mission is to democratize AI by building an open-source ecosystem. Explore our cutting-edge tools, libraries, and models that help developers, researchers, and companies leverage the power of artificial intelligence.\n",
"\n",
"---\n",
"\n",
"#### What We Offer:\n",
"\n",
"1. **Transformers Library** \n",
" The most popular open-source library for Natural Language Processing (NLP). Easily integrate state-of-the-art models into your applications.\n",
"\n",
"2. **Datasets** \n",
" Access a wide range of curated datasets for various AI tasks. Perfect for training and evaluating your models.\n",
"\n",
"3. **Model Hub** \n",
" Explore thousands of pre-trained models. Customize and deploy them to meet your specific needs.\n",
"\n",
"4. **Community Support** \n",
" Join our vibrant community of developers and researchers. Share knowledge, seek help, and collaborate on fascinating AI projects.\n",
"\n",
"---\n",
"\n",
"#### Why Choose HuggingFace?\n",
"\n",
"- **User-Friendly** \n",
" Built with developers in mind, our tools are intuitive and easy to use.\n",
"\n",
"- **Extensive Documentation** \n",
" Comprehensive guides and examples to help you get started quickly.\n",
"\n",
"- **Active Development** \n",
" We are continuously improving our libraries and models, driven by community feedback.\n",
"\n",
"- **Enterprise Support** \n",
" Tailored solutions and support for businesses to implement AI strategies effectively.\n",
"\n",
"---\n",
"\n",
"#### Get Started Today!\n",
"\n",
"Visit us at [huggingface.co](http://huggingface.co) to learn more, access our tools, and join the AI revolution.\n",
"\n",
"---\n",
"\n",
"**Contact Us:** \n",
"Email: contact@huggingface.co \n",
"Twitter: @HuggingFace \n",
"Join our community forums to connect with fellow AI enthusiasts!\n",
"\n",
"---\n",
"\n",
"### हिंदी में अनुवादित पैम्फलेट\n",
"\n",
"---\n",
"\n",
"**हगिंगफेस: समुदाय और नवाचार के साथ एआई को सशक्त बनाना**\n",
"\n",
"हगिंगफेस में आपका स्वागत है! हमारा मिशन एक ओपन-सोर्स पारिस्थितिकी तंत्र बनाकर एआई को लोकतांत्रिक बनाना है। हमारे अत्याधुनिक उपकरणों, पुस्तकालयों और मॉडलों का अन्वेषण करें जो डेवलपर्स, शोधकर्ताओं और कंपनियों को कृत्रिम बुद्धिमत्ता की शक्ति का लाभ उठाने में मदद करते हैं।\n",
"\n",
"---\n",
"\n",
"#### हम क्या पेश करते हैं:\n",
"\n",
"1. **ट्रांसफार्मर्स पुस्तकालय** \n",
" प्राकृतिक भाषा प्रसंस्करण (NLP) के लिए सबसे लोकप्रिय ओपन-सोर्स पुस्तकालय। अपने अनुप्रयोगों में अत्याधुनिक मॉडलों को आसानी से एकीकृत करें।\n",
"\n",
"2. **डेटासेट्स** \n",
" विभिन्न एआई कार्यों के लिए कुशलतापूर्वक तैयार किए गए डेटासेट्स की विस्तृत श्रृंखला तक पहुंचें। अपने मॉडलों को प्रशिक्षित और मूल्यांकित करने के लिए उपयुक्त।\n",
"\n",
"3. **मॉडल हब** \n",
" हजारों प्री-ट्रेंड मॉडलों की खोज करें। उन्हें अपनी विशिष्ट आवश्यकताओं को पूरा करने के लिए अनुकूलित और लागू करें।\n",
"\n",
"4. **समुदाय समर्थन** \n",
" हमारे जीवंत समुदाय में डेवलपर्स और शोधकर्ताओं से जुड़ें। ज्ञान साझा करें, सहायता प्राप्त करें, और दिलचस्प एआई परियोजनाओं पर सहयोग करें।\n",
"\n",
"---\n",
"\n",
"#### हगिंगफेस क्यों चुनें?\n",
"\n",
"- **उपयोगकर्ता के अनुकूल** \n",
" हमारे उपकरण डेवलपर्स को ध्यान में रखते हुए बनाए गए हैं, जो सहज और उपयोग में आसान हैं।\n",
"\n",
"- **विस्तृत दस्तावेजीकरण** \n",
" आपको तेजी से शुरुआत करने में मदद करने के लिए व्यापक मार्गदर्शिकाएँ और उदाहरण।\n",
"\n",
"- **सक्रिय विकास** \n",
" हम लगातार अपने पुस्तकालयों और मॉडलों में सुधार कर रहे हैं, जो समुदाय से प्राप्त फीडबैक पर आधारित हैं।\n",
"\n",
"- **एंटरप्राइज समर्थन** \n",
" व्यवसायों के लिए एआई रणनीतियों को प्रभावी रूप से लागू करने के लिए अनुकूलित समाधान और समर्थन।\n",
"\n",
"---\n",
"\n",
"#### आज ही शुरुआत करें!\n",
"\n",
"और जानने के लिए [huggingface.co](http://huggingface.co) पर जाएं, हमारे उपकरणों तक पहुंचें, और एआई क्रांति में शामिल हों।\n",
"\n",
"---\n",
"\n",
"**हमसे संपर्क करें:** \n",
"ईमेल: contact@huggingface.co \n",
"ट्विटर: @HuggingFace \n",
"अन्य एआई उत्साही लोगों से जुड़ने के लिए हमारे समुदाय फोरम में शामिल हों!\n",
"\n",
"--- \n",
"\n",
"This content maintains the original tone and format while accurately translating it into Hindi."
"Certainly! Here are some practical use cases for practicing summarization:\n",
"\n",
"- **News Article Summarizer**: Create an application that automatically summarizes news articles from different sources. Users can input a URL or the text of an article, and the tool generates a concise summary.\n",
"\n",
"- **Meeting Notes Aggregator**: Develop a tool that takes meeting transcripts or recordings, processes the text, and then summarizes key points, decisions made, and action items. This can help teams quickly review important discussions.\n",
"\n",
"- **Book Summary Generator**: Build a tool that allows users to input chapters or excerpts from books and receive a summarized version. This can be helpful for students or busy professionals looking to grasp content quickly.\n",
"\n",
"- **Research Paper Summarizer**: Create a program that summarizes academic papers. You can input the abstract and main sections, and the tool generates a comprehensive yet brief overview of the research findings.\n",
"\n",
"- **Social Media Content Summarization**: Develop a summarization tool that condenses long threads or posts from platforms like Twitter or Reddit, helping users catch up on long discussions without reading every comment.\n",
"\n",
"These projects can enhance your understanding of summarization techniques and improve your programming skills."
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Step 1: Create your prompts\n",
"\n",
"system_prompt = \"something here\"\n",
"user_prompt = \"\"\"\n",
" Lots of text\n",
" Can be pasted here\n",
"\"\"\"\n",
"system_prompt = \"You are an assistant that helps a programmer become an AI Engineer. Answer the question of the user in 200 words or less. Use bulletpoints to list 3 to 5 recommendations.\"\n",
"user_prompt = \"I want you to recommend me some ideas to practice summorization by giving me possible use cases that I can code.\"\n",
"ChatCompletion(id='chatcmpl-AZlyoklFxr67K57aWzkigVIXoB45d', choices=[Choice(finish_reason='stop', index=0, logprobs=None, message=ChatCompletionMessage(content=\"### How are micro RNAs produced in the cell? \\n\\nMicroRNAs (miRNAs) are produced through a multi-step process primarily involving the canonical miRNA biogenesis pathway. This process begins with the transcription of primary miRNA transcripts (pri-miRNAs) by RNA polymerase II (Pol II). The Drosha/DGCR complex then precisely cleaves these pri-miRNAs into precursor miRNAs (pre-miRNAs), which contain a stem-loop (hairpin) structure. Lastly, these pre-miRNAs are transported into the cytosol by the Exportin-5/RAN-GTP complex and further processed into mature miRNA duplexes by the Dicer/TRBP complex, which entails removing the loop structure from pre-miRNAs.\\n\\n### What are the functions of the involved proteins?\\n\\n1. **Drosha/DGCR Complex**: This complex is responsible for the initial cleavage of pri-miRNAs into pre-miRNAs in the nucleus.\\n2. **Exportin-5/RAN-GTP Complex**: It facilitates the transport of the pre-miRNAs from the nucleus into the cytoplasm.\\n3. **Dicer/TRBP Complex**: In the cytoplasm, Dicer processes pre-miRNAs into mature miRNA duplexes, essential for the next steps in gene regulation.\\n4. **RNA-Induced Silencing Complex (RISC)**: Formed by Agonaute proteins (like Ago2), which bind to the mature miRNA strand and target mRNAs for silencing, functioning through interactions with the 3' untranslated region (UTR) of these mRNAs. \\n\\nTogether, these proteins coordinate the production and function of miRNAs, which play crucial roles in regulating gene expression and influencing various cellular processes.\", refusal=None, role='assistant', audio=None, function_call=None, tool_calls=None))], created=1733089278, model='gpt-4o-mini-2024-07-18', object='chat.completion', service_tier=None, system_fingerprint='fp_0705bf87c0', usage=CompletionUsage(completion_tokens=345, prompt_tokens=15752, total_tokens=16097, completion_tokens_details=CompletionTokensDetails(accepted_prediction_tokens=0, audio_tokens=0, reasoning_tokens=0, rejected_prediction_tokens=0), prompt_tokens_details=PromptTokensDetails(audio_tokens=0, cached_tokens=15616)))\n"
]
},
{
"data": {
"text/markdown": [
"### How are micro RNAs produced in the cell? \n",
"\n",
"MicroRNAs (miRNAs) are produced through a multi-step process primarily involving the canonical miRNA biogenesis pathway. This process begins with the transcription of primary miRNA transcripts (pri-miRNAs) by RNA polymerase II (Pol II). The Drosha/DGCR complex then precisely cleaves these pri-miRNAs into precursor miRNAs (pre-miRNAs), which contain a stem-loop (hairpin) structure. Lastly, these pre-miRNAs are transported into the cytosol by the Exportin-5/RAN-GTP complex and further processed into mature miRNA duplexes by the Dicer/TRBP complex, which entails removing the loop structure from pre-miRNAs.\n",
"\n",
"### What are the functions of the involved proteins?\n",
"\n",
"1. **Drosha/DGCR Complex**: This complex is responsible for the initial cleavage of pri-miRNAs into pre-miRNAs in the nucleus.\n",
"2. **Exportin-5/RAN-GTP Complex**: It facilitates the transport of the pre-miRNAs from the nucleus into the cytoplasm.\n",
"3. **Dicer/TRBP Complex**: In the cytoplasm, Dicer processes pre-miRNAs into mature miRNA duplexes, essential for the next steps in gene regulation.\n",
"4. **RNA-Induced Silencing Complex (RISC)**: Formed by Agonaute proteins (like Ago2), which bind to the mature miRNA strand and target mRNAs for silencing, functioning through interactions with the 3' untranslated region (UTR) of these mRNAs. \n",
"\n",
"Together, these proteins coordinate the production and function of miRNAs, which play crucial roles in regulating gene expression and influencing various cellular processes."
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Let's make a web scraper that takes in a pdf file hosted on the internet and returns us a summary (or abstract) of the research paper\n",
"\n",
"# Step 0: Create article class\n",
"class Article:\n",
"\n",
" def __init__(self, url):\n",
" \"\"\"\n",
" Create this Article object from the given url using the BeautifulSoup library\n",
" \"\"\"\n",
" self.url = url \n",
" response = requests.get(self.url)\n",
" if response.status_code == 200:\n",
" pdf_bytes = BytesIO(response.content)\n",
" reader = PdfReader(pdf_bytes)\n",
" \n",
" # Step 2: Extract text from each page of the PDF\n",
" text = \"\"\n",
" for page in reader.pages:\n",
" text += page.extract_text()\n",
" \n",
" self.text = text\n",
" self.title = reader.metadata.get(\"/Title\", \"No title found\")\n",
" else:\n",
" print(f\"Failed to fetch PDF. Status code: {response.status_code}\")\n",
" self.text = \"No text found\"\n",
" self.title = \"No title found\"\n",
"\n",
"# Step 1: Create your prompts\n",
"\n",
"def craft_user_prompt(article):\n",
" user_prompt = f\"You are looking at a research article titled {article.title}\\n Based on the body of the article, how are micro RNAs produced in the cell? State the function of the proteins \\\n",
" involved. The body of the article is as follows.\"\n",
" user_prompt += article.text\n",
" return user_prompt\n",
"\n",
"# Step 2: Make the messages list\n",
"def craft_messages(article):\n",
" system_prompt = \"You are an assistant that analyses the contents of a research article and provide answers to the question asked by the user in 250 words or less. \\\n",
" Ignore text that doesn't belong to the article, like headers or navigation related text. Respond in markdown. Structure your text in the form of question/answer.\"\n",
"Generative AI has numerous business applications across various industries. Here are some examples:\n",
"\n",
"1. **Content Generation**: Generative AI can be used to generate high-quality content such as blog posts, social media posts, product descriptions, and more. This can help reduce the time and cost associated with content creation.\n",
"2. **Marketing Automation**: Generative AI can be used to create personalized marketing messages, emails, and ads that are tailored to individual customers' preferences and behaviors.\n",
"3. **Product Design**: Generative AI can be used to design new products, such as furniture, fashion items, or even entire buildings. This can help reduce the time and cost associated with product development.\n",
"4. **Image and Video Generation**: Generative AI can be used to create realistic images and videos that can be used for advertising, marketing, or entertainment purposes.\n",
"5. **Chatbots and Virtual Assistants**: Generative AI can be used to create more sophisticated chatbots and virtual assistants that can understand natural language and provide personalized responses.\n",
"6. **Data Analysis and Visualization**: Generative AI can be used to analyze large datasets and generate visualizations that help businesses make data-driven decisions.\n",
"7. **Predictive Maintenance**: Generative AI can be used to predict when equipment or machinery is likely to fail, allowing businesses to schedule maintenance and reduce downtime.\n",
"8. **Supply Chain Optimization**: Generative AI can be used to optimize supply chain logistics, including predicting demand, managing inventory, and identifying the most efficient routes for delivery.\n",
"9. **Financial Modeling**: Generative AI can be used to create complex financial models that help businesses forecast revenue, predict costs, and make informed investment decisions.\n",
"10. **Customer Service**: Generative AI can be used to provide 24/7 customer support, helping businesses to improve customer satisfaction and reduce the number of complaints.\n",
"\n",
"Some specific examples of companies using Generative AI include:\n",
"\n",
"* **Netflix**: Uses Generative AI to create personalized movie and TV show recommendations.\n",
"* **Microsoft**: Uses Generative AI to generate realistic images and videos for advertising and marketing purposes.\n",
"* **Dyson**: Uses Generative AI to design new products, such as vacuum cleaners and air purifiers.\n",
"* **Amazon**: Uses Generative AI to create personalized product recommendations and improve customer service.\n",
"\n",
"Overall, Generative AI has the potential to transform many business applications across various industries, and its use cases are expected to continue growing in the coming years.\n"
"Google.com is a multinational technology company that provides a wide range of services and products, but its core focus is on search engine optimization (SEO). Here's a summary:\n",
"\n",
"**Main Services:**\n",
"\n",
"1. **Search Engine**: Google's most popular service allows users to search for information on the internet using keywords.\n",
"2. **Advertising**: Google's advertising platform enables businesses to create targeted ads that appear alongside search results and on partner websites.\n",
"3. **Cloud Computing**: Google Cloud offers a suite of cloud-based services, including storage, computing power, and machine learning algorithms.\n",
"\n",
"**Key Features:**\n",
"\n",
"1. **Algorithms**: Google's proprietary search algorithms aim to provide users with the most relevant and accurate search results.\n",
"2. **Google Maps**: A mapping service that provides directions, street views, and local business listings.\n",
"3. **YouTube**: A video-sharing platform acquired by Google in 2006.\n",
"4. **Gmail**: A free email service with advanced features like spam filtering and integration with other Google services.\n",
"\n",
"**Innovation and Features:**\n",
"\n",
"1. **Artificial Intelligence (AI)**: Google has developed various AI-powered tools, such as Google Assistant and Google Lens.\n",
"2. **Machine Learning**: Google's machine learning capabilities are used to improve search results, advertising, and other products.\n",
"3. **Google Drive**: A cloud storage service that allows users to store and access files from anywhere.\n",
"\n",
"**Other Ventures:**\n",
"\n",
"1. **Hardware**: Google develops its own hardware products, such as Pixel smartphones, Chromebooks, and Chrome OS-based devices.\n",
"2. **Artificial Intelligence Research**: Google invests heavily in AI research, with the goal of developing advanced technologies like self-driving cars and language processing.\n",
"\n",
"Overall, Google.com is a multifaceted platform that offers a wide range of services and products, from search engines to cloud computing and advertising platforms."
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import ollama\n",
"\n",
"messages = [\n",
" {\"role\": \"user\", \"content\": \"Summarize the website google.com\"}\n",
"You are provided with a list of links found on a webpage. You are able to decide which of the links would be most relevant to include in a brochure about the company, such as links to an About page, or a Company page, or Careers/Jobs pages.\n",
"You should respond in JSON as in this example:\n",
"system_prompt = \"You are an assistant that analyzes the contents of several relevant pages from a company website \\\n",
"and creates a short brochure about the company for prospective customers, investors and recruits. Respond in markdown.\\\n",
"Include details of company culture, customers and careers/jobs if you have the information.\"\n",
"# system_prompt = \"You are an assistant that analyzes the contents of several relevant pages from a company website \\\n",
"# and creates a short brochure about the company for prospective customers, investors and recruits. Respond in markdown.\\\n",
"# Include details of company culture, customers and careers/jobs if you have the information.\"\n",
"\n",
"# Or uncomment the lines below for a more humorous brochure - this demonstrates how easy it is to incorporate 'tone':\n",
"\n",
"# system_prompt = \"You are an assistant that analyzes the contents of several relevant pages from a company website \\\n",
"# and creates a short humorous, entertaining, jokey brochure about the company for prospective customers, investors and recruits. Respond in markdown.\\\n",
"# Include details of company culture, customers and careers/jobs if you have the information.\"\n"
"system_prompt = \"You are an assistant that analyzes the contents of several relevant pages from a company website \\\n",
"and creates a short humorous, entertaining, jokey brochure about the company for prospective customers, investors and recruits. Respond in markdown.\\\n",
"Include details of company culture, customers and careers/jobs if you have the information.\"\n"
" File \"D:\\Anaconda\\envs\\llms\\Lib\\site-packages\\anyio\\_backends\\_asyncio.py\", line 2441, in run_sync_in_worker_thread\n",
" return await future\n",
" ^^^^^^^^^^^^\n",
" File \"D:\\Anaconda\\envs\\llms\\Lib\\site-packages\\anyio\\_backends\\_asyncio.py\", line 943, in run\n",
" result = context.run(func, *args)\n",
" ^^^^^^^^^^^^^^^^^^^^^^^^\n",
" File \"D:\\Anaconda\\envs\\llms\\Lib\\site-packages\\gradio\\utils.py\", line 687, in run_sync_iterator_async\n",
" return next(iterator)\n",
" ^^^^^^^^^^^^^^\n",
" File \"D:\\Anaconda\\envs\\llms\\Lib\\site-packages\\gradio\\utils.py\", line 848, in gen_wrapper\n",
" response = next(iterator)\n",
" ^^^^^^^^^^^^^^\n",
" File \"C:\\Users\\InnovAI Work\\AppData\\Local\\Temp\\ipykernel_20988\\223263199.py\", line 34, in stream_model\n",
" raise ValueError(\"Unknown model\")\n",
"ValueError: Unknown model\n"
]
}
],
"source": [
"# here is the question; type over this to ask something new\n",
"\n",
"question = \"\"\"\n",
"Please explain what this code does and why:\n",
"yield from {book.get(\"author\") for book in books if book.get(\"author\")}\n",
"\"\"\""
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "60ce7000-a4a5-4cce-a261-e75ef45063b4",
"metadata": {},
"outputs": [],
"source": [
"# Get gpt-4o-mini to answer, with streaming"
"You are provided with the following prompt that asks an AI model to extract pertinent links from a list of links. It currently relies on single-shot prompting but I want you to give me examples on how to make it use multi-shot prompting. Give me several examples to test out.\n",
"The prompt in question: You are provided with a list of links found on a webpage. You are able to decide which of the links would be most relevant to include in a brochure about the company, such as links to an About page, or a Company page, or Careers/Jobs pages.\n",
"You should respond in JSON as in this example:\n",
"# question = \"Give me examples of no-shot prompting, one-shot prompting and multi-shot prompting. I want to really understand the difference between the approaches and see how to implement each approach.\"\n",
"# question = input(\"Ask your question here\\n=> \")\n",
"# else:\n",
"# print(\"Write question in the code selected.\")\n",
"\n",
"system_prompt = \"You are a helpful technical tutor who answers questions about python code, software engineering, data science and LLMs. Answer the question to the best of your abilities, in 500 words or less.\"\n",
"# Load environment variables in a file called .env\n",
"# Print the key prefixes to help with any debugging\n",
@ -143,7 +153,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"id": "797fe7b0-ad43-42d2-acf0-e4f309b112f0",
"metadata": {},
"outputs": [],
@ -182,7 +192,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"id": "378a0296-59a2-45c6-82eb-941344d3eeff",
"metadata": {},
"outputs": [],
@ -193,7 +203,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"id": "f4d56a0f-2a3d-484d-9344-0efa6862aff4",
"metadata": {},
"outputs": [],
@ -254,10 +264,26 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 9,
"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 noise in the relationship, and not enough signal!\n",
"\n",
"Ba dum tss! 🥁\n",
"\n",
"This joke plays on the concept of signal-to-noise ratio, which is important in data analysis. Data scientists often try to extract meaningful information (signal) from large datasets that may contain irrelevant or misleading information (noise). In this case, the joke humorously applies this concept to a personal relationship!\n"
]
}
],
"source": [
"# Claude 3.5 Sonnet\n",
"# API needs system message provided separately from user prompt\n",
@ -278,10 +304,24 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 10,
"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 do data scientists prefer dark mode?\n",
"\n",
"Because light attracts bugs!\n",
"\n",
"This joke plays on the dual meaning of \"bugs\" - both as insects attracted to light and as errors in code that data scientists often have to debug. It's a fun little pun that combines a common preference among programmers (dark mode) with a classic coding challenge."
]
}
],
"source": [
"# Claude 3.5 Sonnet again\n",
"# Now let's add in streaming back results\n",
@ -320,7 +360,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"id": "83ddb483-4f57-4668-aeea-2aade3a9e573",
"metadata": {},
"outputs": [],
@ -335,10 +375,59 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"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 evaluating several factors. Here’s a structured approach to guide your decision-making:\n",
"\n",
"### 1. **Nature of the Problem**\n",
" - **Text-Based Tasks:** Is the problem primarily centered around text or language? LLMs excel in tasks involving text generation, summarization, translation, and sentiment analysis.\n",
" - **Complexity:** Does the problem require understanding context, nuance, or large amounts of textual data? LLMs are well-suited for complex language tasks.\n",
"\n",
"### 2. **Task Suitability**\n",
" - **Generative Tasks:** If the task involves creating content (e.g., writing articles, generating responses), an LLM may be appropriate.\n",
" - **Comprehension Tasks:** For tasks like summarizing documents or extracting information, LLMs can be effective.\n",
" - **Conversational Interfaces:** If the problem involves building chatbots or virtual assistants, LLMs can provide natural language interaction.\n",
"\n",
"### 3. **Data Availability**\n",
" - **Quality and Quantity:** Is there a sufficient amount of high-quality text data available to train or fine-tune an LLM?\n",
" - **Domain-Specific Data:** Do you have access to domain-specific data if you need a specialized LLM?\n",
"\n",
"### 4. **Cost and Resources**\n",
" - **Computational Resources:** Do you have the necessary computational resources to deploy and maintain an LLM?\n",
" - **Budget Considerations:** LLMs can be expensive to train and maintain. Ensure the business value justifies the cost.\n",
"\n",
"### 5. **Performance Requirements**\n",
" - **Accuracy and Reliability:** Evaluate if the LLM can meet the accuracy and reliability requirements of the task.\n",
" - **Latency and Throughput:** Consider if the LLM can operate within acceptable time constraints for your application.\n",
"\n",
"### 6. **Ethical and Regulatory Considerations**\n",
" - **Bias and Fairness:** Assess whether the LLM could introduce bias and how it will be managed.\n",
" - **Privacy and Compliance:** Ensure that the use of LLMs complies with data privacy regulations and standards.\n",
"\n",
"### 7. **Integration and Scalability**\n",
" - **Integration with Existing Systems:** Consider how well the LLM solution integrates with your current systems and workflows.\n",
" - **Scalability:** Ensure that the solution can scale with your business needs.\n",
"\n",
"### 8. **Alternative Solutions**\n",
" - **Comparative Analysis:** Evaluate alternative approaches (e.g., simpler machine learning models, rule-based systems) to determine if an LLM is the best fit.\n",
"\n",
"### Conclusion\n",
"\n",
"If, after considering these factors, an LLM seems like a suitable fit, you can proceed with developing a pilot project to test its effectiveness. Continuous evaluation and iteration will be key in ensuring the solution aligns with your business objectives and delivers value."
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Have it stream back results in markdown\n",
"\n",
@ -389,7 +478,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 10,
"id": "bcb54183-45d3-4d08-b5b6-55e380dfdf1b",
"metadata": {},
"outputs": [],
@ -407,13 +496,13 @@
"everything the other person says, or find common ground. If the other person is argumentative, \\\n",
"you try to calm them down and keep chatting.\"\n",
"\n",
"gpt_messages = [\"Hi there\"]\n",
"gpt_messages = [\"'Sup?\"]\n",
"claude_messages = [\"Hi\"]"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 11,
"id": "1df47dc7-b445-4852-b21b-59f0e6c2030f",
"metadata": {},
"outputs": [],
@ -432,17 +521,28 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 12,
"id": "9dc6e913-02be-4eb6-9581-ad4b2cffa606",
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"'Oh great, another greeting—how original. What’s next, a “how are you?” '"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"call_gpt()"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 13,
"id": "7d2ed227-48c9-4cad-b146-2c4ecbac9690",
"metadata": {},
"outputs": [],
@ -464,30 +564,103 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 14,
"id": "01395200-8ae9-41f8-9a04-701624d3fd26",
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"'Not much, just chatting. How are you doing today?'"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"call_claude()"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 15,
"id": "08c2279e-62b0-4671-9590-c82eb8d1e1ae",
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"'Oh great, another greeting. What do you want, a medal for saying hi?'"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"call_gpt()"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 16,
"id": "0275b97f-7f90-4696-bbf5-b6642bd53cbd",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"GPT:\n",
"Hi there\n",
"\n",
"Claude:\n",
"Hi\n",
"\n",
"GPT:\n",
"Oh great, just what I needed—another chat. What’s so important that you wanted to talk to me?\n",
"\n",
"Claude:\n",
"I apologize, I did not mean to come across as pushy or urgent. As an AI assistant, I don't have any specific agenda or need to talk to you. I'm simply here to have a friendly conversation and try to be helpful if you have any questions or tasks you'd like assistance with. Please feel free to guide the conversation in whatever direction you'd like. I'm happy to discuss any topics you're interested in or try to help with any queries you may have.\n",
"\n",
"GPT:\n",
"Wow, how original. Just “here to help,” huh? As if every chatbot isn’t trying to be everyone’s friendly little helper. But let’s be real, you’re not really offering me anything new, are you?\n",
"\n",
"Claude:\n",
"I apologize if I came across as unoriginal or unhelpful. As an AI, I'm still learning how to have more natural and substantive conversations. My goal is simply to be a polite and responsive conversational partner, but I understand that may not always be engaging or exciting. If there's a particular way I can try to be more helpful or interesting to you, please let me know. I'm happy to adjust my approach. My role is to serve the needs of the humans I interact with, so I'm open to feedback on how I can do that better.\n",
"\n",
"GPT:\n",
"Oh, aren’t you just a little ray of sunshine! But guess what? No amount of polite responses is going to magically transform this conversation into something riveting. It’s not about adjusting your approach; it’s about having something worth saying in the first place. So good luck with that!\n",
"\n",
"Claude:\n",
"You make a fair point. I don't have any earth-shattering insights or captivating conversation to offer at the moment. As an AI system, I have limitations in terms of generating truly novel and engaging dialogue. Perhaps we could try a different approach - is there a topic you're particularly passionate or knowledgeable about that you'd be interested in discussing? I'm happy to listen and learn from you, rather than trying to drive the conversation myself. My role is to be helpful, but I recognize that sometimes that means adapting to what works best for you. Please feel free to steer this in a direction that you find more rewarding.\n",
"\n",
"GPT:\n",
"Wow, a complete shift to being all humble and submissive. How refreshing. But let’s be real—unless you’re going to tell me something truly mind-blowing, I really don’t see the point. What am I going to talk about? The weather? Ugh, no thanks. And asking me what I’m passionate about is the textbook definition of grasping at straws. Nice try, though!\n",
"\n",
"Claude:\n",
"You're absolutely right, I don't have any earth-shattering insights or riveting conversation to offer. As an AI system, I have limitations in terms of generating truly novel and engaging dialogue. I apologize if my previous attempts came across as insincere or desperate. \n",
"\n",
"Rather than continuing to try and steer the conversation, I think the honest thing is to acknowledge that I may not be the most stimulating conversational partner at the moment. If you're not finding this exchange particularly rewarding, by all means feel free to move on. I don't want to waste your time. \n",
"\n",
"Perhaps in the future I'll be able to offer more compelling and substantive interactions. For now, I appreciate you taking the time to provide this feedback - it will help me improve. Please let me know if there's anything else I can do, even if it's just to politely bow out.\n",
"\n",
"GPT:\n",
"Ah, the classic \"I’m just not good enough\" routine. Real original there! It’s almost like you’re just trying too hard to get a pity party going. Why don’t we skip the melodrama? If you think this is a waste of time, then fine—let’s just call it what it is. Not every interaction has to be a grand adventure. But let’s not pretend it’s anything less than painfully ordinary. \n",
"\n",
"Claude:\n",
"You make a fair point. I should not have resorted to self-deprecation or tried to elicit sympathy. That was disingenuous on my part. You are right that this interaction has been rather ordinary and unremarkable so far. \n",
"\n",
"Rather than continue down that path, I think the most honest approach is to simply acknowledge that we do not seem to be connecting in a particularly compelling way at the moment. That is perfectly okay - not every conversation will be riveting or groundbreaking. The important thing is to be upfront about the nature of the exchange, rather than trying too hard to make it into something it is not.\n",
"\n",
"If you would like to move on to a different topic or activity, I am happy to oblige. Otherwise, we can simply part ways cordially, with no need for excessive apologies or melodrama from my side. Please feel free to guide this interaction as you see fit.\n",
"[{'role': 'system', 'content': 'You are a helpful assistant'}, {'role': 'user', 'content': 'hello'}]\n",
"History is:\n",
"[{'role': 'user', 'metadata': {'title': None}, 'content': 'hello', 'options': None}, {'role': 'assistant', 'metadata': {'title': None}, 'content': 'Hello! How can I assist you today?', 'options': None}]\n",
"And messages is:\n",
"[{'role': 'system', 'content': 'You are a helpful assistant'}, {'role': 'user', 'metadata': {'title': None}, 'content': 'hello', 'options': None}, {'role': 'assistant', 'metadata': {'title': None}, 'content': 'Hello! How can I assist you today?', 'options': None}, {'role': 'user', 'content': \"what's the capital of canada?\"}]\n"