Instructions to use abhinavkulkarni/VMware-open-llama-7b-open-instruct-w4-g128-awq with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use abhinavkulkarni/VMware-open-llama-7b-open-instruct-w4-g128-awq with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="abhinavkulkarni/VMware-open-llama-7b-open-instruct-w4-g128-awq")# Load model directly from transformers import AutoTokenizer, AutoModelForMultimodalLM tokenizer = AutoTokenizer.from_pretrained("abhinavkulkarni/VMware-open-llama-7b-open-instruct-w4-g128-awq") model = AutoModelForMultimodalLM.from_pretrained("abhinavkulkarni/VMware-open-llama-7b-open-instruct-w4-g128-awq") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use abhinavkulkarni/VMware-open-llama-7b-open-instruct-w4-g128-awq with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "abhinavkulkarni/VMware-open-llama-7b-open-instruct-w4-g128-awq" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "abhinavkulkarni/VMware-open-llama-7b-open-instruct-w4-g128-awq", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/abhinavkulkarni/VMware-open-llama-7b-open-instruct-w4-g128-awq
- SGLang
How to use abhinavkulkarni/VMware-open-llama-7b-open-instruct-w4-g128-awq with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "abhinavkulkarni/VMware-open-llama-7b-open-instruct-w4-g128-awq" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "abhinavkulkarni/VMware-open-llama-7b-open-instruct-w4-g128-awq", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "abhinavkulkarni/VMware-open-llama-7b-open-instruct-w4-g128-awq" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "abhinavkulkarni/VMware-open-llama-7b-open-instruct-w4-g128-awq", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use abhinavkulkarni/VMware-open-llama-7b-open-instruct-w4-g128-awq with Docker Model Runner:
docker model run hf.co/abhinavkulkarni/VMware-open-llama-7b-open-instruct-w4-g128-awq
| license: cc | |
| language: | |
| - en | |
| tags: | |
| - AWQ | |
| inference: false | |
| # VMware/open-llama-7B-open-instruct (4-bit 128g AWQ Quantized) | |
| [Instruction-tuned version](https://huggingface.co/VMware/open-llama-7b-open-instruct) of the fully trained [Open LLama 7B](https://huggingface.co/openlm-research/open_llama_7b) model. | |
| This model is a 4-bit 128 group size AWQ quantized model. For more information about AWQ quantization, please click [here](https://github.com/mit-han-lab/llm-awq). | |
| ## Model Date | |
| July 5, 2023 | |
| ## Model License | |
| Please refer to original OpenLLaMa model license ([link](https://huggingface.co/VMware/open-llama-7b-open-instruct)). | |
| Please refer to the AWQ quantization license ([link](https://github.com/llm-awq/blob/main/LICENSE)). | |
| ## CUDA Version | |
| This model was successfully tested on CUDA driver v530.30.02 and runtime v11.7 with Python v3.10.11. Please note that AWQ requires NVIDIA GPUs with compute capability of `8.0` or higher. | |
| For Docker users, the `nvcr.io/nvidia/pytorch:23.06-py3` image is runtime v12.1 but otherwise the same as the configuration above and has also been verified to work. | |
| ## How to Use | |
| ```bash | |
| git clone https://github.com/mit-han-lab/llm-awq \ | |
| && cd llm-awq \ | |
| && git checkout f084f40bd996f3cf3a0633c1ad7d9d476c318aaa \ | |
| && pip install -e . \ | |
| && cd awq/kernels \ | |
| && python setup.py install | |
| ``` | |
| ```python | |
| import time | |
| import torch | |
| from awq.quantize.quantizer import real_quantize_model_weight | |
| from transformers import AutoModelForCausalLM, AutoConfig, AutoTokenizer, TextStreamer | |
| from accelerate import init_empty_weights, load_checkpoint_and_dispatch | |
| from huggingface_hub import snapshot_download | |
| model_name = "abhinavkulkarni/VMware-open-llama-7b-open-instruct" | |
| # Config | |
| config = AutoConfig.from_pretrained(model_name, trust_remote_code=True) | |
| # Tokenizer | |
| try: | |
| tokenizer = AutoTokenizer.from_pretrained(config.tokenizer_name, trust_remote_code=True) | |
| except: | |
| tokenizer = AutoTokenizer.from_pretrained(model_name, use_fast=False, trust_remote_code=True) | |
| streamer = TextStreamer(tokenizer, skip_special_tokens=True) | |
| # Model | |
| w_bit = 4 | |
| q_config = { | |
| "zero_point": True, | |
| "q_group_size": 128, | |
| } | |
| load_quant = snapshot_download(model_name) | |
| with init_empty_weights(): | |
| model = AutoModelForCausalLM.from_config(config=config, | |
| torch_dtype=torch.float16, trust_remote_code=True) | |
| real_quantize_model_weight(model, w_bit=w_bit, q_config=q_config, init_only=True) | |
| model.tie_weights() | |
| model = load_checkpoint_and_dispatch(model, load_quant, device_map="balanced") | |
| # Inference | |
| prompt = f'''What is the difference between nuclear fusion and fission? | |
| ###Response:''' | |
| input_ids = tokenizer(prompt, return_tensors='pt').input_ids.cuda() | |
| output = model.generate( | |
| inputs=input_ids, | |
| temperature=0.7, | |
| max_new_tokens=512, | |
| top_p=0.15, | |
| top_k=0, | |
| repetition_penalty=1.1, | |
| eos_token_id=tokenizer.eos_token_id, | |
| streamer=streamer) | |
| ``` | |
| ## Evaluation | |
| This evaluation was done using [LM-Eval](https://github.com/EleutherAI/lm-evaluation-harness). | |
| [Open-LLaMA-7B-Instruct](https://huggingface.co/VMware/open-llama-7b-open-instruct) | |
| | Task |Version| Metric | Value | |Stderr| | |
| |--------|------:|---------------|------:|---|------| | |
| |wikitext| 1|word_perplexity|11.7531| | | | |
| | | |byte_perplexity| 1.5853| | | | |
| | | |bits_per_byte | 0.6648| | | | |
| [Open-LLaMA-7B-Instruct (4-bit 128-group AWQ)](https://huggingface.co/abhinavkulkarni/VMware-open-llama-7b-open-instruct-w4-g128-awq) | |
| | Task |Version| Metric | Value | |Stderr| | |
| |--------|------:|---------------|------:|---|------| | |
| |wikitext| 1|word_perplexity|12.1840| | | | |
| | | |byte_perplexity| 1.5961| | | | |
| | | |bits_per_byte | 0.6745| | | | |
| ## Acknowledgements | |
| If you found OpenLLaMA useful in your research or applications, please cite using the following BibTeX: | |
| ``` | |
| @software{openlm2023openllama, | |
| author = {Geng, Xinyang and Liu, Hao}, | |
| title = {OpenLLaMA: An Open Reproduction of LLaMA}, | |
| month = May, | |
| year = 2023, | |
| url = {https://github.com/openlm-research/open_llama} | |
| } | |
| ``` | |
| ``` | |
| @software{together2023redpajama, | |
| author = {Together Computer}, | |
| title = {RedPajama-Data: An Open Source Recipe to Reproduce LLaMA training dataset}, | |
| month = April, | |
| year = 2023, | |
| url = {https://github.com/togethercomputer/RedPajama-Data} | |
| } | |
| ``` | |
| ``` | |
| @article{touvron2023llama, | |
| title={Llama: Open and efficient foundation language models}, | |
| author={Touvron, Hugo and Lavril, Thibaut and Izacard, Gautier and Martinet, Xavier and Lachaux, Marie-Anne and Lacroix, Timoth{\'e}e and Rozi{\`e}re, Baptiste and Goyal, Naman and Hambro, Eric and Azhar, Faisal and others}, | |
| journal={arXiv preprint arXiv:2302.13971}, | |
| year={2023} | |
| } | |
| ``` | |
| The model was quantized with AWQ technique. If you find AWQ useful or relevant to your research, please kindly cite the paper: | |
| ``` | |
| @article{lin2023awq, | |
| title={AWQ: Activation-aware Weight Quantization for LLM Compression and Acceleration}, | |
| author={Lin, Ji and Tang, Jiaming and Tang, Haotian and Yang, Shang and Dang, Xingyu and Han, Song}, | |
| journal={arXiv}, | |
| year={2023} | |
| } | |
| ``` | |