使用 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?")


→ 需事实准确且简洁

→ 需更吸引人且有创意
$$
$$
$$

$$
$$

取值通常在 0 到 1 之间
低温度(如接近 0):
A smartwatch with a heart rate monitor, GPS, and a long-lasting battery
for all-day tracking.
Your personal fitness coach on your wrist - track every heartbeat, every step,
and every adventure without limits.
限制 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.
基于置信度控制输出词的选择
较高 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.
响应中的 token(词元)计数
较低 max_tokens 值:
Stay connected with our sleek smartwatch, featuring fitness tracking
and music control.
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.
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.
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