Instructions to use RUCAIBox/elmer with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use RUCAIBox/elmer with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="RUCAIBox/elmer")# Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("RUCAIBox/elmer") model = AutoModelForSeq2SeqLM.from_pretrained("RUCAIBox/elmer") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use RUCAIBox/elmer with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "RUCAIBox/elmer" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "RUCAIBox/elmer", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/RUCAIBox/elmer
- SGLang
How to use RUCAIBox/elmer 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 "RUCAIBox/elmer" \ --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": "RUCAIBox/elmer", "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 "RUCAIBox/elmer" \ --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": "RUCAIBox/elmer", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use RUCAIBox/elmer with Docker Model Runner:
docker model run hf.co/RUCAIBox/elmer
ELMER
The ELMER model was proposed in ELMER: A Non-Autoregressive Pre-trained Language Model for Efficient and Effective Text Generation by Junyi Li, Tianyi Tang, Wayne Xin Zhao, Jian-Yun Nie and Ji-Rong Wen.
The detailed information and instructions can be found https://github.com/RUCAIBox/ELMER.
Model Description
ELMER is an efficient and effective PLM for NAR text generation, which generates tokens at different layers by leveraging the early exit technique.
The architecture of ELMER is a variant of the standard Transformer encoder-decoder and poses three technical contributions:
- For decoder, we replace the original masked multi-head attention with bi-directional multi-head attention akin to the encoder. Therefore, ELMER dynamically adjusts the output length by emitting an end token "[EOS]" at any position.
- Leveraging early exit, ELMER injects "off-ramps" at each decoder layer, which make predictions with intermediate hidden states. If ELMER exits at the $l$-th layer, we copy the $l$-th hidden states to the subsequent layers.
- ELMER utilizes a novel pre-training objective, layer permutation language modeling (LPLM), to pre-train on the large-scale corpus. LPLM permutes the exit layer for each token from 1 to the maximum layer $L$.
Examples
To fine-tune ELMER on non-autoregressive text generation:
>>> from transformers import BartTokenizer as ElmerTokenizer
>>> from transformers import BartForConditionalGeneration as ElmerForConditionalGeneration
>>> tokenizer = ElmerTokenizer.from_pretrained("RUCAIBox/elmer")
>>> model = ElmerForConditionalGeneration.from_pretrained("RUCAIBox/elmer")
Citation
@article{lijunyi2022elmer,
title={ELMER: A Non-Autoregressive Pre-trained Language Model for Efficient and Effective Text Generation},
author={Li, Junyi and Tang, Tianyi and Zhao, Wayne Xin and Nie, Jian-Yun and Wen, Ji-Rong},
booktitle={EMNLP 2022},
year={2022}
}
- Downloads last month
- 764