Llama 3 매개변수 조정

Llama 3 다루기

Imtihan Ahmed

Machine Learning Engineer

매개변수는 무엇을 하나요?

from llama_cpp import Llama
llm = Llama(model_path="path/to/model.gguf")
output = llm("What are some ways to improve customer retention?")

품질, 무작위성, 길이 제어

Llama 3 다루기

매개변수는 무엇을 하나요?

  • 예: 제품 설명 생성

professional_site.png

→ 사실 기반, 간결해야 함

 

라이프스타일 지향 사이트

 

→ 더 몰입감 있고 창의적으로

Llama 3 다루기

Llama 3 디코딩 매개변수

$$

  • Llama의 동작 조정

$$

  • 서로 다른 톤에 맞게 디코딩 매개변수 사용

$$

  • 원시 출력을 읽기 쉬운 텍스트로 변환

매개변수로 Llama 동작 조정

Llama 3 다루기

Llama 3 디코딩 매개변수

$$

  • Temperature: 무작위성 제어
  • Top-K: 가장 가능성 높은 토큰만 선택하도록 제한
  • Top-P: 누적 확률로 선택 범위 조정
  • Max tokens: 응답 길이 제한

$$

Screenshot 2025-02-26 at 12.51.27.png

Llama 3 다루기

Temperature

  • 값은 보통 0~1 사이

  • 낮은 temperature(예: 0에 가까움):

    • 더 예측 가능한 응답
      A smartwatch with a heart rate monitor, GPS, and a long-lasting battery 
      for all-day tracking.
      
  • 높은 temperature(예: 1에 가까움):
    • 더 창의적인 응답
      Your personal fitness coach on your wrist - track every heartbeat, every step, 
      and every adventure without limits.
      
Llama 3 다루기

Top-k

  • Llama가 선택할 수 있는 가장 가능성 높은 단어의 개수를 제한

  • 낮은 k 값(예: 1):

    • 더 예측 가능한 응답
      Track fitness, stream music, and receive notifications with our sleek smartwatch.
      
  • 높은 k 값(예: 50):

    • 더 다양한 응답
      Experience the future with our cutting-edge smartwatch, featuring fitness tracking, music streaming, customizable notifications, personalized insights, and seamless smartphone integration always.
      
Llama 3 다루기

Top-p

  • 신뢰도에 따라 출력 단어 선택을 제어

  • 높은 top-p 값(예: 1에 가까움):

    • 더 다양한 응답
      Stay connected with our sleek smartwatch, featuring fitness tracking,
      music, and customizable notifications, perfect for fitness 
      enthusiasts and busy professionals.
      
  • 낮은 top-p 값(예: 0에 가까움):

    • 변화가 적음
      Smartwatch with fitness tracking and music control, perfect for workouts.
      
Llama 3 다루기

Max tokens

  • 응답 길이를 제한하는 데 사용
  • 응답의 토큰 수(단어 단위)

  • 낮은 max_tokens 값:

    Stay connected with our sleek smartwatch, featuring fitness tracking 
    and music control.
    
  • 높은 max_tokens 값:
    Stay connected with our sleek smartwatch, featuring fitness tracking, 
    music control, customizable notifications, and seamless smartphone 
    integration. Monitor your health, track your progress, and receive 
    alerts on your wrist. Perfect for fitness enthusiasts.
    
Llama 3 다루기

매개변수 조합하기

llm = Llama(model_path="path/to/model.gguf")

output_concise = llm(
    "Describe an electric car.",

temperature=0.2,
top_k=1,
top_p=0.4,
max_tokens=20
)
A fast, eco-friendly electric car with a long range and cutting-edge technology.
Llama 3 다루기

매개변수 조합하기

output_creative = llm(
    "Describe an electric car.",

temperature=0.8,
top_k=10,
top_p=0.9,
max_tokens=100
)
Glide into the future with an electric car that blends speed, luxury,
and sustainability. Silent yet powerful, it redefines the road ...
Llama 3 다루기

Ayo berlatih!

Llama 3 다루기

Preparing Video For Download...