Skip to content

Commit

Permalink
More comments, more business applications, and links to pkl files
Browse files Browse the repository at this point in the history
  • Loading branch information
ed-donner committed Oct 5, 2024
1 parent 0fba204 commit ca67bf1
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 10 deletions.
54 changes: 50 additions & 4 deletions week1/day1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,18 @@
"\n",
"## If you're new to Jupyer Lab\n",
"\n",
"Welcome to the wonderful world of Data Science experimentation! Once you've used Jupyter Lab, you'll wonder how you ever lived without it. Simply click in each \"cell\" with code in it, like the cell immediately below this text, and hit Shift+Return to execute that cell. As you wish, you can add a cell with the + button in the toolbar, and print values of variables, or try out variations.\n",
"Welcome to the wonderful world of Data Science experimentation! Once you've used Jupyter Lab, you'll wonder how you ever lived without it. Simply click in each \"cell\" with code in it, such as the cell immediately below this text, and hit Shift+Return to execute that cell. As you wish, you can add a cell with the + button in the toolbar, and print values of variables, or try out variations.\n",
"\n",
"If you need to start again, go to Kernel menu >> Restart kernel."
"If you need to start a 'notebook' again, go to Kernel menu >> Restart kernel.\n",
"\n",
"## I am here to help\n",
"\n",
"If you have any problems at all, please do reach out. \n",
"I'm available through the platform, or at ed@edwarddonner.com, or at https://www.linkedin.com/in/eddonner/ if you'd like to connect.\n",
"\n",
"## Business value of these exercises\n",
"\n",
"A final thought. While I've designed these notebooks to be educational, I've also tried to make them enjoyable. We'll do fun things like have LLMs tell jokes and argue with each other. But fundamentally, my goal is to teach skills you can apply in business. I'll explain business implications as we go, and it's worth keeping this in mind: as you build experience with models and techniques, think of ways you could put this into action at work today. Please do contact me if you'd like to discuss more or if you have ideas to bounce off me."
]
},
{
Expand Down Expand Up @@ -71,7 +80,10 @@
"\n",
"load_dotenv()\n",
"os.environ['OPENAI_API_KEY'] = os.getenv('OPENAI_API_KEY', 'your-key-if-not-using-env')\n",
"openai = OpenAI()"
"openai = OpenAI()\n",
"\n",
"# Uncomment the below line if this gives you any problems:\n",
"# openai = OpenAI(api_key=\"your-key-here\")"
]
},
{
Expand Down Expand Up @@ -265,15 +277,49 @@
"display_summary(\"https://anthropic.com\")"
]
},
{
"cell_type": "markdown",
"id": "c951be1a-7f1b-448f-af1f-845978e47e2c",
"metadata": {},
"source": [
"## Business Applications\n",
"\n",
"In this exercise, you experienced calling the API of a Frontier Model (a leading model at the frontier of AI) for the first time. This is broadly applicable across Gen AI use cases and we will be using APIs like OpenAI at many stages in the course, in addition to building our own LLMs.\n",
"\n",
"More specifically, we've applied this to Summarization - a classic Gen AI use case to make a summary. This can be applied to any business vertical - summarizing the news, summarizing financial performance, summarizing a resume in a cover letter - the applications are limitless. Consider how you could apply Summarization in your business, and try prototyping a solution."
]
},
{
"cell_type": "markdown",
"id": "36ed9f14-b349-40e9-a42c-b367e77f8bda",
"metadata": {},
"source": [
"## An extra exercise for those who enjoy web scraping\n",
"\n",
"You may notice that if you try `display_summary(\"https://openai.com\")` - it doesn't work! That's because OpenAI has a fancy website that uses Javascript. There are many ways around this that some of you might be familiar with. For example, Selenium is a hugely popular framework that runs a browser behind the scenes, renders the page, and allows you to query it. If you have experience with Selenium, Playwright or similar, then feel free to improve the Website class to use them. Please push your code afterwards so I can share it with other students!"
"You may notice that if you try `display_summary(\"https://openai.com\")` - it doesn't work! That's because OpenAI has a fancy website that uses Javascript. There are many ways around this that some of you might be familiar with. For example, Selenium is a hugely popular framework that runs a browser behind the scenes, renders the page, and allows you to query it. If you have experience with Selenium, Playwright or similar, then feel free to improve the Website class to use them."
]
},
{
"cell_type": "markdown",
"id": "eeab24dc-5f90-4570-b542-b0585aca3eb6",
"metadata": {},
"source": [
"# Sharing your code\n",
"\n",
"I'd love it if you share your code afterwards so I can share it with others! You'll notice that some students have already made changes (including a Selenium implementation) which you will find in the community-contributions folder. If you'd like add your changes to that folder, submit a Pull Request with your new versions in that folder and I'll merge your changes.\n",
"\n",
"If you're not an expert with git (and I am not!) then GPT has given some nice instructions on how to submit a Pull Request. It's a bit of an involved process, but once you've done it once it's pretty clear. As a pro-tip: it's best if you clear the outputs of your Jupyter notebooks (Edit >> Clean outputs of all cells, and then Save) for clean notebooks.\n",
"\n",
"PR instructions courtesy of an AI friend: https://chatgpt.com/share/670145d5-e8a8-8012-8f93-39ee4e248b4c"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "682eff74-55c4-4d4b-b267-703edbc293c7",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
28 changes: 24 additions & 4 deletions week1/day5.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
"\n",
"Create a product that builds a Brochure for a company to be used for prospective clients, investors and potential recruits.\n",
"\n",
"We will be provided a company name and their primary website."
"We will be provided a company name and their primary website.\n",
"\n",
"See the end of this notebook for examples of real-world business applications.\n",
"\n",
"And remember: I'm always available if you have problems or ideas! Please do reach out."
]
},
{
Expand Down Expand Up @@ -100,7 +104,9 @@
"\n",
"### Use a call to gpt-4o-mini to read the links on a webpage, and respond in structured JSON. \n",
"It should decide which links are relevant, and replace relative links such as \"/about\" with \"https://company.com/about\". \n",
"We will use \"one shot prompting\" in which we provide an example of how it should respond in the prompt."
"We will use \"one shot prompting\" in which we provide an example of how it should respond in the prompt.\n",
"\n",
"Sidenote: there is a more advanced technique called \"Structured Outputs\" in which we require the model to respond according to a spec. We cover this technique in Week 8 during our autonomous Agentic AI project."
]
},
{
Expand Down Expand Up @@ -230,7 +236,7 @@
"and creates a short brochure about the company for prospective customers, investors and recruits. Respond in markdown.\\\n",
"Include details of company culture, customers and careers/jobs if you have the information.\"\n",
"\n",
"# Or uncomment the line below for a more humorous brochure:\n",
"# Or uncomment the lines below for a more humorous brochure - this demonstrates how easy it is to incorporate 'tone':\n",
"\n",
"# system_prompt = \"You are an assistant that analyzes the contents of several relevant pages from a company website \\\n",
"# and creates a short humorous, entertaining, jokey brochure about the company for prospective customers, investors and recruits. Respond in markdown.\\\n",
Expand Down Expand Up @@ -345,10 +351,24 @@
"stream_brochure(\"HuggingFace\", \"https://huggingface.co\")"
]
},
{
"cell_type": "markdown",
"id": "a27bf9e0-665f-4645-b66b-9725e2a959b5",
"metadata": {},
"source": [
"## Business Applications\n",
"\n",
"In this exercise we extended the Day 1 code to make multiple LLM calls, and generate a document.\n",
"\n",
"In terms of techniques, this is perhaps the first example of Agentic AI design patterns, as we combined multiple calls to LLMs. This will feature more in Week 2, and then we will return to Agentic AI in a big way in Week 8 when we build a fully autonomous Agent solution.\n",
"\n",
"In terms of business applications - generating content in this way is one of the very most common Use Cases. As with summarization, this can be applied to any business vertical. Write marketing content, generate a product tutorial from a spec, create personalized email content, and so much more. Explore how you can apply content generation to your business, and try making yourself a proof-of-concept prototype."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "bcf5168e-f1d9-4fa7-b372-daf16358e93c",
"id": "22e878f1-08fe-4465-b50c-869352174eae",
"metadata": {},
"outputs": [],
"source": []
Expand Down
16 changes: 15 additions & 1 deletion week8/day2.0.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,28 @@
"login(hf_token, add_to_git_credential=True)"
]
},
{
"cell_type": "markdown",
"id": "3d4995a4-f67f-4871-87df-8c6439b06366",
"metadata": {},
"source": [
"## Back to the pkl files\n",
"\n",
"Much as we enjoyed data curating in week 6, we probably don't want to go through that whole process again!\n",
"\n",
"Let's reuse the pkl files we created then. Either copy the files `train.pkl` and `test.pkl` from the Week 6 folder into this Week 8 folder, or you can also download them from here:\n",
"\n",
"https://drive.google.com/drive/folders/1f_IZGybvs9o0J5sb3xmtTEQB3BXllzrW?usp=drive_link"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "688bd995-ec3e-43cd-8179-7fe14b275877",
"metadata": {},
"outputs": [],
"source": [
"# Let's avoid curating all our data again! Load in the pickle files:\n",
"# With train.pkl in this folder, you can run this:\n",
"\n",
"with open('train.pkl', 'rb') as file:\n",
" train = pickle.load(file)"
Expand Down
4 changes: 3 additions & 1 deletion week8/day2.3.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@
"metadata": {},
"outputs": [],
"source": [
"# Load in the test pickle file:\n",
"# Load in the test pickle file\n",
"# See the section \"Back to the PKL files\" in the day2.0 notebook\n",
"# for instructions on obtaining this test.pkl file\n",
"\n",
"with open('test.pkl', 'rb') as file:\n",
" test = pickle.load(file)"
Expand Down

0 comments on commit ca67bf1

Please sign in to comment.