INSEAD MBA Course "Building genAI Products and Businesses"
T. Evgeniou, Professor INSEAD GitHub | LinkedIn
The material for session 1 was developed by Olivier Mertens, Developer Audience, Azure Open AI Service, @Microsoft GitHub | LinkedIn
In the first session, we will learn about some Gen AI tools that we will use for product prototyping during the class.
We'll use OpenAI Service and keys to access/use models with the use of apis and Google Collab (browser based) for some python coding.
[NOTE] You can also use all notebooks in a local/your computer: with Visual studio code or using Conda to launch Jupyter notebook You have to install this sofware to use in in local
Summary of the session:
- First steps
- Create a user login on OpenAI and prepare your organization and keys
- Exploring genAI: Three Examples
- Gpts / RAG / functions
- Gen AI in real world
- Reference links
-
Go to the OpenAI website: https://www.openai.com/
-
Create an account: Click on the 'Sign Up' button on the top right corner of the website. Fill in your details and follow the steps to create your account.
-
Verify your email: Check your email for a verification link from OpenAI. Click on the link to verify your account.
-
Log in to your account: After verifying your email, log in to your account using your credentials.
To experiment with the key concepts of prompt engineering, models and RAG - retrieval Augmented Generation you could visit and test the sandbox GPTs (just announced by OpenAI in November 2023) to play with a chatbot interface without the need to code ("No Code" environment). To do so, you can go to https://platform.openai.com/playground
Select your model (e.g., we can select gpt-4 or earlier - and less costly - ones like gpt-3.5-turbo)
If you want to know about differences between the available LLM models, you can deep dive at this link
This interface will be shown after you have correctly created your chatbot
You can also read this for some more background on basic prompt engineering
Other resources:
- Sandbox / Playground Open AI https://platform.openai.com/playground
- Documentation Assistants https://platform.openai.com/docs/assistants/overview
- API With openAI https://platform.openai.com/docs/api-reference
-
Access the API dashboard: Once logged in, navigate to the API dashboard named Api Keys.
-
Create a new API key: If you don't already have an API key, you can create a new one by clicking on the 'Create new API key' button.
You can select the name you want
You will have this kind of view after creating a key (or several keys)
IMPORTANT Don't forget every usage of a model with OpenAI will cost something! ( and the price depends of your chosen model) check this link to understand the difference in pricing / models)[https://openai.com/pricing]
-
Copy your API key: After creating your API key, make sure to copy it and store it somewhere safe. This key is used to authenticate your requests to the OpenAI API. Whoever has access to it will be charging your account when using it!
-
Set up your organization: In the API dashboard, you can also set up your organization if needed. This involves adding other users to your organization and managing their access levels.
Remember, keep your Open AI API key secure and do not share it with anyone. It's also a good practice to regularly rotate your API keys, or create a new one for each application or usage.
In order to simplify potential issues with different python versions or different operating systems and problematic install on your personal computer.
We will use notebook Collab for this course. You can of course also work on your computer if you choose to, using for example Anaconda (beyond the course).
- You need to have a Google Gmail Account. If not create a new one
We will use these three colab notebooks as starting examples. Go to https://colab.research.google.com/ and follow these links to have the latest notebooks for course session 1:
- Interview questions generation https://aka.ms/inseadGenAi-1
- Web article generation https://aka.ms/inseadGenAi-2
- (This one will require some more steps, see below) Extract audio with whisper and process the text https://aka.ms/inseadGenAi-3
We will be adding more over time (as you will notice).
You may encounter warning pop-up windows - click ok or execute to continue.
When a notebook is correctly imported in your personal collab, you have to first import your secrets credentials.
- Add your secrets (Key and organization imported form OpenAI sk-XXX and org-xxxxxx) in the left panel in Google Collab
Create a variable secret one at a time:
- Copy/paste this name:
OPENAI_API_KEY
- Copy paste your sk-key inside the right input named value
- Click on the left blue button to render the secret available in your notebook
Next, if needed (you do not need to do this for the course), you can also add a secret key and value for an organization:
- Copy/paste this name:
OPENAI_ORGANIZATION
- Copy paste your org-key inside the right input input named value
- Click on left blue button to render the secret available in your notebook
To use/run a notebook you have to click on every small "play button" inside the notebook on the left of the code chunk.
[Note] The three example notebooks the very first "code chunk" (that installs packages) may take a few seconds to run and will be generating some messages. Simply wait till it completes running.
For the third (audio analysis) Notebook, you can import you own mp4 file video or audio to analyse. To do so:
- Click on the folder button on the left
- Import your file inside the current path - click yes to the pop up warning. Note that you have to respect the file naming ("interview.mp4") or else you will have to change the name in the notebook itself in the line inputFile = "/content/interview.mp4"
Don't be afraid of python you will also get help!
🥰
So you have now seen some examples of what you can do with Gen AI. You can now try to explore the OpenAI API GPTS actions to see what else is possible.
What is it about ? Gpt's custom can give a chabot with some capabilities to interact with users and you can open it to the world, customize the user experience, add some files for custom the grounded experience
- Has custom instructions which determine the way the GPT interacts with users
- Includes tools like browsing, DALL·E, and Code Interpreter
- Comes with preset starter prompts for new and returning users
- Has custom actions which allow you to connect the GPT to APIs
a possibility to grounded with verified data ( from pdf files , csv, html, etc) to give a more accurate answer to the user ask or with a database vector ( contains embeddings of the data) to give a more accurate answer to the user ask
Functions it's first step to give model a tool / possibility to determine if a function is relevant to the user ask. If you want to use the GPTs functions, you can go to the Cookbook for functions to see what else is possible. Or take a look to this post in forum open AI who explain clearly how it works But the function called an api or a business process to resolve the user ask
It's the next step with new concepts as thread / messages with the addin of tools ( AKA Functions) available ( 128 tools if you want it). You could still add RAG ( retrieval ) or code interpreter ( to permit launch of code) to allow a "agent / assistant" ( with prompt system or persona ) to have the autonomy/choice (Programmatic choice :)) to launch/call by "himself" the function/tools to resolve the user ask/
Take a look on this documentation repository about this Azure Assistants)
An example of a Gpt's with setup to be able to retrieve informations from documents and some functions
Now you have an idea of what one can do with Gen AI - one can use it for many different applications. However, going from a Python Notebook "demo" to an actual product requires some engineering. The tools needed are in some ways like lego blocks: one can combine them to create their own solution.
Let's now see how to build actual gen AI products! Let's start with a really simple use case. The idea of the example here is to insert some python code inside a file of an existing web application to be able to use it as part of that application.
We use python for simplicity, but one can explore other languages like dotnet, java or others.
Note: Some software architecture decisions could be critical in your launch of a product. Understanding the choices and trade offs is very important, but not the purpose of this course.
We will use the lastet developement (in beta version, as of February 2024) from OpenAI: the "Assistants". You can follow these video guides to create a simple chatbot with OpenAI and Azure
You can also follow these steps ("for a beginner, not a developper") to implement your code inside an already existing app
Some example assistants can be found here
- Starters use case: AI in a box
- Sample App With RAG
- Call center Claim AI phone bot
- Youtube - Github OpenAi RAG App on Azure
- Evaluating a RAG Chat App
- AI Term Glossary
- Models
- Azure Assistants
- Generative AI Guide
- RAG Ai document intelligence
- AI Chat App Hack
- Prompt Engineering
- How a transformer works
More information on Azure Open AI services can be found here