Skip to content

Latest commit

 

History

History
359 lines (267 loc) · 7.03 KB

File metadata and controls

359 lines (267 loc) · 7.03 KB

🚀 Quick Start Guide

Get up and running with LLM Playground in under 10 minutes!


⚡ Super Quick Start

# 1. Install Ollama (if not already installed)
brew install ollama  # macOS

# 2. Start Ollama
ollama serve  # In one terminal

# 3. Setup project (in another terminal)
cd llm_101
./setup.sh

# 4. Launch!
streamlit run app.py

Your browser will open to the playground!


📖 What to Read First

If you want to jump right in:

  1. This file (you're here!) ✓
  2. Launch streamlit run app.py
  3. Click around and experiment!

If you want to understand deeply:

  1. README.md - Project overview
  2. CONCEPTS.md - LLM theory
  3. TUTORIAL.md - Guided experiments

If you're technical:

  1. ARCHITECTURE.md - System design
  2. Look at models/ and experiments/ code
  3. Extend with your own features!

🎯 Your First 5 Minutes

Step 1: Connect to Model (1 min)

  1. Open the Streamlit app
  2. In sidebar, click "🔌 Connect to Model"
  3. Wait for "✅ Connected" message

Step 2: Try Quick Chat (2 min)

  1. Go to "💬 Quick Chat" tab
  2. Type: "Explain machine learning in one sentence"
  3. Click "🚀 Generate"
  4. Watch the magic happen!

Step 3: Play with Temperature (2 min)

  1. Go to "🌡️ Temperature" tab
  2. Keep the default prompt
  3. Test temperatures: 0.1, 0.7, 1.5
  4. Click "🧪 Run Temperature Test"
  5. Compare the outputs!

🎓 Your First Hour

Experiment 1: Zero-Shot (10 min)

Try different tasks without examples:

  • Sentiment analysis
  • Question answering
  • Code generation

Observe: How accurate is the model?

Experiment 2: Few-Shot (10 min)

Add examples and see improvement:

  • Compare zero-shot vs few-shot
  • Notice accuracy increase
  • Understand the cost (more tokens)

Experiment 3: Temperature (15 min)

Find the sweet spot:

  • Test: 0.1 (deterministic)
  • Test: 0.7 (balanced)
  • Test: 1.5 (creative)

Question: Which is best for facts? For stories?

Experiment 4: Prompt Sensitivity (10 min)

Small changes, big differences:

  • Try "tone_changes" variations
  • See how outputs differ
  • Learn prompt engineering!

Experiment 5: View Logs (15 min)

Analyze your experiments:

  • Go to "📋 Logs" tab
  • Review your interactions
  • Look for patterns

📚 Learning Path

Day 1: Basics

  • ✅ Setup and first experiments
  • ✅ Understand temperature
  • ✅ Try different prompts

Day 2: Theory

  • ✅ Read CONCEPTS.md
  • ✅ Understand transformers
  • ✅ Learn about tokens

Day 3: Practice

  • ✅ Follow TUTORIAL.md
  • ✅ Complete all experiments
  • ✅ Analyze your logs

Week 2: Advanced

  • ✅ Read LEARNING_OUTCOMES.md
  • ✅ Try follow-up experiments
  • ✅ Build a mini-project

🎯 Common Use Cases

1. Learning LLMs

# Read theory
cat CONCEPTS.md

# Launch interactive playground
streamlit run app.py

# Experiment systematically

2. Prompt Engineering

# Quick testing
python cli.py generate "Your prompt here"

# Compare variations
# Use Streamlit "Sensitivity" tab

3. Model Comparison

# Test different models
ollama pull mistral
ollama pull phi

# Compare in Streamlit
# Switch models in sidebar

4. Cost Estimation

# Check logs for token usage
cat logs/*.jsonl | jq '.metrics.total_tokens'

# Calculate costs
# (automatic in logs)

🔧 Troubleshooting

"Could not connect to Ollama"

# Start Ollama
ollama serve

# Verify it's running
curl http://localhost:11434/api/tags

"Model not found"

# Pull the model
ollama pull llama2

# List available models
ollama list

"Import error"

# Activate virtual environment
source venv/bin/activate

# Reinstall dependencies
pip install -r requirements.txt

"Streamlit won't start"

# Check Python version (need 3.8+)
python --version

# Reinstall Streamlit
pip install --upgrade streamlit

💡 Pro Tips

Tip 1: Save Good Prompts

Create a prompt library in a text file:

# good_prompts.txt
Explain [topic] in simple terms for a beginner
Write a [type] story about [subject] with a [tone] tone
Classify this as [categories]: [text]

Tip 2: Batch Experiments

Use the CLI for automation:

# Test multiple prompts
for temp in 0.1 0.5 0.9; do
    python cli.py generate "Your prompt" --temperature $temp
done

Tip 3: Analyze Logs

Use jq to query logs:

# Average latency
cat logs/*.jsonl | jq '.metrics.latency_ms' | awk '{sum+=$1} END {print sum/NR}'

# Total tokens used
cat logs/*.jsonl | jq '.metrics.total_tokens' | awk '{sum+=$1} END {print sum}'

Tip 4: Compare Models Side-by-Side

Open two terminal windows:

# Terminal 1: llama2
python cli.py generate "Test prompt" --model llama2

# Terminal 2: mistral
python cli.py generate "Test prompt" --model mistral

📊 Understanding the Output

Metrics Explained

Tokens:

  • Prompt tokens: Your input
  • Completion tokens: Model output
  • Total tokens: Sum (used for billing)

Latency:

  • Time from request to response
  • Includes: network + processing + generation
  • Lower is better (but quality matters more!)

Cost:

  • $0.00 for Ollama (local)
  • ~$0.0005-0.03 per 1K tokens for OpenAI
  • Check logs for your actual usage

🎯 Next Steps

Beginner

  1. ✅ Complete first hour experiments
  2. ✅ Read key sections of CONCEPTS.md
  3. ✅ Try 10+ different prompts
  4. ✅ Understand temperature effects

Intermediate

  1. ✅ Complete full TUTORIAL.md
  2. ✅ Read all of CONCEPTS.md
  3. ✅ Try all experiment types
  4. ✅ Analyze your logs

Advanced

  1. ✅ Read LEARNING_OUTCOMES.md
  2. ✅ Implement follow-up experiments
  3. ✅ Build a mini-project
  4. ✅ Read ARCHITECTURE.md
  5. ✅ Extend the system

📞 Getting Help

Documentation

  • README.md - Overview
  • CONCEPTS.md - Theory
  • TUTORIAL.md - Hands-on guide
  • ARCHITECTURE.md - Technical details

Code Examples

  • example.py - 4 working examples
  • experiments/ - Reusable patterns
  • app.py - Full UI implementation

Common Questions

Q: Which model should I use? A: Start with llama2. It's small, fast, and works well for learning.

Q: What's a good temperature? A: 0.7 is a good default. Lower (0.1-0.3) for facts, higher (1.0-1.5) for creativity.

Q: How many tokens can I use? A: Most models support 2K-4K tokens. Check context limits for your model.

Q: Is it free? A: Yes! Ollama is completely free for local use.

Q: Can I use GPT-4? A: Yes, if you have an OpenAI API key. Add it to .env file.


🎉 You're Ready!

You now know enough to start experimenting. The best way to learn is by doing!

Start here:

streamlit run app.py

Have fun learning! 🚀


📝 Quick Reference Card

Setup:          ./setup.sh
Web UI:         streamlit run app.py
CLI:            python cli.py --help
Example:        python example.py
List models:    ollama list
Pull model:     ollama pull <model>
View logs:      cat logs/*.jsonl
Theory:         cat CONCEPTS.md
Tutorial:       cat TUTORIAL.md

Bookmark this page for quick reference!