What is Llama?

Working with Llama 3

Imtihan Ahmed

Machine Learning Engineer

Meet the instructor

 

  • Imtihan Ahmed
  • Machine Learning Engineer
  • Six years experience
  • AI at scale

  Instructor profile photo

Working with Llama 3

What is Llama 3?

 

  • Summarization

Screenshot 2025-02-19 at 11.01.25.png

Working with Llama 3

What is Llama 3?

 

  • Summarization

 

  • Data analysis

Screenshot 2025-02-19 at 11.01.16.png

Working with Llama 3

What is Llama 3?

 

  • Summarization

 

  • Data analysis

 

  • Coding assistant

Screenshot 2025-02-19 at 11.01.07.png

Working with Llama 3

What is Llama 3?

Screenshot 2025-02-19 at 11.32.24.png

Llama 3:

  • Developed by Meta
Working with Llama 3

What is Llama 3?

Screenshot 2025-02-19 at 11.32.18.png

Llama 3:

  • Developed by Meta
  • Text generation
Working with Llama 3

What is Llama 3?

Screenshot 2025-02-19 at 11.32.12.png

  • Developed by Meta
  • Text generation
  • Trained on massive dataset
    • Equivalent to 2000 Wikipedias
  • Open-source
Working with Llama 3

Why run Llama 3 locally

  • Example: industrial automation
    • Llama predicting maintenance needs

3.jpg

1 https://ai.meta.com/blog/aitomatic-built-with-llama/
Working with Llama 3

Why run Llama 3 locally

 

  • Privacy and security

Screenshot 2025-02-19 at 11.48.10.png

Working with Llama 3

Why run Llama 3 locally

 

  • Privacy and security

 

  • Cost efficiency

Screenshot 2025-02-19 at 11.48.03.png

Working with Llama 3

Why run Llama 3 locally

 

  • Privacy and security

 

  • Cost efficiency

 

  • Customization

Screenshot 2025-02-19 at 11.47.54.png

Working with Llama 3

Using Llama locally

  • Available locally when Python is installed

Screenshot 2025-02-19 at 11.54.07.png

  • Can be used through the llama-cpp-python library
  • Run pip install
pip install llama-cpp-python
Working with Llama 3

Asking questions to Llama

from llama_cpp import Llama

llm = Llama(model_path = "path/to/model.gguf")
output = llm("What are some ways to improve customer retention?")
  • Import Llama class
  • Initialize the LLM
    • Can send prompts and get responses
    • Model in GGUF format
  • Pass a question to the LLM
Working with Llama 3

Asking questions to Llama

 

  • Model receives the prompt
  • Processes the prompt
  • Returns a response

prompting.jpg

Working with Llama 3

Unpacking the output

  • The response is in a dictionary format
output
{'id': 'cmpl-af88304f-97b0-49f5-ba20-db87f86c4068',
 'object': 'text_completion',
 'created': 1715222298,
 'model': './Llama3-gguf-unsloth.Q4_K_M.gguf',
 'choices': [{'text': 'Improving customer retention is crucial for any business, as 
 it leads to increased revenue, positive word-of-mouth, and cost savings...'},
 ...]
}
Working with Llama 3

Unpacking the output

  • Access "text" from the 0 element of "choices"
output["choices"][0]["text"]
'Improving customer retention is crucial for any business, as 
 it leads to increased revenue, positive word-of-mouth, and cost savings. 
 Here are some effective ways to boost customer retention:
 1. Personalize the Customer Experience
 Tailor your interactions with customers based on their preferences, behaviors, and 
 purchase history. Use data and analytics to create personalized offers, 
 recommendations, and communications.
 2. Foster Strong Relationships
 Build strong, human connections with your customers. Train your...'
Working with Llama 3

Let's practice!

Working with Llama 3

Preparing Video For Download...