LLaMA-2 下载&demo利用

打印 上一主题 下一主题

主题 724|帖子 724|积分 2172

1. LLaMA-2 下载&demo利用

1.1 meta官网

llama2下载
在meta的官网 Meta website 举行下载申请(留意地域不要选择China会被ban)
主要有三类模子的参数:


  • llama 2
  • llama 2-code
  • llama 2-guard
一样寻常必要魔法下载
基本的步调:


  • meta官网申请llama2的利用(一样寻常是秒通过,可以把三类模子全部勾选)
  • 去 facebookresearch/llama: Inference code for LLaMA models 的GitHub中clone仓库到本地
  • 解压后运行download.sh脚本开始模子的下载
  • 复制邮件中给出的URL,选择必要的模子权重(7B 13B等)举行下载
下载原始的llama2-7b(13GB)和llama2-7b-chat(13G)
llama2利用
根据meta llama on GitHub的例子,我们可以按照以下步调来运行llama2:


  • 根据requirement.tx下载必要的库(fire, fairscale, sentencepiece)
  • 仓库提供了两个下令:
  1. torchrun --nproc_per_node 1 example_text_completion.py \
  2.     --ckpt_dir llama-2-7b/ \
  3.     --tokenizer_path tokenizer.model \
  4.     --max_seq_len 128 --max_batch_size 4
  5.    
  6. torchrun --nproc_per_node 1 example_chat_completion.py \
  7.     --ckpt_dir llama-2-7b-chat/ \
  8.     --tokenizer_path tokenizer.model \
  9.     --max_seq_len 512 --max_batch_size 6
复制代码
会得到以下结果:
  1. I believe the meaning of life is
  2. > to be happy. I believe we are all born with the potential to be happy. The meaning of life is to be happy, but the way to get there is not always easy.
  3. The meaning of life is to be happy. It is not always easy to be happy, but it is possible. I believe that
  4. ==================================
  5. .......
  6. ==================================
  7. Translate English to French:
  8.         
  9.         sea otter => loutre de mer
  10.         peppermint => menthe poivrée
  11.         plush girafe => girafe peluche
  12.         cheese =>
  13. > fromage
  14.         fish => poisson
  15.         giraffe => girafe
  16.         elephant => éléphant
  17.         cat => chat
  18.         giraffe => girafe
  19.         elephant => éléphant
  20.         cat => chat
  21.         giraffe => gira
  22. ==================================
复制代码
[code]......
==================================

System: Always answer with Haiku

User: I am going to Paris, what should I see?

> Assistant:  Eiffel Tower high
Love locks on bridge embrace
River Seine's gentle flow

==================================

System: Always answer with emojis

User: How to go from Beijing to NY?

> Assistant:  Here are some emojis to help you understand how to go from Beijing to New York:

回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

笑看天下无敌手

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表