</>
Skip to content
Gen AI lessons (6/39)

Gen AI — LLMs

What are LLMs?

Large Language Models are neural networks trained on vast text data to understand and generate human-like text.

How they work

  1. Training: Learn patterns from billions of text samples
  2. Tokenization: Break text into tokens
  3. Prediction: Predict next token in sequence
  4. Generation: Chain predictions to create output

Major LLMs

ModelCompanyStrengths
GPT-4OpenAIReasoning, coding
ClaudeAnthropicSafety, analysis
GeminiGoogleMulti-modal
LLaMAMetaOpen source
MistralMistral AIEfficiency

Parameters

  • GPT-3.5: 175 billion parameters
  • GPT-4: Estimated 1.7 trillion parameters
  • Claude 3: Unknown, very large
  • LLaMA 2: 7B, 13B, 70B parameters

Temperature

# Low temperature: more focused, deterministic
response = client.chat.completions.create(
    model="gpt-4",
    messages=[{"role": "user", "content": "Write a poem"}],
    temperature=0.3
)

# High temperature: more creative, random
response = client.chat.completions.create(
    model="gpt-4",
    messages=[{"role": "user", "content": "Write a poem"}],
    temperature=0.9
)

Token limits

# Check token count
import tiktoken

encoder = tiktoken.encoding_for_model("gpt-4")
tokens = encoder.encode("Hello, world!")
print(len(tokens))  # 2 tokens

Mini Practice

  1. Compare responses at different temperatures
  2. Count tokens in a prompt
  3. Test different models
  4. Understand context windows

Up Next

Continue with Prompt Engineering - Crafting effective prompts.

Related Topics

Frequently Asked Questions about LLMs

What is LLMs in Gen AI?

LLMs is a fundamental concept in Gen AI. This lesson explains it step by step with clear examples, making it easy for beginners to understand.

How do I learn LLMs?

Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn LLMs.

Why is LLMs important in Gen AI?

LLMs is essential for Gen AI development. Understanding this concept will help you write better code and solve real-world problems more effectively.