Prompt Engineering with GPT & LangChain | Get Better Outputs Instantly

16 Jan 2024 · 97 min
1:36:41

The video walks through a hands‑on tutorial that introduces the LangChain framework and demonstrates core prompt‑engineering techniques for OpenAI models. It starts by setting up the environment and installing required packages, then shows how to read a small financial‑headline dataset and clean it. The presenter explains how to create reusable PromptTemplate and ChatPromptTemplate objects, illustrating the use of dynamic variables and system messages. LLMChain objects are built for both completion and chat models, with discussion of temperature settings and model selection. The tutorial then covers LangChain’s output parsers, using a comma‑separated‑list parser to extract company names directly into Python lists. Next, agents and tools are introduced: a Python REPL tool is wrapped in a LangChain agent to execute code, solve math problems, and orchestrate a multi‑step financial‑sentiment workflow that extracts company names, determines sentiment, builds a Pandas DataFrame, and writes a CSV. The limitations of rule‑based Python extraction are highlighted, leading to a switch back to LLM‑driven extraction with few‑shot prompting. Few‑shot examples are added to improve financial sentiment classification, and the impact of few‑shot learning is demonstrated. Finally, the OpenAI Moderation API is used to filter potentially harmful user input before sending it to the model. The session concludes with a recap of prompt templates, few‑shot learning, LLM chains, output parsing, agents, tools, and moderation as essential components for building robust generative‑AI applications with LangChain.

Chapters

More from Richie

youtube.com

#359 My Best Friend is AI with Valerie Tiberius, Professor of Philosophy at University of Minnesota

5mo ago
youtube.com

17.8% of the World Now Uses AI — And the Gap Is Widening | The Median #5

5mo ago
youtube.com

Create GPTs to Automate Go-To-Market Research

5mo ago
youtube.com

What Happened to Self-Driving Cars? #AI

5mo ago
youtube.com

Never Use AI For This #warning #AI #flights

5mo ago
youtube.com

Use AI Agents to Analyze Power Grid Optimization

5mo ago
youtube.com

This is how modern AI actually solves problems #AITrends #AI

5mo ago
youtube.com

How AI Agents Will Work While You Sleep | Ruslan Salakhutdinov, Professor at Carnegie Mellon

5mo ago
youtube.com

#358 How AI Agents Will Work While You Sleep | Ruslan Salakhutdinov, Professor at Carnegie Mellon

5mo ago
youtube.com

Build an AI‑driven Dashboard

5mo ago
youtube.com

What’s Broken in Labor Markets Today #datascience

5mo ago
See all content