๐Ÿ’ฌ Basic Chat: Mastering Simple LLM Conversationsยถ

Welcome to the Basic Chat tutorial! This guide will help you understand how to have effective conversations with Large Language Models (LLMs) using CellMage.

๐ŸŽฏ What Youโ€™ll Learnยถ

In this tutorial, youโ€™ll discover:

  • How to structure effective prompts

  • The basics of conversation flow

  • How to refine and improve LLM responses

  • Best practices for clear communication with LLMs

๐Ÿง™โ€โ™‚๏ธ Getting Started with Basic Chatยถ

Before diving in, make sure you have:

  • CellMage installed (pip install cellmage)

  • An API key configured (see the Quickstart guide if needed)

  • The extension loaded in your notebook:

%load_ext cellmage

๐Ÿ—ฃ๏ธ Step 1: Your First Conversationยถ

Letโ€™s start with a simple conversation:

%%llm
Explain what makes a good prompt for an LLM. Keep it concise.

Youโ€™ll notice the LLM responds with a concise explanation. But what if we want to follow up on this topic?

๐Ÿ”„ Step 2: Follow-Up Questionsยถ

CellMage maintains conversation context automatically, allowing for natural follow-ups:

%%llm
Can you give me 3 specific examples of what you just explained?

The model remembers the previous discussion about good prompts and provides examples based on that context.

๐Ÿงฉ Step 3: Structuring More Complex Promptsยถ

For more detailed responses, structure your prompt with clear sections:

%%llm
I need information about Python's list comprehensions.

Please structure your response as follows:
1. A simple definition
2. Basic syntax with an example
3. Three advanced examples with explanations
4. Common pitfalls to avoid

Notice how providing a structure helps the LLM organize its response in a more useful way.

๐Ÿ”ฎ Step 4: Different Response Stylesยถ

You can request different styles or formats for responses:

%%llm
Explain the concept of "technical debt" in software development.
First, explain it as if I'm a senior developer.
Then, explain the same concept as if I'm a non-technical project manager.

This approach is useful when you need explanations tailored to different audiences.

๐ŸŒก๏ธ Step 5: Adjusting Temperatureยถ

The temperature parameter controls the creativity and randomness of responses:

# More deterministic, focused response
%%llm --temperature 0.1
List 5 best practices for writing clean code.

# More creative, varied response
%%llm --temperature 0.8
List 5 best practices for writing clean code.

Compare the two responses. The lower temperature produces more predictable, conventional advice, while the higher temperature might introduce more unique or creative suggestions.

โœ๏ธ Step 6: Refining Responsesยถ

If a response isnโ€™t quite what you wanted, you can ask for refinements:

%%llm
Your previous response about clean code was helpful, but could you focus more specifically on Python best practices and include examples for each?

This iterative refinement is one of the most powerful aspects of conversational LLMs.

๐ŸŽฎ Step 7: Controlling Response Lengthยถ

You can guide the LLM to produce shorter or longer responses:

%%llm
Explain quantum computing in 2-3 sentences only.

Or for a more detailed explanation:

%%llm
I'd like an in-depth explanation of quantum computing, including:
- Key principles and concepts
- How it differs from classical computing
- Current limitations and challenges
- Potential future applications

Please be thorough and provide examples where helpful.

๐Ÿ‘” Step 8: Setting the Toneยถ

You can request a specific tone for the response:

%%llm
Write a brief explanation of blockchain technology with an enthusiastic tone.

Now, explain the same concept with a more formal, academic tone.

๐Ÿšซ Step 9: Handling Unhelpful Responsesยถ

If you receive a response that isnโ€™t helpful, you can:

%%llm
That explanation wasn't quite what I was looking for. Let me clarify: I'm trying to understand blockchain specifically in terms of its application for supply chain tracking. Can you focus on that aspect?

๐Ÿง  Best Practices for Basic Chatยถ

  1. Be Clear and Specific: State exactly what you need

  2. Provide Context: Give background information when needed

  3. Structure Complex Requests: Use numbered lists or sections

  4. Iterate: Refine your questions based on previous responses

  5. Experiment: Try different prompts, temperatures, and approaches

๐Ÿ” Examining Your Chat Historyยถ

To review your conversation:

# Show your full conversation history
%llm_config --show-history

๐Ÿงน Starting Freshยถ

When you want to start a new conversation without previous context:

# Clear conversation history
%llm_config --clear-history

๐ŸŽ“ Whatโ€™s Next?ยถ

Now that youโ€™ve mastered the basics of chatting with LLMs through CellMage, explore these tutorials:

Happy chatting with your magical AI assistant! โœจ