Views
No views yet
text-generation-webuihuggingface-hub Python library:pip3 install huggingface-hubhuggingface-cli download andrijdavid/MiniMA-2-3B-GGUF MiniMA-2-3B-f16.gguf --local-dir . --local-dir-use-symlinks Falsehuggingface-cli download andrijdavid/MiniMA-2-3B-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 hf_transferHF_HUB_ENABLE_HF_TRANSFER to 1:HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download andrijdavid/MiniMA-2-3B-GGUF MiniMA-2-3B-f16.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 MiniMA-2-3B-f16.gguf --color -c 4096 --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 4096 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="./MiniMA-2-3B-f16.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="./MiniMA-2-3B-f16.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)
| Method | TFLOPs | MMLU (5-shot) | CEval (5-shot) | DROP (3-shot) | HumanEval (0-shot) | BBH (3-shot) | GSM8K (8-shot) |
|---|---|---|---|---|---|---|---|
| Mamba-2.8B | 4.6E9 | 25.58 | 24.74 | 15.72 | 7.32 | 29.37 | 3.49 |
| ShearedLLaMA-2.7B | 0.8E9 | 26.97 | 22.88 | 19.98 | 4.88 | 30.48 | 3.56 |
| BTLM-3B | 11.3E9 | 27.20 | 26.00 | 17.84 | 10.98 | 30.87 | 4.55 |
| StableLM-3B | 72.0E9 | 44.75 | 31.05 | 22.35 | 15.85 | 32.59 | 10.99 |
| Qwen-1.8B | 23.8E9 | 44.05 | 54.75 | 12.97 | 14.02 | 30.80 | 22.97 |
| Phi-2-2.8B | 159.9E9 | 56.74 | 34.03 | 30.74 | 46.95 | 44.13 | 55.42 |
| LLaMA-2-7B | 84.0E9 | 46.00 | 34.40 | 31.57 | 12.80 | 32.02 | 14.10 |
| MiniMA-3B | 4.0E9 | 28.51 | 28.23 | 22.50 | 10.98 | 31.61 | 8.11 |
| MiniChat-3B | 4.0E9 | 38.40 | 36.48 | 22.58 | 18.29 | 31.36 | 29.72 |
| MiniMA-2-3B | 13.4E9 | 40.14 | 44.65 | 23.10 | 14.63 | 31.43 | 8.87 |
| MiniChat-2-3B | 13.4E9 | 46.17 | 43.91 | 30.26 | 22.56 | 34.95 | 38.13 |
1import torch
2
3from transformers import AutoModelForCausalLM, AutoTokenizer
4
5# MiniMA
6tokenizer = AutoTokenizer.from_pretrained("GeneZC/MiniMA-2-3B", use_fast=False)
7# GPU.
8model = AutoModelForCausalLM.from_pretrained("GeneZC/MiniMA-2-3B", use_cache=True, device_map="auto", torch_dtype=torch.float16).eval()
9# CPU.
10# model = AutoModelForCausalLM.from_pretrained("GeneZC/MiniMA-2-3B", use_cache=True, device_map="cpu", torch_dtype=torch.float16).eval()
11
12prompt = "Question: Sherrie tells the truth. Vernell says Sherrie tells the truth. Alexis says Vernell lies. Michaela says Alexis tells the truth. Elanor says Michaela tells the truth. Does Elanor tell the truth?\nAnswer: No\n\nQuestion: Kristian lies. Sherrie says Kristian lies. Delbert says Sherrie lies. Jerry says Delbert tells the truth. Shalonda says Jerry tells the truth. Does Shalonda tell the truth?\nAnswer: No\n\nQuestion: Vina tells the truth. Helene says Vina lies. Kandi says Helene tells the truth. Jamey says Kandi lies. Ka says Jamey lies. Does Ka tell the truth?\nAnswer: No\n\nQuestion: Christie tells the truth. Ka says Christie tells the truth. Delbert says Ka lies. Leda says Delbert tells the truth. Lorine says Leda tells the truth. Does Lorine tell the truth?\nAnswer:"
13input_ids = tokenizer([prompt]).input_ids
14output_ids = model.generate(
15 torch.as_tensor(input_ids).cuda(),
16 do_sample=True,
17 temperature=0.7,
18 max_new_tokens=1024,
19)
20output_ids = output_ids[0][len(input_ids[0]):]
21output = tokenizer.decode(output_ids, skip_special_tokens=True).strip()
22# output: "No"1@article{zhang2023law,
2 title={Towards the Law of Capacity Gap in Distilling Language Models},
3 author={Zhang, Chen and Song, Dawei and Ye, Zheyu and Gao, Yan},
4 year={2023},
5 url={https://arxiv.org/abs/2311.07052}
6}