Lesson 2 Lecture
What is Prompt Engineering?
Prompt engineering is the art and science of crafting effective instructions for AI systems like Deepseek. Think of it as learning how to "speak AI" - finding the right words and structures that help these advanced systems understand exactly what you want them to do.
Just like you might phrase a question differently when talking to a teacher versus a friend, prompt engineering involves adapting your language to communicate clearly with AI systems. It's about finding the perfect balance between being specific enough to get what you want, but open enough to let the AI's capabilities shine.
For example, instead of asking "Tell me about space," a well-engineered prompt might be: "Explain three fascinating discoveries about black holes from the last decade in simple terms that a high school student would understand."
Why Use Prompt Engineering?
Imagine having a super-smart friend who takes everything extremely literally. That's basically what Deepseek and other AI systems are like! Here's why prompt engineering matters:
- Get better results - The quality of an AI's output directly depends on the quality of your input. Better prompts = better responses.
- Save time - Instead of going back and forth with an AI system trying to get what you want, a well-crafted prompt can get you there in one go.
- Unlock hidden capabilities - Many AI systems can do amazing things, but only if you know how to ask! Prompt engineering helps you tap into capabilities you might not know exist.
- Gain a valuable skill - As Deepseek and other AI models become more integrated into everyday life, knowing how to effectively communicate with these systems is becoming as important as knowing how to use a smartphone.
- Take control - Rather than accepting whatever an AI gives you, prompt engineering puts you in the driver's seat of the interaction.
Real-World Uses of Prompt Engineering
Prompt Engineering is used (or at least, can be used) in all sorts of real life situations. For example, try and come up with the prompts that you would use for at least 5 examples below. How different are the prompts? How did you have to structure some of them differently?
For School Projects
- Transform a vague homework assignment into specific questions that AI can help you explore
- Generate creative writing prompts or story ideas based on specific themes
- Create study guides that focus on exactly what you need to learn
For Creative Projects
- Design detailed image prompts for AI art generators to create exactly the visual you're imagining
- Craft character profiles that help AI generate consistent dialogue for stories
- Develop music creation prompts that specify genre, mood, and instruments
For Practical Tasks
- Write prompts that help AI break down complex problems into manageable steps
- Create templates for emails, essays, or other writing projects
- Generate code snippets by describing exactly what functionality you need
For Learning
- Design prompts that challenge AI to explain concepts at different levels of complexity
- Create scenarios where AI can simulate debates between different viewpoints
- Transform dense information into easily understandable formats
Tips for Better Prompt Engineering
- Be specific - Include details about format, length, style, audience, and purpose
- Use examples - Show the AI what good output looks like
- Break it down - Complex tasks work better when broken into steps
- Experiment - Try different approaches and see what works best
- Iterate - Use the AI's response to refine your prompt and try again
Remember: Prompt engineering isn't about tricking AI or finding hacks - it's about clear communication and collaboration with these powerful tools!
Running Deepseek Locally with Langchain and Ollama
Want to run Deepseek on your own computer? You can do it with Langchain and Ollama! Here's how:
Step 1: Install the Required Package
First, open your terminal or command prompt and install the Langchain-Ollama package:
Step 2: Write the Python Code
Create a new Python file and add this code:
Step 3: Run and See the Results
When you run this code, Deepseek will process your question and produce output like this:
What's Happening Here?
- The code sets up a template that tells Deepseek to think step by step
- We create a prompt template that can take variables (like our question)
- We connect to the Deepseek model (the 7B parameter version)
- We create a simple chain: prompt model
- We run the chain with our question
Notice how Deepseek shows its thinking process with the
<think>