Skip to main content

AirLLM allows single 4GB GPU card to run 70B large language models without quantization, distillation or pruning.

Project description

AirLLM optimizes inference memory usage, allowing 70B large language models to run inference on a single 4GB GPU card. No quantization, distillation, pruning or other model compression techniques that would result in degraded model performance are needed.

AirLLM优化inference内存,4GB单卡GPU可以运行70B大语言模型推理。不需要任何损失模型性能的量化和蒸馏,剪枝等模型压缩。

Quickstart 如何使用?

install package 安装

First, install airllm pip package.

首先安装airllm包。

pip install airllm

如果找不到package,可能是因为默认的镜像问题。可以尝试制定原始镜像:

pip install -i https://pypi.org/simple/ airllm

Inference 推理

Then, initialize AirLLMLlama2, pass in the huggingface repo ID of the model being used, or the local path, and inference can be performed similar to a regular transformer model.

然后,初始化AirLLMLlama2,传入所使用模型的huggingface repo ID,或者本地路径即可类似于普通的transformer模型进行推理。

from airllm import AirLLMLlama2

MAX_LENGTH = 128
# could use hugging face model repo id:
model = AirLLMLlama2("garage-bAInd/Platypus2-70B-instruct")

# or use model's local path...
#model = AirLLMLlama2("/home/ubuntu/.cache/huggingface/hub/models--garage-bAInd--Platypus2-70B-instruct/snapshots/b585e74bcaae02e52665d9ac6d23f4d0dbc81a0f")

input_text = [
        'What is the capital of United States?',
        #'I like',
    ]

input_tokens = model.tokenizer(input_text,
    return_tensors="pt", 
    return_attention_mask=False, 
    truncation=True, 
    max_length=MAX_LENGTH, 
    padding=True)
           
generation_output = model.generate(
    input_tokens['input_ids'].cuda(), 
    max_new_tokens=2,
    use_cache=True,
    return_dict_in_generate=True)

output = model.tokenizer.decode(generation_output.sequences[0])

print(output)

Note: During inference, the original model will first be decomposed and saved layer-wise. Please ensure there is sufficient disk space in the huggingface cache directory.

注意:推理过程会首先将原始模型按层分拆,转存。请保证huggingface cache目录有足够的磁盘空间。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

airllm-0.9.2.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

airllm-0.9.2-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file airllm-0.9.2.tar.gz.

File metadata

  • Download URL: airllm-0.9.2.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.3

File hashes

Hashes for airllm-0.9.2.tar.gz
Algorithm Hash digest
SHA256 b937d9a2f5f1a19f273ce2791ad5a1dd66b4c1382bdce059bf1d18560107af06
MD5 a6fcf60d902875dc7dbdf12a47620215
BLAKE2b-256 1b90e6b04ba6cb7b3d01bb6211460b58c4d056fa8e3004038a1e5f80af057db0

See more details on using hashes here.

File details

Details for the file airllm-0.9.2-py3-none-any.whl.

File metadata

  • Download URL: airllm-0.9.2-py3-none-any.whl
  • Upload date:
  • Size: 16.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.3

File hashes

Hashes for airllm-0.9.2-py3-none-any.whl
Algorithm Hash digest
SHA256 01ae5cac4489c7e0144bb05faaf6dbcd8fcb32ee7920236fd2d878759aed1a54
MD5 b917b9114f0dd5afc6ab83ca1bfa5c05
BLAKE2b-256 551522dbb464d7a74d475a25d252d6588cf77348eb8c827f3dca9ce41f8ed6fe

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page