Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon

How-To Tutorials

7019 Articles
article-image-ab-testing-for-marketing-comparison-using-openai-chatgpt
Valentina Alto
08 Jun 2023
5 min read
Save for later

A/B testing for marketing comparison using OpenAI ChatGPT

Valentina Alto
08 Jun 2023
5 min read
This article is an excerpt from the book, Modern Generative AI with ChatGPT and OpenAI Models, by Valentina Alto. This book will help harness the power of AI with innovative, real-world applications, and unprecedented productivity boosts, powered by the latest advancements in AI technology like ChatGPT and OpenAI.A/B testing in marketing is a method of comparing two different versions of a marketing campaign, advertisement, or website to determine which one performs better. In A/B testing, two variations of the same campaign or element are created, with only one variable changed between the two versions. The goal is to see which version generates more clicks, conversions, or other desired outcomes.An example of A/B testing might be testing two versions of an email campaign, using different subject lines, or testing two versions of a website landing page, with different call-to-action buttons. By measuring the response rate of each version, marketers can determine which version performs better and make data-driven decisions about which version to use going forward. A/B testing allows marketers to optimize their campaigns and elements for maximum effectiveness, leading to better results and a higher return on investment.Since this method involves the process of generating many variations of the same content, the generative power of ChatGPT can definitely assist in that.Let’s consider the following example. I’m promoting a new product I developed: a new, light and thin climbing harness for speed climbers. I’ve already done some market research and I know my niche audience. I also know that one great channel of communication for that audience is publishing on an online climbing blog, of which most climbing gyms’ members are fellow readers.My goal is to create an outstanding blog post to share the launch of this new harness, and I want to test two different versions of it in two groups. The blog post I’m about to publish and that I want to be the object of my A/B testing is the following:  Figure 1– An example of a blog post to launch climbing gearHere, ChatGPT can help us on two levels:The first level is that of rewording the article, using different keywords or different attention-grabbing slogans. To do so, once this post is provided as context, we can ask ChatGPT to work on the article and slightly change some elements:Figure 2 – New version of the blog post generated by ChatGPT As per my request, ChatGPT was able to regenerate only those elements I asked for (title, subtitle, and closing sentence) so that I can monitor the effectiveness of those elements by monitoring the reaction of the two audience groups.The second level is working on the design of the web page, namely, changing the collocation of the image rather than the position of the buttons. For this purpose, I created a simple web page for the blog post published in the climbing blog (you can find the code in the book’s GitHub repository at https://github.com/PacktPublishing/The-Ultimate-Guide- to-ChatGPT-and-OpenAI/tree/main/Chapter%207%20-%20ChatGPT%20 for%20Marketers/Code):Figure 3 – Sample blog post published on the climbing blogWe can directly feed ChatGPT with the HTML code and ask it to change some layout elements, such as the position of the buttons or their wording. For example, rather than Buy Now, a reader might be more gripped by an I want one! button.So, let's feed ChatGPT with the HTML source code:Figure 4 – ChatGPT changing HTML code Let’s see what the output looks like:Figure 5 – New version of the websiteAs you can see, ChatGPT only intervened at the button level, slightly changing their layout, position, color, and wording.Indeed, inspecting the source code of the two versions of the web pages, we can see how it differs in the button sections:Figure 6 – Comparison between the source code of the two versions of the website ConclusionIn conclusion, ChatGPT is a valuable tool for A/B testing in marketing. Its ability to quickly generate different versions of the same content can reduce the time to market of new campaigns. By utilizing ChatGPT for A/B testing, you can optimize your marketing strategies and ultimately drive better results for your business.Author BioAfter completing her Bachelor's degree in Finance, Valentina Alto pursued a Master's degree in Data Science in 2021. She began her professional career at Microsoft as an Azure Solution Specialist, and since 2022, she has been primarily focused on working with Data & AI solutions in the Manufacturing and Pharmaceutical industries. Valentina collaborates closely with system integrators on customer projects, with a particular emphasis on deploying cloud architectures that incorporate modern data platforms, data mesh frameworks, and applications of Machine Learning and Artificial Intelligence. Alongside her academic journey, she has been actively writing technical articles on Statistics, Machine Learning, Deep Learning, and AI for various publications, driven by her passion for AI and Python programming.Link - Medium Modern Generative AI with ChatGPT and OpenAI Models
Read more
  • 0
  • 0
  • 129

article-image-integrating-chatgpt-api-with-microsoft-office
Martin Yanev
07 Jun 2023
6 min read
Save for later

Integrating ChatGPT API with Microsoft Office

Martin Yanev
07 Jun 2023
6 min read
In this article, we will explore how to set up a PyCharm project and install the docx Python library to extract text from Word documents. The docx library is a Python package that allows us to read and write Microsoft Word ( .docx) files and provides a convenient interface to access information stored in these files. The first step is to initiate your work by creating a new PyCharm project. This will enable you to have a dedicated area to craft and systematize your Translation app code.  Open PyCharm IDE on your systemClick on Create New Project from the welcome screen or go to File | New Project if you're already in the IDE Keep the default settingGive your project the name Translation AppClick on Create to create the project To run the language translation desktop app, you will need to install the following libraries:  openai: The  openai library allows you to interact with the OpenAI API and perform various natural language processing tasks.  docx: The  docx library allows you to read and write Microsoft Word files  .docx using Python.  tkinter: The  tkinter library is a built-in Python library that allows you to create graphical user interfaces (GUIs) for your desktop app.   As  tkinter is a built-in library, there is no need for installation since it already exists within your Python environment. To install the  openai and  docx libraries, access the PyCharm terminal by clicking on View | Tool Windows | Terminal, and then execute the following commands:  pip install openai pip install python-docx   To access and read the contents of a Word document, you will need to create a sample Word file inside your PyCharm project. Here are the steps to create a new Word file in PyCharm:  In PyCharm project create a new directory called files Right-click on the files folder and select New | File In the dialog box that appears, enter a file name with the extension .docx. For example, info.doc.  Select the Enter key to create the file Once the file is created, double-click on it to open it You can now add some text or content to this file, which we will later access and read using the docx library in Python. For this example, we have created an article about on New York City. However, you can choose any Word document containing text that you want to analyze.  The United States' most populous city, often referred to as New York City or NYC, is New York. In 2020, its population reached 8,804,190 people across 300.46 square miles, making it the most densely populated major city in the country and over two times more populous than the nation's second-largest city, Los Angeles. The city's population also exceeds that of 38 individual U.S. states. Situated at the southern end of New York State, New York City serves as the Northeast megalopolis and New York metropolitan area's geographic and demographic center - the largest metropolitan area in the country by both urban area and population. Over 58 million people also live within 250 miles of the city. A significant influencer on commerce, health care and life sciences, research, technology, education, politics, tourism, dining, art, fashion, and sports, New York City is a global cultural, financial, entertainment, and media hub. It houses the headquarters of the United Nations, making it a significant center for international diplomacy, and is often referred to as the world's capital.  Now that you have created the Word file inside your PyCharm project, you can move on to the next step, which is to create a new Python file called app.py inside the Translation App root directory. This file will contain the code to read and manipulate the contents of the Word file using the docx library. With the Word file and the Python file in place, you are ready to start writing the code to extract data from the document and use it in your application. To test if we can read word files with the docx Python library, we can implement the subsequent code in our app.py file:  Import docx  doc = docx.Document(“<full_path_to_docx_file>”)  text = “”  for para in doc.paragraphs:  text += para.text  print(text)  Make sure to replace the <full_path_to_docx_file> with the actual path to your Word document file. Obtaining the file path is a simple task, achieved by Right Click on your docx file in PyCharm and selecting the option Copy Path/Reference… from the drop-down menu.  Once you have done that, run the app.py file and verify the output. This code will read the contents of your Word document and print them to the Run Window console. If the text extraction works correctly, you should see the text of your document printed in the console (see figure below). The text variable now holds the data from the info.docx as a Python string.   Figure: Word text extraction console output SummaryThis section provided a step-by-step guide on how to set up a PyCharm project and install the docx Python library to extract text from Word documents. The section also included instructions on how to create a new Word file in PyCharm and use the docx library to read and manipulate its contents using Python.  Author BioMartin Yanev is an experienced Software Engineer who has worked in the aerospace and medical industries for over 8 years. He specializes in developing and integrating software solutions for air traffic control and chromatography systems. Martin is a well-respected instructor with over 280,000 students worldwide, and he is skilled in using frameworks like Flask, Django, Pytest, and TensorFlow. He is an expert in building, training, and fine-tuning AI systems with the full range of OpenAI APIs. Martin has dual master's degrees in Aerospace Systems and Software Engineering, which demonstrates his commitment to both practical and theoretical aspects of the industry. https://www.linkedin.com/in/martinyanev/https://www.udemy.com/user/martin-yanev-3/ 
Read more
  • 0
  • 0
  • 231

article-image-audio-summarize-any-youtube-video-with-python-chatgpt-and-aws
Andrei Gheorghiu
07 Jun 2023
8 min read
Save for later

Audio Summarize Any YouTube Video with Python, ChatGPT, and AWS

Andrei Gheorghiu
07 Jun 2023
8 min read
IntroductionHave you ever wished you could just listen to the summary of a long YouTube video instead of watching the whole thing? Well, you're in luck! In this article, I’ll be showcasing a fun little Python project that I’ve been working on, which allows you to do just that.Don’t get me wrong: YouTube is a great resource for learning about new technologies and keeping you up to date with the latest news. And best of all: it’s free. But sometimes, I tend to lose track of time in the myriad of videos out there, fast forwarding through long talks only to find out in the end that the information I’m looking for is not in the video ☹Well, if you often find yourself in a similar situation, here’s a potential tool you might like. This little script downloads the audio from a YouTube video, transcribes it, summarizes it using AI and finally generates a new audio file with the summary. And all this magic is done using the OpenAI GPT-3.5-turbo API and some cool AWS services (S3, Transcribe, and Polly). In less than 80 lines of code.For those who might be unfamiliar with these APIs, here is their purpose in the script:OpenAI's GPT-3.5-turbo provides programmatic access to the same advanced language model used by ChatGPT. Its purpose in the script is summarizing the transcribed video content.AWS S3 is a storage service where we temporarily store the audio file from the YouTube video and the transcript. We have to use an S3 bucket because it is required by AWS Transcribe and AWS Polly.AWS Transcribe is used to convert the audio file into text.AWS Polly is a service that turns text into lifelike speech. We use it to generate an audio file of the summary.Logic Diagram DisclaimerBefore you start using these services, be aware that both AWS and OpenAI have usage quotas and costs associated with them. Make sure to familiarize yourself with these to avoid any unexpected charges. You’ll probably fall well within the limits of your Amazon account’s free tier unless you start summarizing hundreds of videos.Also, you might consider adding error handling in the code. To keep it short I’ve skipped it from this demo.You can download the Python file for this code from GitHub here.Configuring the APIsMake sure you store your OpenAI API Key and AWS Credentials in your local environment variables for secure and efficient access. The code works on the assumption that both the OpenAI API keys and AWS credentials are valid and have been already stored on your local environment variables. Alternatively, you can store your AWS ACCESS KEY and SECRET ACCESS KEY in %USERPROFILE%\.aws\credentialsMore info on that here: https://docs.aws.amazon.com/sdkref/latest/guide/creds-config-files.htmlFor the code to function properly make sure the AWS credentials you are using have the following permissions:AmazonS3FullAccess: This is required to create and delete S3 buckets, upload files to the buckets and delete objects within the buckets.AmazonTranscribeFullAccess: This is needed to start transcription jobs and get the transcription job results.AmazonPollyFullAccess: This is necessary to synthesize speech from text.The most convenient and safe approach to grant the necessary permissions is though the AWS Management Console by attaching the relevant policies to the user or role associated with the credentials. RequirementsI’ve used Python v3.11. Make sure you first install all the requirements or update them to the latest version if already installed.pip install pytube pip install openai pip install boto3 pip install requests pip install python-dotenvThe CodeLet’s break it down snippet by snippet. Setup and Import Statementsimport os import boto3 import requests import openai import uuid from pytube import YouTube Downloading the Audio from YouTubeThe download_audio function uses the pytube library to download the audio from a YouTube video. The audio file is saved locally before being uploaded to S3 by the main function. Here’s a complete documentation for pytube: https://pytube.io/en/latest/def download_audio(video_id): yt = YouTube(f'https://www.youtube.com/watch?v={video_id}') return yt.streams.get_audio_only().download(filename=video_id) Transcribing Audio to TextThe transcribe_audio function uses AWS Transcribe to convert the audio into text. The UUID (Universally Unique Identifier) module is used to generate a unique identifier for each transcription job. The benefit of using UUIDs here is that every time we run the function, a new unique job name is created. This is important because AWS Transcribe requires job names to be unique. Here’s the complete documentation of AWS Transcribe: https://docs.aws.amazon.com/transcribe/latest/dg/what-is.htmldef transcribe_audio(s3, bucket, file_name): transcribe = boto3.client('transcribe') job_name = f"TranscriptionJob-{uuid.uuid4()}" transcribe.start_transcription_job( TranscriptionJobName=job_name, Media={'MediaFileUri': f"s3://{bucket}/{file_name}"}, MediaFormat='mp4', LanguageCode='en-US' ) while True: status = transcribe.get_transcription_job(TranscriptionJobName=job_name) if status['TranscriptionJob']['TranscriptionJobStatus'] in ['COMPLETED', 'FAILED']: break return status['TranscriptionJob']['Transcript']['TranscriptFileUri'] if status['TranscriptionJob']['TranscriptionJobStatus'] == 'COMPLETED' else None Summarizing the TranscriptThe summarize_transcript function leverages OpenAI's GPT-3.5-turbo to summarize the transcript. Notice the simple prompt I’ve used for this task. I’ve tried to keep it very short in order to save more tokens for the actual transcript. It can definitely be improved and tweaked according to your preferences. For a complete documentation of the OpenAI API check out this link: https://platform.openai.com/docs/api-reference/introductiondef summarize_transcript(transcript): response = openai.ChatCompletion.create( model="gpt-3.5-turbo", messages=[ {"role": "system", "content": "You are a knowledge curator helping users to understand the contents of video transcripts."}, {"role": "user", "content": f"Please summarize the following transcript: '{transcript}'"} ] ) return response['choices'][0]['message']['content'].strip() Synthesizing Speech from TextThe synthesize_speech function uses AWS Polly to convert the summarized text back into audio. If you prefer other voices or want to tweak different parameters such as speed, language, or dialect, here’s the complete documentation on how to use Polly: https://docs.aws.amazon.com/polly/index.htmldef synthesize_speech(s3, bucket, transcript_uri): transcript_data = requests.get(transcript_uri).json() transcript = ' '.join(item['alternatives'][0]['content'] for item in transcript_data['results']['items'] if item['type'] == 'pronunciation') summary = summarize_transcript(transcript) summary_file_name = f"summary_{uuid.uuid4()}.txt" s3.put_object(Body=summary, Bucket=bucket, Key=summary_file_name) polly = boto3.client('polly') response = polly.synthesize_speech(OutputFormat='mp3', Text=summary, VoiceId='Matthew', Engine='neural') mp3_file_name = f"speech_{uuid.uuid4()}.mp3" with open(mp3_file_name, 'wb') as f: f.write(response['AudioStream'].read()) return mp3_file_name The Clean-up of the S3 BucketTo keep our storage in check and avoid littering the cloud, it’s best to clean up all objects from the bucket. We’ll be able to delete the bucket completely once the audio summary has been downloaded locally.Remember, we only needed the S3 bucket because it was required by AWS Transcribe and Polly.def delete_all_objects(bucket_name): s3 = boto3.resource('s3') bucket = s3.Bucket(bucket_name) bucket.objects.all().delete() The Main FunctionAnd finally, the main function, which ties everything together. It specifies the YouTube video to summarize (which you can obviously change to any another video ID), sets up the necessary AWS services and calls the functions defined above in the correct order. It also makes sure to clean up by deleting the S3 bucket after use.def main(): video_id = 'U3PiD-g7XJM' #change to any other Video ID from YouTube bucket = f"bucket-{uuid.uuid4()}" file_name = f"{video_id}.mp4" openai.api_key = os.getenv('OPENAI_API_KEY') s3 = boto3.client('s3') s3.create_bucket(Bucket=bucket) print ("Downloading audio stream from youtube video...") audio_file = download_audio(video_id) print ("Uploading video to S3 bucket...") s3.upload_file(audio_file, bucket, file_name) print("Transcribing audio...") transcript_uri = transcribe_audio(s3, bucket, file_name) print("Synthesizing speech...") mp3_file_name = synthesize_speech(s3, bucket, transcript_uri) print(f"Audio summary saved in: {mp3_file_name}\n") delete_all_objects(bucket) s3.delete_bucket(Bucket=bucket) if __name__ == "__main__": main() And that's it! With this simple tool you can now convert any YouTube video into a summarized audio file.So, sit back, relax and let AI do the work for you.Enjoy! About the AuthorAndrei Gheorghiu is an experienced trainer with a passion for helping learners achieve their maximum potential. He always strives to bring a high level of expertise and empathy to his teaching.With a background in IT audit, information security, and IT service management, Andrei has delivered training to over 10,000 students across different industries and countries. He is also a Certified Information Systems Security Professional and Certified Information Systems Auditor, with a keen interest in digital domains like Security Management and Artificial Intelligence.In his free time, Andrei enjoys trail running, photography, video editing and exploring the latest developments in technology.You can connect with Andrei on:LinkedIn: https://www.linkedin.com/in/gheorghiu/Twitter: https://twitter.com/aqg8017
Read more
  • 0
  • 0
  • 1050

article-image-falcon-llm-the-dark-horse-in-open-source-llm-race
Valentina Alto
07 Jun 2023
6 min read
Save for later

Falcon LLM: The Dark Horse in Open Source LLM Race

Valentina Alto
07 Jun 2023
6 min read
Discover the ground-breaking capabilities of the Falcon Language Model (LLM) in natural language processing. This article presents an architectural overview of Falcon LLM, highlighting its transformer-based design and distinctive features. Gain practical guidance on leveraging Falcon LLM's power effectively, including fine-tuning techniques and optimization strategies. We also address ethical considerations and responsible AI deployment. Whether you're a researcher, developer, or simply curious about cutting-edge language models, this article provides valuable insights to harness the full potential of Falcon LLM.Foundation models and LLMsWhen we talk about Generative AI models, we are talking about a new generation of deep learning models called Foundation models. Foundation models are pre-trained AI models that can be fine-tuned for specific tasks.Foundational Models In the specific case of ChatGPT and similar models, we talk about Large language models (LLMs), a subset of Foundation models specifically designed for natural language processing tasks. Models like GPT-4 are examples of LLMs that can generate human-like text, answer questions, translate languages, and more.LLMs are characterized by huge training sets and a number of parameters of the network. To make an example, GPT-3 has been trained on almost 500 billion tokens and has 175 billion parameters. However, models with such a high number of parameters are heavy, both in the training phase and inference phase. This also implies a high computational cost, being needed GPU-powered hardware, and a lot of training time. That’s why a new trend has emerged lately, that is the one of building lighter models (with fewer parameters) focusing rather on the quality of the training dataset.Introducing Falcon LLMOne of the latest models of this new trend is Falcon LLM, an open-source model launched by Abu Dhabi’s Technology Innovation Institute (TII) that as of now (June 2023) ranks 1 globally in the latest Hugging Face independent verification of open-source AI models: Open LLM Leaderboard — a Hugging Face Space by HuggingFaceH4Falcon LLM has been trained on 1 trillion tokens and has 40 billion parameters (even though it has also been released a lighter version with 7 billion parameters). So the question might be: how can a model with “only” 40 billion parameters perform so well? In fact, the answer is in the quality of the dataset.Falcon was developed using specialized tools and incorporates a unique data pipeline capable of extracting valuable content from web data. The pipeline was designed to extract high-quality content by employing extensive filtering and deduplication techniques.The resulting dataset, called RefinedWeb, has been released by TII under the Apache-2.0 license and can be found here →https://huggingface.co/datasets/tiiuae/falcon-refinedweb.Plus, the architecture of Falcon was meticulously fine-tuned for optimal performance and efficiency. By combining superior data quality with these optimizations, Falcon achieves remarkable performance while utilizing around 75% of the training compute budget of the GPT-3. Furthermore, it requires only a fifth of the computing resources during inference.A decoder-only (Falcon LLM) architectureFalcon LLM is a decoder-only model, but what does it mean?Source: https://arxiv.org/abs/1706.03762 The Encoder-Decoder architecture was the original transformer architecture introduced in the Attention Is All You Need (https://arxiv.org/abs/1706.03762) paper in 2017. We have the “encoder”, which has the task to represent the input into a lower-dimensional space; on the right-hand side, we have the “decoder”, which has the task to translate back to the original data format the lower-dimensional data provided by the encoder.While the original transformer architecture was made of both the components — encoder and decoder, in last years, AI labs and companies shifted towards a new architecture made of a decoder-only framework. To name one example, the OpenAI’s GPT-3 is made of a decoder-only architecture.The key distinction between the Decoder-only architecture and the Encoder-Decoder architecture lies in the absence of a separate encoder responsible for summarizing the input information. Instead, in the Decoder-only architecture, the decoder’s hidden state implicitly encodes the relevant information and is continually updated at each step of the generation process.How to use Falcon LLMAs it is an open-source model, you can try Falcon LLM directly from the frontend provided on the Hugging Face site:Hugging face frontendPlus, you can download the model using Python:!pip install torch from transformers import AutoTokenizer, AutoModelForCausalLM import transformers import torch #model = "tiiuae/falcon-40b" model = "tiiuae/falcon-7b" tokenizer = AutoTokenizer.from_pretrained(model) pipeline = transformers.pipeline(    "text-generation",    model=model,    tokenizer=tokenizer,    torch_dtype=torch.bfloat16,    trust_remote_code=True,    device_map="auto", ) sequences = pipeline(   "Girafatron is obsessed with giraffes, the most glorious animal on the face of this Earth. Giraftron believes all other animals are irrelevant when compared to the glorious majesty of the giraffe.\nDaniel: Hello, Girafatron!\nGirafatron:",    max_length=200,    do_sample=True,    top_k=10,    num_return_sequences=1,    eos_token_id=tokenizer.eos_token_id, ) for seq in sequences:    print(f"Result: {seq['generated_text']}")Depending on your hardware capacity, you can decide to use either the 40b or the 7b parameters model. Also, note that the 7b version of the model is trained in English and French only.ConclusionsLLMs are extremely powerful, and they have seen an exponential growth in their number of parameters in the last few years. Nevertheless, we are quickly approaching towards a hard cap that is the computational capacity needed. Henceforth, it is pivotal to start exploring new ways of making LLMs less “large” yet more accurate, as TII is achieving with Falcon LLM. This implies a major focus on the quality of the training set, which massively impacts on the performance of the model.Falcon LLM paper will be released soon, so stay tuned to learn more about this amazing model!Referenceshttps://huggingface.co/datasets/tiiuae/falcon-refinedwebhttps://falconllm.tii.ae/Open LLM Leaderboard — a Hugging Face Space by HuggingFaceH4Author BioValentina Alto graduated in 2021 in data science. Since 2020, she has been working at Microsoft as an Azure solution specialist, and since 2022, she has been focusing on data and AI workloads within the manufacturing and pharmaceutical industries. She has been working closely with system integrators on customer projects to deploy cloud architecture with a focus on modern data platforms, data mesh frameworks, IoT and real-time analytics, Azure Machine Learning, Azure Cognitive Services (including Azure OpenAI Service), and Power BI for dashboarding. Since commencing her academic journey, she has been writing tech articles on statistics, machine learning, deep learning, and AI in various publications and has authored a book on the fundamentals of machine learning with Python.Valentina is also the author of the book: Modern Generative AI with ChatGPT and OpenAI ModelsLinks - Medium LinkedIn  
Read more
  • 0
  • 0
  • 528
Banner background image

article-image-ai-distilled-2-google-gen-ai-search-engine-microsoft-fabric-nvidia-dgx-supercomputer-google-matcha-succeed-in-ai
Merlyn Shelley
05 Jun 2023
10 min read
Save for later

AI_Distilled #2: Google Gen AI Search Engine, Microsoft Fabric, NVIDIA DGX Supercomputer, Google MatCha, Succeed in AI

Merlyn Shelley
05 Jun 2023
10 min read
“AI is going to touch literally every single industry. While some worry that AI may take their jobs, someone who’s expert with AI will." - Jensen Huang, Founder and CEO, NVIDIA In a world where AI revolutionizes all industries, fears of job loss fade when you become an AI expert. Embrace the power of AI to unlock boundless opportunities and shape the future!  Welcome to the second issue of AI_Distilled newsletter — your essential guide to the latest developments in AI/ML, LLMs, GPT, NLP, and Generative AI! In this edition, we’ll start with the latest AI buzz, including Google’s newly launched AI search engine, the unveiling of Microsoft Fabric — a new analytics platform for the AI era, NVIDIA’s cutting-edge DGX supercomputer, scientists’ breakthrough discovery of a lifesaving antibiotic using AI, and Microsoft’s recently released report on AI governance proposing “safety brakes” to ensure critical AI always remain under human control. We’ve also got you your fresh dose of AI secret knowledge and tutorials. The AI Product Manager's Handbook, Building your own LLM-powered chatbot in 5 minutes with HugChat and Streamlit, see how Google’s MatCha revolutionizes Computer understanding of Visual Language and Chart Reasoning, and discover why self-healing software could become a tangible reality in the era of LLMs.  What do you think of this issue and our newsletter? Please consider taking the short survey below to share your thoughts and you will get a free PDF of the “The Applied Artificial Intelligence Workshop” eBook upon completion. Complete the Survey. Get a Packt eBook for Free! Writer’s Credit: Special shout-out to Vidhu Jain for their valuable contribution to this week’s newsletter content! Cheers, Merlyn Shelley, Editor-in-Chief, Packt  ⚡ TechWave: AI/GPT News & Analysis Google Launches its New AI Search Engine: Google has opened access to its new generative AI search capabilities, called Search Labs, the new program lets you access early experiments from Google. Sign up for the waitlist and start testing new Labs experiments, including SGE (Search Generative Experience), Code Tips and Add to Sheets. The enhanced search experience simplifies the search process, helping you grasp a topic more quickly, discover fresh perspectives and valuable insights, and accomplish tasks with greater ease. Microsoft Build Unveils AI-powered Shift in Technology Space: Microsoft Build, the annual flagship event for developers, showcased the major shift in the technology space driven by artificial intelligence (AI). The event highlighted the adoption of AI copilots and plugins across various Microsoft offerings, including Bing, Dynamics 365 Copilot, and Microsoft 365 Copilot. Microsoft also announced the growth of the AI plugin ecosystem, the introduction of Azure AI tooling for developers, initiatives for building responsible AI systems, the unified analytics platform Microsoft Fabric, and collaborations with partners like NVIDIA. Windows 11 will also feature new AI-driven experiences with Windows Copilot. Microsoft Launches Microsoft Fabric, the New Analytics Platform ‘for AI era’: Microsoft Fabric debuts as a comprehensive and integrated analytics platform designed to meet the diverse needs of organizations. This end-to-end solution seamlessly combines various data and analytics tools, including Azure Data Factory, Azure Synapse Analytics, and Power BI, into a single unified product. Fabric empowers data and business professionals to maximize the value of their data, enabling them to delve deeper into insights and enhance decision-making processes.  OpenAI Launches $1M Grants Program for Democratic Inputs to AI: OpenAI has announced that it will fund ten grants of $100,000 each, aimed at supporting experiments in establishing a democratic framework for determining the guidelines that govern the behavior of AI systems while staying within legal boundaries. Recognizing that AI’s impact will be “significant” and “far-reaching,” the ChatGPT creator wants decisions concerning how AI behaves to be influenced by diverse public perspectives. The deadline to submit the grant application is June 24, 2023. Microsoft Releases AI Governance Report: Microsoft has published a report titled "Governing AI: A Blueprint for the Future," which outlines guidelines for governments in formulating policies and regulations related to AI. The report emphasizes five key areas for consideration, including the creation of “fail-safe safety brakes” for AI systems that control critical infrastructure including city traffic systems and electrical grids to ensure AI is always under human control. The report highlights Microsoft's commitment to ethical AI practices and how the company is implementing responsible AI principles within its operations. Scientists Harness AI to Unleash Powerful Antibiotic Against Deadly Superbug: Scientists have utilized artificial intelligence (AI) to identify a new antibiotic capable of combating a dangerous superbug. In a study published in Nature Chemical Biology, researchers from McMaster University and MIT discovered a promising antibiotic, named abaucin, through the use of AI algorithms. The superbug in question, Acinetobacter baumannii, poses a severe threat to human health. The AI screening process enabled the identification of several potential antibiotics, with abaucin ultimately proving effective in suppressing the infection in laboratory tests.  NVIDIA Unveils DGX GH200 AI Supercomputer to Revolutionize Generative AI and Recommender Systems: NVIDIA has introduced the DGX GH200 AI Supercomputer, a groundbreaking innovation that combines 256 Grace Hopper Superchips into a single, massive GPU, capable of delivering 1 exaflop of performance and 144 terabytes of shared memory. With advanced NVLink interconnect technology and the NVIDIA NVLink Switch System, the DGX GH200 empowers researchers to develop next-generation models for generative AI language applications, recommender systems, and data analytics workloads. Expert Insights from Packt Community The AI Product Manager's Handbook – By Irene Bratsis Succeeding in AI – how well-managed AI companies do infrastructure right Many large technology companies that depend heavily on ML have dedicated teams and platforms that focus on building, training, deploying, and maintaining ML models. The following are a few examples of options you can take when building an ML/AI program: Databricks has MLflow: MLflow is an open source platform developed by Databricks to help manage the complete ML life cycle for enterprises. It allows you to run experiences and work with any library, framework, or language.  Google has TensorFlow Extended (TFX): This is Google’s newest product built on TensorFlow and it’s an end-to-end platform for deploying production-level ML pipelines. It allows you to collaborate within and between teams and offers robust capabilities for scalable, high-performance environments. Uber has Michelangelo: Uber is a great example of a company creating their own ML management tool in-house for collaboration and deployment. Earlier, they were using disparate languages, models, and algorithms and had teams that were siloed. After they implemented Michelangelo, they were able to bring in varying skill sets and capabilities under one system.  The above content is extracted from the recently published book titled "The AI Product Manager's Handbook," authored By Irene Bratsis and published in Feb 2023. To get a glimpse of the book's contents, make sure to read the free chapter provided here, or if you want to unlock the full Packt digital library free for 7 days, try signing up now! To learn more, click on the button below.     Sit Back, Relax and Read More Here! Secret Knowledge: AI/LLM Resources LLMs Enabling Self-Healing Software that Repair Vulnerabilities Automatically: Researchers have introduced a groundbreaking solution that utilizes Large Language Models (LLMs) and Formal Verification techniques to automatically detect and fix software vulnerabilities. The method involves Bounded Model Checking (BMC) to identify vulnerabilities and generate counterexamples that highlight incorrect system behavior. These counterexamples, along with the source code, are then fed into an LLM engine, which uses a specialized prompt language for code debugging and generation. The repaired code is verified using BMC.  Google Research Introduces MatCha to Revolutionize Computer Understanding of Visual Language and Chart Reasoning: MatCha is a groundbreaking pixels-to-text foundation model that aims to improve computer understanding of visual language, including charts and graphs. Training on chart de-rendering and math reasoning tasks, MatCha surpasses previous models in ChartQA performance by over 20% and achieves comparable results in summarization systems with significantly fewer parameters. The research papers on MatCha and DePlot will be presented at ACL2023, and the models and code are available on Google Research's GitHub repository.  Dialogue-guided intelligent document processing with foundation models on Amazon SageMaker JumpStart: A dialogue-guided approach to intelligent document processing (IDP) using Amazon SageMaker JumpStart. IDP automates the processing of unstructured data and offers improvements over manual methods. The solution discussed in the article combines OCR, large language models (LLMs), task automation, and external data sources to enhance IDP workflows. Incorporating dialogue capabilities and generative AI technologies, the system becomes more efficient, accurate, and user-friendly.  Resolving Code Review Comments with Machine Learning: Google has implemented a machine learning (ML) system to automate and streamline the code review process, reducing the time spent on code reviews. By training a model to predict code edits based on reviewer comments, Google's system suggests code changes to authors, increasing their productivity and allowing them to focus on more complex tasks. The model has been calibrated to achieve a target precision of 50% and has successfully addressed 52% of comments in offline evaluations.  MasterClass: AI/LLM Tutorials Build LLM-powered chatbot in 5 minutes using HugChat and Streamlit: If you’re interested in building a chatbot using Language Models, this is a step-by-step guide on developing an LLM-powered chatbot using HugChat, a Python library that simplifies the integration of LLMs into chatbot applications and Streamlit, a user-friendly framework for creating interactive web applications.  Unlock the Potential of Unstructured Data with BigQuery Object Tables: Discover how Google Cloud's BigQuery Object Tables, now generally available, empower AI developers to analyze unstructured data more effectively. Object tables provide a structured record interface for unstructured data stored in Cloud Storage, enabling the use of SQL and AI models for processing and managing diverse data types. You can access Google’s guided lab and tutorials to get started with your project. Vertex AI Embeddings for Text: Grounding LLMs Easily: Explore the concept of grounding and learn about Vertex AI Embeddings for Text and Matching Engine, including its key features. Learn how to build reliable Gen AI services for enterprise use, enabling deep semantic understanding and enhancing user experiences in applications such as search, classification, recommendation, and clustering. You can access the Vertex AI Embeddings for Text API documentation here and see the Stack Overflow semantic search demo on GitHub. Getting Started with Generative AI Studio on Google Cloud: Google Cloud offers Generative AI Studio, a user-friendly console tool for prototyping and testing generative AI models. This article provides step-by-step instructions on using Generative AI Studio through the Google Cloud user interface, without the need for REST API or Python SDK. Further resources are available in the GitHub repository for those interested in learning more about using Generative AI Studio.  HackHub: Trending AI Tools SamurAIGPT/privateGPT: Create a QnA chatbot on your documents without relying on the internet by utilizing the capabilities of local LLMs with complete privacy and security.  facebookresearch/fairseq: A sequence modeling toolkit that allows researchers and developers to train custom models for translation, summarization, language modeling, and other text generation tasks.  iperov/DeepFaceLive: Swap your face from a webcam or the face in the video using trained face models. geohot/tinygrad: Aims to be the easiest deep learning framework to add new accelerators to, with support for both inference and training.  OpenGVLab/InternGPT: A pointing-language-driven visual interactive system, allowing you to interact with ChatGPT by clicking, dragging, and drawing using a pointing device.
Read more
  • 0
  • 0
  • 81

article-image-ai-distilled-1-scikit-llm-privacy-in-ml-models-and-chatgpt-copilot-in-windows-11
Kartikey Pandey, Vidhu Jain
05 Jun 2023
8 min read
Save for later

AI_Distilled #1: Scikit-LLM, Privacy in ML Models, and ChatGPT Copilot in Windows 11

Kartikey Pandey, Vidhu Jain
05 Jun 2023
8 min read
Welcome to the first issue of our newsletter — a treat for anyone interested in AI including developers, engineers, AI practitioners, and enthusiasts who live and breathe AI/ML, LLMs, NLP, Generative AI, and all related fields! This is a newsletter from Packt that combines original ideas and curated content for you. Deep dives, industry developments, interesting tools, and tools, all in one place. If it’s not the right area for you, please click on the unsubscribe button at the footer of this email.In this edition, we’ll examine differential privacy approaches in ML models, take a look at Scikit-LLM, that allows developers to seamlessly integrate language models into scikit-learn for enhanced text analysis, and explore why Microsoft is emphasizing the importance of causal inference in ML.We’ll learn how to quickly deploy your own ChatGPT-based apps and explore the concept of AI hallucinations, where AI attempts to overreach itself in misleading (and often terrifying) ways. More in today’s issue:TechWave: AI/GPT News & AnalysisSecret Knowledge: AI/LLM ResourcesMasterclass: AI/LLM TutorialsIndustry Experts SpeakHackHub: Trending AI ToolsCoding your new app? Working on the next GPT breakthrough? Trying to reduce ML inference latency? We’re here to help you stay updated and make sense of the rapidly changing AI landscape!What do you think of this issue and our newsletter? Please consider taking the short survey below to share your thoughts and you will get a free PDF of the “The Applied Artificial Intelligence” eBook upon completion.Until next time!Kartikey Pandey, Vidhu JainEditor-in-ChiefsComplete the Survey. Get a Packt eBook for Free! ⚡ TechWave: AI/GPT News & Analysis ChatGPT iOS App Released: OpenAI has released the much-awaited ChatGPT app for iOS. The app will sync your search history across all your devices and supports voice input for hands-free operation on your iPhone on the go. You can download the app here. The app is being initially rolled out in the US and will be available in more regions in the coming days. OpenAI has promised an Android version soon.Built-in ChatGPT-driven Copilot Will be Added to Windows 11: Microsoft is adding a new ChatGPT-driven Copilot feature in Windows 11 that can be used alongside other Windows apps. It will be available to Windows Insiders in June. It can change Windows settings, rearrange windows with Snap Layouts, summarize and rewrite documents, open apps, and more. There will also be a dedicated button for Windows Copilot on the taskbar.Scikit-LLM: Scikit-LLM allows developers to seamlessly integrate language models into scikit-learn for enhanced text analysis tasks. Scikit-LLM is still under development and it plans to add support for more models and fine-tuning. It features zero-shot text classification, multi-label zero-shot text classification, and text vectorization. GitHub repo here.New Image-to-Speech Generative AI App: AWS architects designed a novel web application, an image-to-speech Generative AI solution that empowers individuals with visual challenges to comprehend images through image captioning, facial recognition, and text-to-speech, leveraging Amazon SageMaker and Hugging Face. The website creates detailed descriptions of uploaded images and reads them out in a nature-sounding voice. The team used Hugging Face’s OFA model, a unified multi-model pre-trained model.dreamGPT Puts LLM Hallucinations to Creative Use: A new GPT-based tool turns LLM hallucination on its head and uses it to foster divergent thinking to generate unique insights and ideas for inspiration (think poetry). Contrary to conventional tools that use LLM models to solve specific challenges, dreamGPT ‘dreams’ of new ideas and amalgamates them to create novel concepts. You can access the GitHub repo here.Google Launches AI Product Studio: Google has started to deploy more generative technologies to their products. Google says Product Studio gives merchants the ability to create product imagery for free and get more value from the images they already have. You can create new imagery without the added cost of new photoshoots.Secret Knowledge: AI/LLM Resources How to Use Synthetic Control Method (SCM) for Causal Inference: Traditional ML models overlook causal relationships in favor of correlation. Many real-world instances need cause-effect dynamics, for example, when randomized control trials (A/B testing) are not feasible. Causal effects are also more resilient to model drifts. The article shows how you can estimate causal effects using machine learning with a synthetic control group instead of A/B testing. SCM (Synthetic Control Method) involves creating a synthetic control group that closely resembles the target group and using it to estimate the causal effect of an intervention. CRITIC: A New Framework for Self-Correcting AI Language Models: Researchers have introduced a system named CRITIC, which allows large language models (LLMs) to validate and improve their own outputs in a way similar to humans using tools for fact-checking or debugging. The process involves the model producing an initial output, interacting with tools to evaluate it, and then revising the output based on the feedback received, which has been proven to enhance the performance of LLMs in areas like question answering, program synthesis, and reducing toxicity.Leveraging Reinforcement Learning to Facilitate Dynamic Planning in Open-Ended Discussions: Dynamic planning is the ability to modify the original plan of a conversation based on its flow, allowing for flexible and engaging interactions. In the context of virtual assistants, dynamic planning enables deeper, multi-turn conversations that adapt to user preferences and goals. Traditional LLMs excel at generating individual responses but lack the capacity for forward planning. Novel RL constructions utilize supervised models, such as RNNs and transformers, to represent dialogue states effectively.Differentially Privacy in ML Models: Best Practices and Open Challenges: The article discusses the importance of protecting the privacy of training data in machine learning (ML) models. It introduces the concept of Differential Privacy (DP) which allows for data anonymization in ML models. Get to know the challenges in achieving good utility with differentially private ML techniques and explore the common techniques for obtaining differentially private ML models. The research emphasizes the need for practitioners to choose the right privacy unit, privacy guarantees, and perform hyperparameter tuning effectively. You can read the complete survey paper here.VideoLLM: A Tool for Video Analysis using LLMs: Leveraging the power of language processing models, the newly proposed VideoLLM system converts all video inputs into a type of language that can be analyzed more efficiently. By successfully testing on multiple datasets, VideoLLM proves that it can handle various tasks, suggesting that model's reasoning abilities can be effectively used for understanding and analyzing video content. GitHub repo here. MasterClass: AI/LLM Tutorials Quickly build ChatGPT apps in 5 steps with this low-code platform: This tutorial introduces the use of the low-code solution, ToolJet, to rapidly develop ChatGPT apps. Traditionally, creating and integrating apps with ChatGPT required programming expertise and time-consuming development cycles. ToolJet offers seamless integration with OpenAI, enabling developers to quickly build applications that leverage ChatGPT's capabilities in 5 steps:Sign up for a ToolJet accountCreate a new appSelect OpenAI pluginEnter your Organization ID and API KeyFetch OpenAI dataPrompt Engineering (GitHub Copilot) Beginner’s Guide: This tutorial explores how you can get started with Prompt Engineering using GitHub Copilot and practice writing and iterating on prompts yourself. First, let's start with the basics for folks who are unfamiliar with GitHub Copilot or prompt engineering. Read the full tutorial here ->How to Use Alpa and Ray to Efficiently Scale LLM training Across a Large GPU Cluster: This post explores the integration of Alpa.ai and Ray.io frameworks, highlighting their combined capabilities to train a massive 175 billion-parameter JAX transformer model with pipeline parallelism. We delve into the architectures, developer-friendly APIs, scalability, and performance of these frameworks. Both Alpa and Ray enhance developer productivity and optimize model scalability. Alpa's pipeline parallelism efficiently distributes computation across multiple GPUs, relieving developers of cognitive load. Ray provides a distributed computing framework for simplified resource scaling and management across multiple machines. Industry Experts Speak “No one in the field has yet solved the hallucination problems”- Sundar Pichai, Google and Alphabet CEOLLMs can deliver inaccurate information with a confident tone, often misleading unsuspecting users. Called hallucinations or confabulations, this is one of the major challenges with AI.“This new generation of AI will remove the drudgery of work and unleash creativity, and today we're sharing our latest Work Trend Index findings as we apply technology to help alleviate digital debt, build AI aptitude, and empower employees”-Satya Nadella, Microsoft Chairman and CEOThe latest Microsoft Work Trend Index report shows how AI is redefining the future of work. 49% of surveyed employees are fearful AI will replace their jobs while 70% would readily delegate workloads to AI to simplify their professional life and bolster creativity. HackHub: Trending AI Tools StanGirard/Quivr: Quivr calls itself “your second brain in the cloud”. It’s very convenient to dump all your files and thoughts and retrieve unstructured information, powered by generative AI.FlowiseAI/Flowise: Drag & drop UI to build your customized LLM flow using LangchainJS.Ricklamers/gpt-code-ui: An open-source implementation of OpenAI's ChatGPT Code interpreter.Stability-AI/StableStudio: StableStudio is Stability AI's official open-source variant of DreamStudio (user interface for generative AI). It is a web-based application that allows users to create and edit generated images. 0nutation/SpeechGPT: LLM with intrinsic cross-modal conversational abilities, capable of perceiving and generating multi-model content following human instructions.
Read more
  • 0
  • 0
  • 154
Unlock access to the largest independent learning library in Tech for FREE!
Get unlimited access to 7500+ expert-authored eBooks and video courses covering every tech area you can think of.
Renews at $19.99/month. Cancel anytime
article-image-creating-data-dictionary-using-chatgpt
Sagar Lad
04 Jun 2023
4 min read
Save for later

Creating Data Dictionary Using ChatGPT

Sagar Lad
04 Jun 2023
4 min read
This article highlights how ChatGPT can create data dictionaries within minutes, aiding data professionals in documenting data items. By leveraging ChatGPT's capabilities, professionals gain deeper insights, enhancing data management. A practical example demonstrates the efficiency and effectiveness of using ChatGPT in generating data dictionaries. What is a data dictionary? Data professionals, such as data engineers, data scientists, analysts, database administrators, and developers, face various data challenges, ranging from business requirement definition to data volume and speed management. To effectively tackle these difficulties, they require a comprehensive understanding of the data. Data dictionaries play a vital role in providing deeper insights into the data. A data dictionary serves as documentation for the data, encompassing names, definitions, and attributes of the database's data items. Its main purpose is to comprehend and describe the significance of data items in relation to the application, along with including data element metadata. Data dictionaries are indispensable in data projects as they contribute to success by offering valuable insights into the data. Benefits of creating a data dictionary: Conquer data discrepancies Facilitate data exploration and analysisMaintain data standards throughout the projectEstablish uniform and consistent standards for the projectEstablish data standards to control the gathered data and explain it across the project A typical data dictionary has below components:  ComponentDescriptionData ElementName of the data elementDescription Definition of the data elementData TypeType of data stored in the attribute (ex. text, number, date)LengthMaximum number of characters stored in the attributeFormatFormat  for the data (e.g. date/currency format) Valid ValuesList of allowed values for the data elementRelationshipsRelationships between different tables in the databaseSource Origin of the data (e.g. system, department)ConstraintsRules related to the use of the dataListing of data objectsNames and DefinitionsDetailed properties of data elementsData type, Size, nullability, optionality, indexesBusiness rulesSchema validation or Data Quality Image 1 : Sample Database Schema with Data Attribute Name, Data Type & Constraints     As demonstrated in the example above, each database has a basic set of data about the data dictionary, but this information is insufficient when working with a database that has numerous tables, each of which may have multiple columns.  Creating a practical data dictionary with ChatGPT Data and natural language processing can be used by ChatGPT to produce in-depth knowledge on any subject. As a result, ChatGPT may be used to build instructive data dictionaries for any dataset.       Image 2: ChatGPT to create Data Dictionary Let’s understand the step-by-step process to create a data dictionary using ChatGPT: Finding and copying the data               Let us ask ChatGPT for one of the public datasets to create a data dictionary:    List of Data Sources recommended by ChatGPT Now, I will download the csv file named Institutions.csv from the FDIC Bank Data API. Image 4: Downloaded CSV file for FDIC Bank DataLet’s use this data to create a data dictionary using ChatGPT. Prepare ChatGPT Let’s now prompt the GPT to create a raw data dictionary for the dataset that we picked above:Image 5: Output Data Dictionary Request Data Dictionary with additional information Additionally, we can request that ChatGPT add new columns and other pertinent data to the output of the data dictionary. For instance, in the sample below, I've asked ChatGPT to add a new column called Active Loan and to provide descriptions to the columns based on its knowledge of banking. Output Data Dictionary from ChatGPT with additional columns and informationWe can now see that the data dictionary is updated which can be shared within the organization.ConclusionIn conclusion, leveraging ChatGPT's capabilities expedites the creation of data dictionaries, enhancing data management for professionals. Its efficiency and insights empower successful data projects, making ChatGPT a valuable tool in the data professional's toolkit. Author BioSagar Lad is a Cloud Data Solution Architect with a leading organization and has deep expertise in designing and building Enterprise-grade Intelligent Azure Data and Analytics Solutions. He is a published author, content writer, Microsoft Certified Trainer, and C# Corner MVP. Link - Medium, Amazon, LinkedIn.
Read more
  • 0
  • 0
  • 595

article-image-using-openai-python-library-to-interact-with-the-chatgpt-api
Martin Yanev
04 Jun 2023
7 min read
Save for later

Using OpenAI Python Library to Interact with the ChatGPT API

Martin Yanev
04 Jun 2023
7 min read
Using the ChatGPT API with Python is a relatively simple process. You'll first need to make sure you create a new PyCharm project called ChatGPTResponse as shown in the following screenshot: Fig 1: New Project Window in PyCharm Once you have that setup, you can use the OpenAI Python library to interact with the ChatGPT API. Open a new Terminal in PyCharm, make sure that you are in your project folder, and install the openai package: $ pip install openai Next, you need to create a new Python file in your PyCharm project on the left top corner perform a Right-click on the folder ChatGPTResponse | New | Python File. Name the file app.py and click hit Enter. You should now have a new Python file in your project directory: Fig 2: New Python File To get started, you'll need to import the openai library into your Python file. Also, you'll need to provide your OpenAI API Key. You can obtain an API Key from the OpenAI website by following the steps outlined in the previous sections of this book. Then you'll need to set it as a parameter in your Python code. Once your API Key is set up, you can start interacting with the ChatGPT API. import openaiopenai.api_key = "YOUR_API_KEY" Replace YOUR_API_KEY with the API key you obtained from the OpenAI platform page. Now, you can ask the user a question using the input() function: question = input("What would you like to ask ChatGPT? ") The input() function is used to prompt the user to input a question they would like to ask the ChatGPT API. The function takes a string as an argument, which is displayed to the user when the program is run. In this case, the question string is "What would you Like to ask ChatGPT?". When the user types their question and presses enter, the input() function will return the string that the user typed. This string is then assigned to the variable question. To pass the user question from your Python script to ChatGPT, you will need to use the ChatGPT API Completion function: response = openai.Completion.create(    engine="text-davinci-003",    prompt=question,    max_tokens=1024,    n=1,    stop=None,    temperature=0.8,) The openai.Completion.create() function in the code is used to send a request to the ChatGPT API to generate a completion of the user's input prompt. The engine parameter specifies the ChatGPT engine to use for the request, and in this case, it is set to "text-davinci-003". The prompt parameter specifies the text prompt for the API to complete, which is the user's input question in this case. The max_tokens parameter specifies the maximum number of tokens the response should contain.  The n parameter specifies the number of completions to generate for the prompt. The stop parameter specifies the sequence where the API should stop generating the response. The temperature parameter controls the creativity of the generated response. It ranges from 0 to 1. Higher values will result in more creative but potentially less coherent responses, while lower values will result in more predictable but potentially fewer interesting responses. Later in the book, we will delve into how these parameters impact the responses received from ChatGPT.The function returns a JSON object containing the generated response from the ChatGPT API, which then can be accessed and printed to the console in the next line of code.print(response)In the project pane on the left-hand side of the screen, locate the Python file you want to run. Right-click on the app.py file and select Run app.py from the context menu. You should receive a message in the Run window that asks you to write a question to the ChatGPT.  Fig 3: Run WindowOnce you have entered your question, press the Enter key to submit your request to the ChatGPT API. The response generated by the ChatGPT API model will be displayed in the Run window as a complete JSON object: {   "choices": [    {       "finish_reason": "stop",       "index": 0,       "logprobs": null,       "text": "\n\n1. Start by getting in the water. If you're swimming in a pool, you can enter the water from the side, ………….    }  ],   "created": 1681010983,   "id": "cmpl-73G2JJCyBTfwCdIyZ7v5CTjxMiS6W",   "model": "text-davinci-003",   "object": "text_completion",   "usage": {    "completion_tokens": 415,     "prompt_tokens": 4,     "total_tokens": 419  }} This JSON response produced by the OpenAI API contains information about the response generated by the GPT-3 model. This response consists of the following fields:The choices field contains an array of objects with the generated responses, which in this case only contains one response object. The text field within the response object contains the actual response generated by the GPT-3 model.The finish_reason field indicates the reason why the response was generated; in this case it was because the model reached the stop condition specified in the API request.The created field specifies the Unix timestamp of when the response was created. The id field is a unique identifier for the API request that generated this response.The model field specifies the GPT-3 model that was used to generate the response. The object field specifies the type of object that was returned, which in this case is text_completion.The usage field provides information about the resource usage of the API request. It contains information about the number of tokens used for the completion, the number of tokens in the prompt, and the total number of tokens used.The two most important parameter from the response is the text field, that contains the answer to the question asked to ChatGPT API. This is why most API users would like to access only that parameter from the JSON object. You can easily separate the text from the main body as follows: answer = response["choices"][0]["text"]print(answer)By following this approach, you can guarantee that the variable answer will hold the complete ChatGPT API text response, which you can then print to verify. Keep in mind that ChatGPT responses can significantly differ depending on the input, making each response unique.OpenAI:1. Start by getting in the water. If you're swimming in a pool, you can enter the water from the side, ladder, or diving board. If you are swimming in the ocean or lake, you can enter the water from the shore or a dock.2. Take a deep breath in and then exhale slowly. This will help you relax and prepare for swimming.Summary In this tutorial, you implemented a simple ChatGPT API response, by sending a request to generate a completion of a user's input prompt/question. You have also learned how to set up your API Key and how to prompt the user to input a question, and finally, how to access the generated response from ChatGPT in the form of a JSON object containing information about the response.  About the Author Martin Yanev is an experienced Software Engineer who has worked in the aerospace and medical industries for over 8 years. He specializes in developing and integrating software solutions for air traffic control and chromatography systems. Martin is a well-respected instructor with over 280,000 students worldwide, and he is skilled in using frameworks like Flask, Django, Pytest, and TensorFlow. He is an expert in building, training, and fine-tuning AI systems with the full range of OpenAI APIs. Martin has dual Master's degrees in Aerospace Systems and Software Engineering, which demonstrates his commitment to both practical and theoretical aspects of the industry.https://www.linkedin.com/in/martinyanev/https://www.udemy.com/user/martin-yanev-3/
Read more
  • 0
  • 0
  • 3216

article-image-set-up-and-run-auto-gpt-with-docker
Rohan Chikorde
04 Jun 2023
8 min read
Save for later

Set Up and Run Auto-GPT with Docker

Rohan Chikorde
04 Jun 2023
8 min read
Are you looking to get your hands dirty with Auto-GPT? Look no further! In this article, we'll guide you through the straightforward installation process, enabling you to effortlessly set up Auto-GPT and unlock its powerful capabilities. Say goodbye to complex setups and hello to enhanced language generation in just a few simple steps. To use Auto-GPT, users need to have Python installed on their computer, as well as an OpenAI API key. This key allows Auto-GPT to access the GPT-4 and GPT-3.5 APIs, as well as other resources such as internet search engines and popular websites. Once it is configured, users can interact with Auto-GPT using natural language commands, and the AI agent will automatically perform the requested task. We will show practically how to set up and run Auto-GPT using Docker. We will also be showing steps to other popular methods towards the end. Benefits of using Docker for running Auto-GPT  Docker is a containerization technology that allows developers to create, deploy, and run applications in a consistent and isolated environment. It enables the packaging of an application and all its dependencies into a single container, which can be easily distributed and run on any machine that has Docker installed. Using Docker to run Auto-GPT provides several benefits:It allows you to run Auto-GPT in an isolated and reproducible environment, which ensures that the dependencies and configurations required to run Auto-GPT are consistent across different machines. This can be especially useful when collaborating on a project or when deploying Auto-GPT to a production environment. Docker provides a secure sandboxed environment, which can help prevent any potential harm to your computer from continuous mode malfunctions or accidental damage from commands.  Docker simplifies the installation and configuration process of Auto-GPT by packaging it in a container that includes all the necessary dependencies and libraries. This means you don't have to manually install and configure these dependencies, which can be time-consuming and error prone. Overall, using Docker to run Auto-GPT provides a convenient and secure solution for developing and deploying Auto-GPT in a consistent and reproducible manner.Software Requirements Docker (recommended)  Python 3.10 or later  VSCode + devcontainer Getting an API key  Get your OpenAI API key from: https://platform.openai.com/account/api-keys   Fig 1. Creating API keySetting up Auto-GPT with DockerHere first we will showcase step by step by guide to set up Auto-GPT using docker.1.     Make sure you have Python and Docker are installed on your system and its daemon is running, see requirements Fig 2. Command Prompt  2.     Open CMD and Pull the latest image from Docker Hub using following command:docker pull significantgravitas/auto-gpt Fig 3. Pulling image from dockerhub Please note if docker daemon is not running it will throw an error. Fig 4. Docker Image Once pulled using above command, you can find the significantgravitas/auto-gpt image on your docker. 3.     Create a folder for Auto-GPT4.     In the folder, create a file named docker-compose.yml with the following contents:version: "3.9"services:  auto-gpt:    image: significantgravitas/auto-gpt    depends_on:      - redis    env_file:      - .env    environment:      MEMORY_BACKEND: ${MEMORY_BACKEND:-redis}      REDIS_HOST: ${REDIS_HOST:-redis}    profiles: ["exclude-from-up"]    volumes:      - ./auto_gpt_workspace:/app/auto_gpt_workspace      - ./data:/app/data      ## allow auto-gpt to write logs to disk      - ./logs:/app/logs      ## uncomment following lines if you have / want to make use of these files      #- ./azure.yaml:/app/azure.yaml      #- ./ai_settings.yaml:/app/ai_settings.yaml  redis:    image: "redis/redis-stack-server:latest" 5.     Download Source code(zip) from the latest stable release6.     Extract the zip-file into a folder. Fig 5. Source folder Configuration using Docker 1.     After downloading and unzipping the folder, find the file named .env.template in the main Auto-GPT folder. This file may be hidden by default in some         operating systems due to the dot prefix. To reveal hidden files, follow the instructions for your specific operating system: Windows, macOS2.     Create a copy of .env.template and call it .env; if you're already in a command prompt/terminal window: use cp .env.template .env3.     Now you should have only two files in your folder – docker-compose.yml and .env Fig 6.  Docker-compose and .env files 4.     Open the .env file in a text editor5.     Find the line that says OPENAI_API_KEY=6.     After the =, enter your unique OpenAI API Key without any quotes or spaces.7.     Extracting API key is discussed in step 1 (discussed above).8.     Save and close .env file Running Auto-GPT with Docker Easiest is to use docker-compose. Run the commands below in your Auto-GPT folder.1.     Build the image. If you have pulled the image from Docker Hub, skip this stepdocker-compose build auto-gpt2.     Run Auto-GPTdocker-compose run --rm auto-gpt3.     By default, this will also start and attach a Redis memory backend. If you do not want this, comment or remove the depends: - redis and redis: sections           from docker-compose.yml4.     You can pass extra arguments, e.g., running with --gpt3only and --continuous:docker-compose run --rm auto-gpt --gpt3only –continuous Fig 7. Auto-GPT Installed Other methods without Docker Setting up Auto-GPT with Git 1.     Make sure you have Git installed for your OS2.     To execute the given commands, open a CMD, Bash, or PowerShell window. On Windows: press Win+X and select Terminal, or Win+R and enter cmd3.     First clone the repository using following command:git clone -b stable https://github.com/Significant-Gravitas/Auto-GPT.git4.     Navigate to the directory where you downloaded the repositorycd Auto-GPT Manual Setup 1.     Download Source code (zip) from the latest stable release2.     Extract the zip-file into a folderConfiguration 1.     Find the file named .env.template in the main Auto-GPT folder. This file may be hidden by default in some operating systems due to the dot prefix. To reveal hidden files, follow the instructions for your specific operating system: Windows, macOS2.     Create a copy of .env.template and call it .env; if you're already in a command prompt/terminal window: cp .env.template .env3.     Open the .env file in a text editor4.     Find the line that says OPENAI_API_KEY=5.     After the =, enter your unique OpenAI API Key without any quotes or spaces6.     Save and close the .env file Run Auto-GPT without Docker Simply run the startup script in your terminal. This will install any necessary Python packages and launch Auto-GPT. Please note, if the above configuration is not properly setup, then it will throw an error, hence recommended and easiest way to run is using docker.On Linux/MacOS:./run.shOn Windows:.\run.batIf this gives errors, make sure you have a compatible Python version installed. ConclusionIn conclusion, if you're looking for a hassle-free way to install Auto-GPT, Docker is the recommended choice. By following our comprehensive guide, you can effortlessly set up Auto-GPT using Docker, ensuring a streamlined installation process, consistent environment configuration, and seamless deployment on different platforms. With Docker, bid farewell to compatibility concerns and embrace a straightforward and efficient Auto-GPT installation experience. Empower your language generation capabilities today with the power of Docker and Auto-GPT.Author BioRohan is an accomplished AI Architect professional with a post-graduate in Machine Learning and Artificial Intelligence. With almost a decade of experience, he has successfully developed deep learning and machine learning models for various business applications. Rohan's expertise spans multiple domains, and he excels in programming languages such as R and Python, as well as analytics techniques like regression analysis and data mining. In addition to his technical prowess, he is an effective communicator, mentor, and team leader. Rohan's passion lies in machine learning, deep learning, and computer vision.You can follow Rohan on LinkedIn
Read more
  • 0
  • 0
  • 1379

article-image-text-to-image-prompt-engineering-tips-stable-diffusion
Emily Webber
04 Jun 2023
7 min read
Save for later

Text-to-Image Prompt Engineering Tips: Stable Diffusion

Emily Webber
04 Jun 2023
7 min read
This article is an excerpt from the book, Pretrain Vision and Large Language Models in Python, by Emily Webber. This book will help you pretrain and fine-tune your own foundation models from scratch on AWS and Amazon SageMaker, while applying them to hundreds of use cases across your organization.Stable Diffusion is a revolutionary model that allows you to unleash your creativity by generating captivating images through natural language prompts. This article explores the power of Stable Diffusion in producing high-resolution, black-and-white masterpieces, inspired by renowned artists like Ansel Adams. Discover valuable tips and techniques to enhance your Stable Diffusion results, including adding descriptive words, utilizing negative prompts, upscaling images, and maximizing precision and detail. Dive into the world of hyperparameters and learn how to optimize guidance, seed, width, height, and steps to achieve stunning visual outcomes. Unleash your artistic vision with Stable Diffusion's endless possibilities. Stable Diffusion is a great model you can use to interact with via natural language and produce new images. The beauty, fun, and simplicity of Stable Diffusion-based models are that you can be endlessly creative in designing your prompt. In this example, I made up a provocative title for a work of art. I asked the model to imagine what it would look like if created by Ansel Adams, a famous American photographer from the mid-twentieth century known for his black-and-white photographs of the natural world. Here was the full prompt: “Closed is open” by Ansel Adams, high resolution, black and white, award-winning. Guidance (20). Let’s take a closer look.Figure 1 – An image generated by Stable DiffusionIn the following list, you’ll find a few helpful tips to improve your Stable Diffusion results:Add any of the following words to your prompt: Award-winning, high resolution, trending on <your favorite site here>, in the style of <your favorite artist here>, 400 high dpi, and so on. There are thousands of examples of great photos and their corresponding prompts online; a great site is Lexica. Starting from what works is always a great path. If you’re passionate about vision, you can easily spend hours of time just pouring through these and finding good examples. For a faster route, that same site lets you search for words as a prompt and renders the images. It’s a quick way to get started with prompting your model. Add negative prompts: Stable Diffusion offers a negative prompt option, which lets you provide words to the model that it will explicitly not use. Common examples of this are hands, humans, oversaturated, poorly drawn, and disfigured.Upscaling: While most prompting with Stable Diffusion results in smaller images, such as size 512x512, you can use another technique, called upscaling, to render that same image into a much larger, higher quality image, of size 1,024x1,024 or even more. Upscaling is a great step you can use to get the best quality Stable Diffusion models today, both on SageMaker (2) and through Hugging Face directly. (3) We’ll dive into this in a bit more detail in the upcoming section on image-to-image.Precision and detail: When you provide longer prompts to Stable Diffusion, such as including more terms in your prompt and being extremely descriptive about the types and styles of objects you’d like it to generate, you actually increase your odds of the response being good. Be careful about the words you use in the prompt. As we learned earlier in the chapter on bias, most large models are trained on the backbone of the internet. With Stable Diffusion, for better or for worse, this means you want to use language that is common online. This means that punctuation and casing actually aren’t as important, and you can be really creative and spontaneous with how you’re describing what you want to see.Order: Interestingly, the order of your words matters in prompting Stable Diffusion. If you want to make some part of your prompt more impactful, such as dark or beautiful, move that to the front of your prompt. If it’s too strong, move it to the back.Hyperparameters: These are also relevant in language-only models, but let’s call out a few that are especially relevant to Stable Diffusion. Key hyperparameters for Stable Diffusion prompt engineering Guidance: The technical term here is classifier-free guidance, and it refers to a mode in Stable Diffusion that lets the model pay more (higher guidance) or less (lower guidance) attention to your prompt. This ranges from 0 up to 20. A lower guidance term means the model is optimizing less for your prompt, and a higher term means it’s entirely focused on your prompt. For example, in my image in the style of Ansel Adams above, I just updated the guidance term from 8 to 20. In the guidance=8 in Figure 13.3, you see a rolling base and gentle shadows. However, when I updated to guidance=20 on the second image, the model captures the stark contrast and shadow fades that characterized Adams’ work. In addition, we have a new style, almost like M. C. Escher, where the tree seems to turn into the floor. Seed: This refers to an integer you can set to baseline your diffusion process. Setting the seed can have a big impact on your model response. Especially if my prompt isn’t very good, I like to start with the seed hyperparameter and try a few random starts. Seed impacts high-level image attributes such as style, size of objects, and coloration. If your prompt is strong, you may not need to experiment heavily here, but it’s a good starting point. Width and height: These are straightforward; they’re just the pixel dimensions of your output image! You can use them to change the scope of your result, and hence the type of picture the model generates. If you want a perfectly square image, use 512x512. If you want a portrait orientation, use 512x768. For landscape orientation, use 768x512. Remember you can use the upscaling process we’ll learn about shortly to increase the resolution on the image, so start with smaller dimensions first. Steps: This refers to the number of denoising steps the model will take as it generates your new image, and most people start with steps set to 50. Increasing this number will also increase the processing time. To get great results, personally, I like to scale this against guidance. If you plan on using a very high guidance term (~16), such as with a killer prompt, then I wouldn’t set inference steps to anything over 50. This looks like it overfits, and the results are just plain bad. However, if your guidance scale is lower, closer to 8, then increasing the number of steps can get you a better result. SummaryIn conclusion, Stable Diffusion offers a fascinating avenue for creative expression through its image-generation capabilities. By employing strategic prompts, negative constraints, upscaling techniques, and optimizing hyperparameters, users can unlock the full potential of this powerful model. Embrace the boundless creativity and endless possibilities that Stable Diffusion brings to the world of visual art. Author BioEmily Webber is a Principal Machine Learning Specialist Solutions Architect and keynote speaker at Amazon Web Services, where she has led the development of countless solutions and features on Amazon SageMaker. She has guided and mentored hundreds of teams, developers, and customers in their machine-learning journey on AWS. She specializes in large-scale distributed training in vision, language, and generative AI, and is active in the scientific communities in these areas. She hosts YouTube and Twitch series on the topic, regularly speaks at re:Invent, writes many blog posts, and leads workshops in this domain worldwide. You can follow Emily on LinkedIn
Read more
  • 0
  • 0
  • 1244
article-image-shortcomings-and-challenges-of-chatgpt-implementation
Matt Zand
04 Jun 2023
5 min read
Save for later

Shortcomings and Challenges of ChatGPT Implementation

Matt Zand
04 Jun 2023
5 min read
IntroductionThe emergence of AI technology, such as ChatGPT and Auto-GPT, has presented a wealth of possibilities for industries across the full spectrum of work. This article introduces ChatGPT and its use cases, followed by analyzing the shortcomings and challenges of ChatGPT integration. Overview of ChatGPT  A chatbot is an artificial intelligence-based computer program designed to simulate conversation with human users through a messaging interface. Chatbots can be a valuable tool to learn about AI and natural language processing, as well as to improve their communication skills. By interacting with a chatbot, beginners can practice their language skills, get feedback, and learn new vocabulary. Additionally, chatbots can provide instant answers to their questions, help them with simple tasks, and guide them through complex processes. For beginners, chatbots can be a useful tool in automating various tasks. Chatbots can also help in providing personalized recommendations, answering frequently asked questions, and offering support.   Technical Use Cases of ChatGPT  ChatGPT can be an excellent resource for experts and technical people in various fields. As a language model, it can provide answers to complex questions, aid in problem-solving, and assist in research. With its vast knowledge database and ability to understand and process natural language, ChatGPT can quickly and efficiently find relevant information and provide accurate answers. This can save time for experts and technical people, allowing them to focus on higher-level tasks that require their expertise. In addition to answering questions and providing information, ChatGPT can also be used by professionals for technical tasks. It can automate processes, such as data analysis, text classification, and language translation, making it an excellent tool for technical people. For example, a data scientist could use ChatGPT to automate the process of analyzing large data sets, while a developer could use it to quickly translate code or troubleshoot technical issues. With its versatility and adaptability, ChatGPT can be a valuable asset to technical people in various fields. Shortcomings and Challenges of ChatGPT  While ChatGPT is a highly advanced and impressive technology, there are still some shortcomings and challenges associated with it.  One of the main challenges is the potential for bias and inaccurate responses based on the data on which it was trained. As with any machine learning model, ChatGPT is only as good as the data it was trained on, so if the training data contains biases or inaccuracies, it may reproduce them in its responses.  Another challenge is the lack of transparency in its decision-making process, which can make it difficult to understand why it generates certain responses.  ChatGPT may struggle with context-dependent conversations and may not always supply accurate or helpful responses to complex or nuanced queries.  Response based on reinforcement learning could potentially be problematic for ChatGPT. Reinforcement learning involves the use of a reward system to incentivize the model to produce certain responses. However, if the feedback supplied is incorrect or biased, it can negatively affect the ChatGPT model's learning and lead to the production of suboptimal responses.  ChatGPT does not provide any confidence score for its response, for example, if an algorithm has multiple functions or sections, it does not provide a confidence score for each section. Hence, it raises questions about the reliability of its responses and how to measure that reliability.  ChatGPT, like any machine learning model, has limitations in its ability to predict the future. While it can generate responses based on patterns it has learned from enormous amounts of data, it cannot anticipate events that have not yet occurred or make predictions beyond its training data. The energy consumption and carbon footprint associated with training and running such a large language model is a concern for its environmental impact.Summary With the ever-growing advancement of AI technology, tools like ChatGPT can assist many professions, from beginners who want to learn a new language, to technical experts who work in the field of data science. Like any other tool, ChatGPT comes with its own shortcomings and challenges. Thus, since ChatGPT is still at its early stage of adoption, it is advisable for the AI community to work on its shortcomings and share its insights and solutions.   About the Author Matt Zand is the director of Coding Bootcamps and High School Technology Services (HSTS) which offers self-paced and live courses related to blockchain, software engineering, and AI.  HSTS is a member of the Linux Foundation and LF AI & Data. He is a leading author of Hands-on Smart Contract Development with Hyperledger Fabric book by O’Reilly Media. He has written many technical articles on blockchain development at sites such as IBM, Alibaba Cloud, Hyperledger, The Linux Foundation, and more. He is also the founder of three tech startups: RealBig, DC Web Makers, and GoReward. Currently, he is the Advisor at Zuma Dating Events. You can connect with him on LinkedIn: https://www.linkedin.com/in/matt-zand-64047871
Read more
  • 0
  • 0
  • 785

article-image-prompt-engineering-principles
Martin Yanev
04 Jun 2023
5 min read
Save for later

Prompt Engineering Principles

Martin Yanev
04 Jun 2023
5 min read
Prompt Engineering and design play a very vital role in controlling the output of the model. Here are some best practices you can use to improve your prompts, as well as some practices you should avoid:Clarity: Use simple sentences and instructions that can easily be understood by ChatGPT. Conciseness: Favor short prompts and short sentences. This can be achieved by chunking your instructions into smaller sentences with clear intentions.Focus: Keep the focus of the prompt on a well-defined topic so that you don’t risk your output being too generic.Consistency: Maintain a consistent tone and language during the conversation so that you can ensure a coherent conversation.“Acting as…”: The hack of letting ChatGPT act as someone or something has proven to be extremely powerful. You can shorten the context you have to provide to the model by simply asking him to act like the person or system you want information from. We’ve already seen the interview-candidate example, where ChatGPT acted as an interviewer for a data scientist position. A very interesting prompt is that of asking ChatGPT to act as a console. Here is an example of it: Figure 1 – Example of ChatGPT acting as a Python console Note that the console, as it would be if it were real, is also reporting the error I made for the cycle, indicating that I was missing the brackets.There is a continuously growing list of Act as prompts you can try in the following GitHub repository: https://github.com/f/awesome-chatgpt-prompts.Considering the few-shot learning capabilities, there are some good tips for leveraging this feature in prompt designing. An ideal conversation is as follows: On the other hand, there are some things you should avoid while designing your prompt:Start with a concise, clear, and focused prompt. This will help you have an overview of the topic you want to discuss, as well as provide food for thought and potential expansion of particular elements. Here’s an exampleFigure 2 – Example of a clear and focused prompt to initiate a conversation with ChatGPTOnce you have identified the relevant elements in the discussion, you can ask ChatGPT to elaborate on them with much more focusFigure 3 – Example of a deep-dive follow-up question in a ChatGPT Sometimes, it might be useful to remember the model and the context in which you are inquiring, especially if the question might apply to various domainsFigure 4 – Example of a reminder about the context in a conversation with ChatGPTFinally, always in mind the limitations we mentioned in previous chapters. ChatGPT may provide partial or incorrect information, so it is always a good practice to double-check. One nice tip you could try is asking the model to provide documentation about its responses so that you can easily find proof of themFigure 5 – Example of ChatGPT providing documentation supporting its previous responses On the other hand, there are some things you should avoid while designing your prompt: Information overload: Avoid providing too much information to ChatGPT, since it could reduce the accuracy of the response.Open-ended questions: Avoid asking ChatGPT vague, open-ended questions. Prompts such as What can you tell me about the world? or Can you help me with my exam? are far too generic and will result in ChatGPT generating vague, useless, and sometimes hallucinated responses.Lack of constraints: If you are expecting an output with a specific structure, don’t forget to specify that to ChatGPT! If you think about the earlier example of ChatGPT acting as an interviewer, you can see how strict I was in specifying not to generate questions all at once. It took several tries before getting to the result since ChatGPT is thought to generate a continuous flow of text.Furthermore, as a general consideration, we still must remember that the knowledge base of ChatGPT is limited to 2021, so we should avoid asking questions about facts that occurred after that date. You can still provide context; however, all the responses will be biased toward the knowledge base before 2021. SummaryIn this article, we get to learn some strong principles that can help you learn how to prompt effectively.  We cover the importance of a good prompt, and all the important Do’s and Don'ts while designing a good prompt with a practical example. About the Author Valentina Alto graduated in 2021 in Data Science. Since 2020 she has been working in Microsoft as Azure Solution Specialist and, since 2022, she focused on Data&AI workloads within the Manufacturing and Pharmaceutical industry. She has been working on customers’ projects closely with system integrators to deploy cloud architecture with a focus on datalake house and DWH, data integration and engineering, IoT and real-time analytics, Azure Machine Learning, Azure cognitive services (including Azure OpenAI Service), and PowerBI for dashboarding. She holds a BSc in Finance and an MSc degree in Data Science from Bocconi University, Milan, Italy. Since her academic journey, she has been writing Tech articles about Statistics, Machine Learning, Deep Learning, and AI in various publications. She has also written a book about the fundamentals of Machine Learning with Python.LinkedInMedium
Read more
  • 0
  • 0
  • 306

article-image-create-a-personal-portfolio-website-with-javascript-and-chatgpt
Maaike van Putten
04 Jun 2023
9 min read
Save for later

Create a Personal Portfolio Website with JavaScript and ChatGPT

Maaike van Putten
04 Jun 2023
9 min read
This article is the first part of a series of articles, please refer to Part 2  for learning how to add a Chatbot to the portfolio website you create in this article!Creating a personal portfolio is a great way for showcasing your skills and accomplishments as a developer or designer. Does that sound like a lot of work? Well… it doesn’t have to be. We can use ChatGPT to generate code snippets and obtain a lot of guidance throughout the process. This way you can build an impressive portfolio website with minimal effort.Here’s what you can do in around 10 prompts: Fig 1: Homepage Fig 2: Portfolio PageFig 3: Contact Page Not bad, right? And it even contains some features: The search functionality works and filters projects based on what you are typing.The testimonials and projects are not hard-coded, but dynamically populated with JavaScript (but not connected to a backend with a database, so for the purpose of this article, they are hard-coded there).Of course, this personal portfolio would need more content. And you could definitely use ChatGPT to generate a bit more content and descriptions for it. You should be adding in some professional pictures and images to complete your portfolio. However, this is a project that you can do in half a day to a day using ChatGPT. The prompt magic The prompts used to create the personal portfolio follow a few best practices that I’ll discuss later. In the overview below, asking to continue after cutting off a response is not included. If you’d like to see all the responses and the versions of the personal portfolio after each step, you can check out this GitHub repo: https://github.com/BrightBoost/brightboost-portfolio-chatgpt Here is the first prompt:I'm making a portfolio site, using HTML/CSS/JS. Can you help me write the initial framework for it?  I need a home page, in which I will introduce me, my passions, aspirations and study background. I also need a call-to-action directing visitors to explore my work.Then I need a portfolio page, in which I showcase my best projects. This will include case studies, and testimonials highlighting my contributions and accomplishments.Finally I need a contact page, which is a minimalist form and social media links in order to facilitate professional connections. And the second:That seems to be close to what I want. However, could you split these into 3 files? One for each page.The third, as you can see, a lot of the heavy lifting in terms of content is done in the prompt here:Can you populate the pages with the following information?Name: Olivia MartinezStudy: Olivia recently graduated from the University of California, Berkeley with a Bachelor's degree in Computer Science.Aspirations: Olivia aspires to become a full-stack software engineer at a tech startup that focuses on environmental sustainability. She hopes to contribute her skills to develop innovative solutions for pressing environmental issues.Hobbies: In her free time, Olivia enjoys hiking, painting, and exploring the latest advancements in machine learning.Example Open Source Projects:- GreenRoute: A web application that optimizes travel routes based on carbon emissions.- EcoClicker: A browser extension that encourages users to reduce their digital carbon footprint.Additional Personal Details: Olivia has been an active volunteer at her local recycling center, where she has helped develop a digital platform to streamline recycling processes. This is what it looked like after this prompt:Fig 4: Homepage after initial promptsFig 5: Portfolio page after promptFig 6: Contact Page after promptThe fourth prompt was quite a challenge and it required going back and forward a bit and testing it until it was good. It was tempting to just modify it, but ChatGPT was supposed to create it here and it did eventually:Can you help me modify the following snippet? ```html      <h2>Portfolio</h2>      <div class="project">        <h3>GreenRoute</h3>        <p>A web application that optimizes travel routes based            on carbon emissions.</p>        <a href="#" class="project-link">View Case Study</a>        <div class="testimonials">          <p>Testimonial 1</p>          <p>Testimonial 2</p>        </div>      </div>       <div class="project">        <h3>EcoClicker</h3>        <p>A browser extension that encourages users to reduce            their digital carbon footprint.</p>        <a href="#" class="project-link">View Case Study</a>        <div class="testimonials">          <p>Testimonial 1</p>          <p>Testimonial 2</p>        </div>      </div>    ``` I'm not satisfied with the look. Could you make the following changes: - Each project is displayed in a card.- The project link looks like a button, in the bottom right.- The title is underlined, and a bit larger.- The page shows 2 columns of cards. Fig 7: Home page after refined promptingAnd here’s the fifth: I need to make sure that footer is always at the bottom of the page, can you provide a CSS snippet to make that work?This also needed second attempt because it wasn’t working. Don’t just say that it doesn’t work, but be specific:It doesn't seem to work. The page only uses about 50% of the screen, so the footer is still in the middle. After this, it looks like: Fig 8: Homepage after footer promptsThis is where things really got cool, but this needed a few tweaks in terms of output. Here was the first prompt to add JavaScript: I'd like to make the portfolio a bit more extendable. Can you write some JavaScript code that generates the portfolio page using an array of objects? For now just put the content directly in code. I forgot a few classes, so let’s prompt again: This works, but you've excluded the classes used in the CSS. As a reminder, this is how a single item should look:** code of the prompt omitted And after this it was good: It seems the 2 column layout is gone. I think this:```html<section id="portfolio"><div class="container" id="portfolio-container"></div></section>```Should contain an element with the class `project-grid` somewhere, which should create a grid. Can you modify the snippet? The last part was on the search bar, which required this prompt:I'd like to add a search bar to the portfolio page. It must search for the text in the title and body. I only want to look for the exact text. After each character it should update the list, filtering out any project that does not match the search text. Then there should be a button to clear the search bar, and show all projects. Can you add this to the JavaScript file? And that’s it! Of course, there are many ways to do this, but this is one way of how you can use ChatGPT to create a personal portfolio. Let’s see some best practices for your ChatGPT prompts, to help you with using it to create your personal portfolio.Best practices for ChatGPT prompts There are some best practices I figured out when working with ChatGPT. Let’s go over them before seeing the prompts used for the personal portfolio.Be specific and clear: Make sure your prompt leaves little room for interpretation. For example, the prompt:Help me with a grid layout.Is not going to help you as much as:For this piece of HTML containing bootstrap cards provide a CSS snippet for a responsive 3-column grid layout with a 20px gap between columns: ** insert your HTML snippet here **Include relevant context and background information: Give the AI enough information to understand the problem or task and help you to its best ability. Don’t ask:How do I convert a date string to a Date object?But ask:  I have a JSON object with date and value properties. How do I convert the date property to a JavaScript Date object?Ask one question at a time: Keep your prompts focused and avoid asking multiple questions in one prompt.Make sure ChatGPT completes its answer before asking the next question: Sometimes it cuts off the result. You can ask it to continue and it will. That’s harder when you’re further down the line.Test the result after every step: Related to the previous tip, but make sure to test the result after every step. This way you can provide feedback on the outcome and it can easily adjust still. Step? Yes! Break down big projects into smaller tasks: Divide your project into manageable steps, and ask the AI to complete each task separately.Bonus tip: You can even ask ChatGPT for help on how to break your project into smaller tasks and make these tasks very detailed. Then go ahead and ask it to do one task at a time.The good news is these tips are actually great interaction tips with humans as well! I bet you’d like to see some of the prompts used to create the personal portfolio, so let’s dive in. Author BioMaaike van Putten is an experienced software developer and Pluralsight, LinkedIn Learning, Udemy, and Bright Boost instructor. She has a passion for software development and helping others get to the next level in their career.You can follow Maaike on:LinkedInTraining Courses
Read more
  • 0
  • 0
  • 1408
article-image-using-chatgpt-with-text-to-speech
Denis Rothman
04 Jun 2023
7 min read
Save for later

Using ChatGPT with Text to Speech

Denis Rothman
04 Jun 2023
7 min read
This article provides a quick guide to using the OpenAI API to jump-start ChatGPT. The guide includes instructions on how to use a microphone to speak to ChatGPT and how to create a ChatGPT request with variables. Additionally, the article explains how to use Google gTTS, a text-to-speech tool, to listen to ChatGPT's response. By following these steps, you can have a more interactive experience with ChatGPT and make use of its advanced natural language processing capabilities. We’re using the GPT-3.5-Turbo architecture in this example. We are also running the examples within Google Colab, but they should be applicable to other environments. In this article, we’ll cover: Installing OpenAI, your API key, and Google gTTS for Text-to-SpeechGenerating content with ChatGPTSpeech-to-text ChatGPT's responseTranscribing with WhisperTo understand GPT-3 Transformers in detail, read Transformers for NLP, 2nd Edition 1. Installing OpenAI, gTTS, and your API Key There are a few libraries that we’ll need to install into Colab for this project. We’ll install them as required, starting with OpenAI. Installing and Importing OpenAI To start using OpenAI's APIs and tools, we'll need to install the OpenAI Python package and import it into your project. To do this, you can use pip, a package manager for Python. First, make sure you have pip installed on your system. !pip install --upgrade pipNext, run the following script in your notebook to install the OpenAI package. It should come pre-installed in Colab:#Importing openaitry:import openaiexcept:!pip install openaiimport openai Installing gTTS Next, install Google gTTS a Python library that provides an easy-to-use interface for text-to-speech synthesis using the Google Text-to-Speech API:#Importing gTTStry:from gtts import gTTSexcept:!pip install gTTS   from gtts import gTTS API Key Finally, import your API key. Rather than enter your key directly into your notebook, I recommend keeping it in a local file and importing it from your script. You will need to provide the correct path and filename in the code below.from google.colab import drivedrive.mount('/content/drive')f = open("drive/MyDrive/files/api_key.txt", "r")API_KEY=f.readline()f.close()#The OpenAI Keyimport osos.environ['OPENAI_API_KEY'] =API_KEYopenai.api_key = os.getenv("OPENAI_API_KEY") 2. Generating Content Let’s look at how to pass prompts into the OpenAI API to generate responses. Speech to text When it comes to speech recognition, Windows provides built-in speech-to-text functionality. However, third-party speech-to-text modules are also available, offering features such as multiple language support, speaker identification, and audio transcription. For simple speech-to-text, this notebook uses the built-in functionality in Windows. Press Windows key + H to bring up the Windows speech interface. You can read the documentation for more information.Note: For this notebook, press Enter when you have finished asking for a request in Colab. You could also adapt the function in your application with a timed input function that automatically sends a request after a certain amount of time has elapsed. Preparing the Prompt Note: you can create variables for each part of the OpenAI messages object. This object contains all the information needed to generate a response from ChatGPT, including the text prompt, the model ID, and the API key. By creating variables for each part of the object, you can make it easier to generate requests and responses programmatically. For example, you could create a prompt variable that contains the text prompt for generating a response. You could also create variables for the model ID and API key, making it easier to switch between different OpenAI models or accounts as needed.For more on implementing each part of the messages object, take a look at: Prompt_Engineering_as_an_alternative_to_fine_tuning.ipynb.Here’s the code for accepting the prompt and passing the request to OpenAI:#Speech to text. Use OS speech-to-text app. For example,   Windows: press Windows Key + H def prepare_message():#enter the request with a microphone or type it if you wish  # example: "Where is Tahiti located?"  print("Enter a request and press ENTER:")  uinput = input("")  #preparing the prompt for OpenAI   role="user"  #prompt="Where is Tahiti located?" #maintenance or if you do not want to use a microphone  line = {"role": role, "content": uinput}  #creating the message   assert1={"role": "system", "content": "You are a helpful assistant."}  assert2={"role": "assistant", "content": "Geography is an important topic if you are going on a once in a lifetime trip."}  assert3=line  iprompt = []  iprompt.append(assert1)  iprompt.append(assert2)  iprompt.append(assert3)  return iprompt#run the cell to start/continue a dialogiprompt=prepare_message() #preparing the messages for ChatGPTresponse=openai.ChatCompletion.create(model="gpt-3.5-turbo",messages=iprompt) #ChatGPT dialogtext=response["choices"][0]["message"]["content"] #response in JSONprint("ChatGPT response:",text) Here's a sample of the output: Enter a request and press ENTER:Where is Tahiti locatedChatGPT response: Tahiti is located in the South Pacific Ocean, specifically in French Polynesia. It is part of a group of islands called the Society Islands and is located approximately 4,000 kilometers (2,500 miles) south of Hawaii and 7,850 kilometers (4,880 miles) east of Australia. 3. Speech-to-text the response GTTS and IPython Once you've generated a response from ChatGPT using the OpenAI package, the next step is to convert the text into speech using gTTS (Google Text-to-Speech) and play it back using  IPython audio.from gtts import gTTSfrom IPython.display import Audiotts = gTTS(text)tts.save('1.wav')sound_file = '1.wav'Audio(sound_file, autoplay=True) 4. Transcribing with Whisper If your project requires the transcription of audio files, you can use OpenAI’s Whisper.First, we’ll install the ffmpeg audio processing library. ffmpeg is a popular open-source software suite for handling multimedia data, including audio and video files:!pip install ffmpegNext, we’ll install Whisper:!pip install git+https://github.com/openai/whisper.git With that done, we can use a simple command to transcribe the WAV file and store it as a JSON file with the same name:!whisper  1.wavYou’ll see Whisper transcribe the file in chunks:[00:00.000 --> 00:06.360]  Tahiti is located in the South Pacific Ocean, specifically in the archipelago of society[00:06.360 --> 00:09.800]  islands and is part of French Polynesia.[00:09.800 --> 00:22.360]  It is approximately 4,000 miles, 6,400 km, south of Hawaii and 5,700 miles, 9,200 km,[00:22.360 --> 00:24.640]  west of Santiago, Chile.Once that’s done, we can read the JSON file and display the text object:import json with open('1.json') as f:     data = json.load(f) text = data['text'] print(text)This gives the following output:Tahiti is located in the South Pacific Ocean, specifically in the archipelago of society islands and is part of French Polynesia. It is approximately 4,000 miles, 6,400 km, south of Hawaii and 5,700 miles, 9,200 km, west of Santiago, Chile. By using Whisper in combination with ChatGPT and gTTS, you can create a fully featured AI-powered application that enables users to interact with your system using natural language inputs and receive audio responses. This might be useful for applications that involve transcribing meetings, conferences, or other audio files. About the Author Denis Rothman graduated from Sorbonne University and Paris-Diderot University, designing one of the very first word2matrix patented embedding and patented AI conversational agents. He began his career authoring one of the first AI cognitive natural language processing (NLP) chatbots applied as an automated language teacher for Moet et Chandon and other companies. He authored an AI resource optimizer for IBM and apparel producers. He then authored an advanced planning and scheduling (APS) solution used worldwide.You can follow Denis on LinkedIn:  https://www.linkedin.com/in/denis-rothman-0b034043/Copyright 2023 Denis Rothman, MIT License
Read more
  • 0
  • 0
  • 3163

article-image-generating-data-descriptions-with-openai-chatgpt
Greg Beaumont
02 Jun 2023
5 min read
Save for later

Generating Data Descriptions with OpenAI ChatGPT

Greg Beaumont
02 Jun 2023
5 min read
This article is an excerpt from the book, Machine Learning with Microsoft Power BI, by Greg Beaumont. This book is designed for data scientists and BI professionals seeking to improve their existing solutions and workloads using AI.Data description generation plays a vital role in understanding complex datasets, but it can be a time-consuming task. Enter ChatGPT, an advanced AI language model developed by OpenAI. Trained on extensive text data, ChatGPT demonstrates impressive capabilities in understanding and generating human-like responses. In this article, we explore how ChatGPT can revolutionize data analysis by expediting the creation of accurate and coherent data descriptions. We delve into its training process, architecture, and potential applications in fields like research, journalism, and business analytics. While acknowledging limitations, we unveil the transformative potential of ChatGPT for data interpretation and knowledge dissemination. Our first step will be to identify a suitable use case for leveraging the power of GPT models to generate descriptions of elements of FAA Wildlife Strike data. Our objective is to unlock the potential of external data by creating prompts for GPT models that can provide detailed information and insights about the data we are working with. Through this use case, we will explore the value that GPT models can bring to the table when it comes to data analysis and interpretation.For example, a description of the FAA Wildlife Strike Database by ChatGPT might look like this: Figure 1 – OpenAI ChatGPT description of FAA Wildlife Strike Database Within your solution using the FAA Wildlife Strike database, you have data that could be tied to external data using the GPT models. A few examples include additional information about:AirportsFAA RegionsFlight OperatorsAircraftAircraft EnginesAnimal SpeciesTime of Year When the scoring process for a large number of separate rows in a dataset is automated, we can use a GPT model to generate descriptive text for each individual row. It is worth noting that ChatGPT's approach varies from this, as it operates as a chatbot that calls upon different GPT models and integrates past conversations into future answers. Despite the differences in how GPT models will be used in the solution, ChatGPT can still serve as a valuable tool for testing various use cases.When using GPT models, the natural language prompts that are used to ask questions and give instructions will impact the context of the generated text. Prompt engineering is a topic that has surged in popularity for OpenAI and LLMs. The following prompts will provide different answers when using “dogs” as a topic for a GPT query:Tell me about dogs:From the perspective of an evolutionary biologist, tell me about dogs:Tell me the history of dogs:At a third-grade level, tell me about dogs:When planning for your use of OpenAI on large volumes of data, you should test and evaluate your prompt engineering strategy. For this book, the use cases will be kept simple since the goal is to teach tool integration with Power BI. Prompt engineering expertise will probably be the topic of many books and blogs this year. You can test different requests for a description of an FAA Region in the data: Figure 2 – Testing the utility of describing an FAA Region using OpenAI ChatGPT You can also combine different data elements for a more detailed description. The following example combines data fields with a question to ask “Tell me about the Species in State in Month”: Figure 3 – Using ChatGPT to test a combination of data about Species, State, and Month There are many different options to consider. To combine a few fields of data and provide useful context about the data, you decide to plan a use case for describing the aircraft and operator. An example can be tested with the following formula in OpenAI ChatGPT such as “Tell me about the airplane model Aircraft operated by the Operator in three sentences." Here is an example using data from a single row of the FAA Wildlife Strike database: Figure 4 – Information about an airplane in the fleet of an operator as described by OpenAI ChatGPT From a prompt engineering perspective, asking this question for multiple reports in the FAA Wildlife Strike database would require running the following natural language query on each row of data (column names are depicted with brackets): Tell me about the airplane model [Aircraft] operated by [Operator] in three sentences:SummaryThis article explores how ChatGPT expedites the generation of accurate and coherent data descriptions. Unveiling its training process, architecture, and applications in research, journalism, and business analytics, we showcase how ChatGPT revolutionizes data interpretation and knowledge dissemination. Acknowledging limitations, we highlight the transformative power of this AI technology in enhancing data analysis and decision-making. Author BioGreg Beaumont is a Data Architect at Microsoft; Greg is an expert in solving complex problems and creating value for customers. With a focus on the healthcare industry, Greg works closely with customers to plan enterprise analytics strategies, evaluate new tools and products, conduct training sessions and hackathons, and architect solutions that improve the quality of care and reduce costs. With years of experience in data architecture and a passion for innovation, Greg has a unique ability to identify and solve complex challenges. He is a trusted advisor to his customers and is always seeking new ways to drive progress and help organizations thrive. For more than 15 years, Greg has worked with healthcare customers who strive to improve patient outcomes and find opportunities for efficiencies. He is a veteran of the Microsoft data speaker network and has worked with hundreds of customers on their data management and analytics strategies.You can follow Greg on his LinkedIn 
Read more
  • 0
  • 0
  • 105