当前位置:   article > 正文

LLaMA-2 下载&demo使用_llama下载

llama下载

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)
  • 仓库提供了两个命令:
torchrun --nproc_per_node 1 example_text_completion.py \
    --ckpt_dir llama-2-7b/ \
    --tokenizer_path tokenizer.model \
    --max_seq_len 128 --max_batch_size 4
    
torchrun --nproc_per_node 1 example_chat_completion.py \
    --ckpt_dir llama-2-7b-chat/ \
    --tokenizer_path tokenizer.model \
    --max_seq_len 512 --max_batch_size 6
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

会得到以下结果:

I believe the meaning of life is
> 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.
The meaning of life is to be happy. It is not always easy to be happy, but it is possible. I believe that

==================================
.......
==================================

Translate English to French:
        
        sea otter => loutre de mer
        peppermint => menthe poivrée
        plush girafe => girafe peluche
        cheese =>
> fromage
        fish => poisson
        giraffe => girafe
        elephant => éléphant
        cat => chat
        giraffe => girafe
        elephant => éléphant
        cat => chat
        giraffe => gira

==================================
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
......
==================================

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:

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/383735
推荐阅读
相关标签