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
复制代码 会得到以下结果:
- 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
- ==================================
复制代码 [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:
|