Views
No views yet
text-generation-webuihuggingface-hub Python library:pip3 install huggingface-hubhuggingface-cli download LiteLLMs/OpenELM-1_1B-Instruct-GGUF Q4_0/Q4_0-00001-of-00001.gguf --local-dir . --local-dir-use-symlinks Falsehuggingface-cli download LiteLLMs/OpenELM-1_1B-Instruct-GGUF --local-dir . --local-dir-use-symlinks False --include='*Q4_K*gguf'huggingface-cli, please see: HF -> Hub Python Library -> Download files -> Download from the CLI.hf_transfer:pip3 install huggingface_hub[hf_transfer]HF_HUB_ENABLE_HF_TRANSFER to 1:HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download LiteLLMs/OpenELM-1_1B-Instruct-GGUF Q4_0/Q4_0-00001-of-00001.gguf --local-dir . --local-dir-use-symlinks Falseset HF_HUB_ENABLE_HF_TRANSFER=1 before the download command.llama.cpp from commit d0cee0d or later../main -ngl 35 -m Q4_0/Q4_0-00001-of-00001.gguf --color -c 2048 --temp 0.7 --repeat_penalty 1.1 -n -1 -p "<PROMPT>"-ngl 32 to the number of layers to offload to GPU. Remove it if you don't have GPU acceleration.-c 2048 to the desired sequence length. For extended sequence models - eg 8K, 16K, 32K - the necessary RoPE scaling parameters are read from the GGUF file and set by llama.cpp automatically. Note that longer sequence lengths require much more resources, so you may need to reduce this value.-p <PROMPT> argument with -i -instext-generation-webui1# Base ctransformers with no GPU acceleration
2pip install llama-cpp-python
3# With NVidia CUDA acceleration
4CMAKE_ARGS="-DLLAMA_CUBLAS=on" pip install llama-cpp-python
5# Or with OpenBLAS acceleration
6CMAKE_ARGS="-DLLAMA_BLAS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS" pip install llama-cpp-python
7# Or with CLBLast acceleration
8CMAKE_ARGS="-DLLAMA_CLBLAST=on" pip install llama-cpp-python
9# Or with AMD ROCm GPU acceleration (Linux only)
10CMAKE_ARGS="-DLLAMA_HIPBLAS=on" pip install llama-cpp-python
11# Or with Metal GPU acceleration for macOS systems only
12CMAKE_ARGS="-DLLAMA_METAL=on" pip install llama-cpp-python
13# In windows, to set the variables CMAKE_ARGS in PowerShell, follow this format; eg for NVidia CUDA:
14$env:CMAKE_ARGS = "-DLLAMA_OPENBLAS=on"
15pip install llama-cpp-python1from llama_cpp import Llama
2# Set gpu_layers to the number of layers to offload to GPU. Set to 0 if no GPU acceleration is available on your system.
3llm = Llama(
4 model_path="./Q4_0/Q4_0-00001-of-00001.gguf", # Download the model file first
5 n_ctx=32768, # The max sequence length to use - note that longer sequence lengths require much more resources
6 n_threads=8, # The number of CPU threads to use, tailor to your system and the resulting performance
7 n_gpu_layers=35 # The number of layers to offload to GPU, if you have GPU acceleration available
8)
9# Simple inference example
10output = llm(
11 "<PROMPT>", # Prompt
12 max_tokens=512, # Generate up to 512 tokens
13 stop=["</s>"], # Example stop token - not necessarily correct for this specific model! Please check before using.
14 echo=True # Whether to echo the prompt
15)
16# Chat Completion API
17llm = Llama(model_path="./Q4_0/Q4_0-00001-of-00001.gguf", chat_format="llama-2") # Set chat_format according to the model you are using
18llm.create_chat_completion(
19 messages = [
20 {"role": "system", "content": "You are a story writing assistant."},
21 {
22 "role": "user",
23 "content": "Write a story about llamas."
24 }
25 ]
26)generate_openelm.py.python generate_openelm.py --model apple/OpenELM-1_1B-Instruct --hf_access_token [HF_ACCESS_TOKEN] --prompt 'Once upon a time there was' --generate_kwargs repetition_penalty=1.2generate_kwargs. As an example, to speedup the inference, you can try lookup token speculative generation by passing the prompt_lookup_num_tokens argument as follows:python generate_openelm.py --model apple/OpenELM-1_1B-Instruct --hf_access_token [HF_ACCESS_TOKEN] --prompt 'Once upon a time there was' --generate_kwargs repetition_penalty=1.2 prompt_lookup_num_tokens=10assistant_model argument, for example:python generate_openelm.py --model apple/OpenELM-1_1B-Instruct --hf_access_token [HF_ACCESS_TOKEN] --prompt 'Once upon a time there was' --generate_kwargs repetition_penalty=1.2 --assistant_model [SMALLER_MODEL]1
2# install public lm-eval-harness
3
4harness_repo="public-lm-eval-harness"
5git clone https://github.com/EleutherAI/lm-evaluation-harness ${harness_repo}
6cd ${harness_repo}
7# use main branch on 03-15-2024, SHA is dc90fec
8git checkout dc90fec
9pip install -e .
10cd ..
11
12# 66d6242 is the main branch on 2024-04-01
13pip install datasets@git+https://github.com/huggingface/datasets.git@66d6242
14pip install tokenizers>=0.15.2 transformers>=4.38.2 sentencepiece>=0.2.0
151
2# OpenELM-1_1B-Instruct
3hf_model=apple/OpenELM-1_1B-Instruct
4
5# this flag is needed because lm-eval-harness set add_bos_token to False by default, but OpenELM uses LLaMA tokenizer which requires add_bos_token to be True
6tokenizer=meta-llama/Llama-2-7b-hf
7add_bos_token=True
8batch_size=1
9
10mkdir lm_eval_output
11
12shot=0
13task=arc_challenge,arc_easy,boolq,hellaswag,piqa,race,winogrande,sciq,truthfulqa_mc2
14lm_eval --model hf \
15 --model_args pretrained=${hf_model},trust_remote_code=True,add_bos_token=${add_bos_token},tokenizer=${tokenizer} \
16 --tasks ${task} \
17 --device cuda:0 \
18 --num_fewshot ${shot} \
19 --output_path ./lm_eval_output/${hf_model//\//_}_${task//,/_}-${shot}shot \
20 --batch_size ${batch_size} 2>&1 | tee ./lm_eval_output/eval-${hf_model//\//_}_${task//,/_}-${shot}shot.log
21
22shot=5
23task=mmlu,winogrande
24lm_eval --model hf \
25 --model_args pretrained=${hf_model},trust_remote_code=True,add_bos_token=${add_bos_token},tokenizer=${tokenizer} \
26 --tasks ${task} \
27 --device cuda:0 \
28 --num_fewshot ${shot} \
29 --output_path ./lm_eval_output/${hf_model//\//_}_${task//,/_}-${shot}shot \
30 --batch_size ${batch_size} 2>&1 | tee ./lm_eval_output/eval-${hf_model//\//_}_${task//,/_}-${shot}shot.log
31
32shot=25
33task=arc_challenge,crows_pairs_english
34lm_eval --model hf \
35 --model_args pretrained=${hf_model},trust_remote_code=True,add_bos_token=${add_bos_token},tokenizer=${tokenizer} \
36 --tasks ${task} \
37 --device cuda:0 \
38 --num_fewshot ${shot} \
39 --output_path ./lm_eval_output/${hf_model//\//_}_${task//,/_}-${shot}shot \
40 --batch_size ${batch_size} 2>&1 | tee ./lm_eval_output/eval-${hf_model//\//_}_${task//,/_}-${shot}shot.log
41
42shot=10
43task=hellaswag
44lm_eval --model hf \
45 --model_args pretrained=${hf_model},trust_remote_code=True,add_bos_token=${add_bos_token},tokenizer=${tokenizer} \
46 --tasks ${task} \
47 --device cuda:0 \
48 --num_fewshot ${shot} \
49 --output_path ./lm_eval_output/${hf_model//\//_}_${task//,/_}-${shot}shot \
50 --batch_size ${batch_size} 2>&1 | tee ./lm_eval_output/eval-${hf_model//\//_}_${task//,/_}-${shot}shot.log
511@article{mehtaOpenELMEfficientLanguage2024,
2 title = {{OpenELM}: {An} {Efficient} {Language} {Model} {Family} with {Open} {Training} and {Inference} {Framework}},
3 shorttitle = {{OpenELM}},
4 url = {https://arxiv.org/abs/2404.14619v1},
5 language = {en},
6 urldate = {2024-04-24},
7 journal = {arXiv.org},
8 author = {Mehta, Sachin and Sekhavat, Mohammad Hossein and Cao, Qingqing and Horton, Maxwell and Jin, Yanzi and Sun, Chenfan and Mirzadeh, Iman and Najibi, Mahyar and Belenko, Dmitry and Zatloukal, Peter and Rastegari, Mohammad},
9 month = apr,
10 year = {2024},
11}
12
13@inproceedings{mehta2022cvnets,
14 author = {Mehta, Sachin and Abdolhosseini, Farzad and Rastegari, Mohammad},
15 title = {CVNets: High Performance Library for Computer Vision},
16 year = {2022},
17 booktitle = {Proceedings of the 30th ACM International Conference on Multimedia},
18 series = {MM '22}
19}