Instructions to use DAMO-NLP-MT/polylm-13b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use DAMO-NLP-MT/polylm-13b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="DAMO-NLP-MT/polylm-13b", trust_remote_code=True)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("DAMO-NLP-MT/polylm-13b", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("DAMO-NLP-MT/polylm-13b", trust_remote_code=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use DAMO-NLP-MT/polylm-13b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "DAMO-NLP-MT/polylm-13b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "DAMO-NLP-MT/polylm-13b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/DAMO-NLP-MT/polylm-13b
- SGLang
How to use DAMO-NLP-MT/polylm-13b 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 "DAMO-NLP-MT/polylm-13b" \ --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": "DAMO-NLP-MT/polylm-13b", "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 "DAMO-NLP-MT/polylm-13b" \ --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": "DAMO-NLP-MT/polylm-13b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use DAMO-NLP-MT/polylm-13b with Docker Model Runner:
docker model run hf.co/DAMO-NLP-MT/polylm-13b
Tokenizer class LlamaTokenizer does not exist or is not currently imported.
Hello, I would love to use this model for my master thesis but unfortunately I get this error when trying to execute the example code. I installed sentencepiece and it is already lowercase, so the fixes that helped others are not working here.
I am happy about any suggestions. Thank you!
Please make sure you have cloned the latest model files. You can try to install the latest transformers (v4.31.0) and execute the following example code again:
# pip install accelerate
from transformers import AutoModelForCausalLM, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("DAMO-NLP-MT/polylm-13b", legacy=False, use_fast=False)
model = AutoModelForCausalLM.from_pretrained("DAMO-NLP-MT/polylm-13b", device_map="auto", trust_remote_code=True)
model.eval()
input_doc = f"Beijing is the capital of China.\nTranslate this sentence from English to Chinese."
inputs = tokenizer(input_doc, return_tensors="pt")
generate_ids = model.generate(inputs.input_ids, attention_mask=inputs.attention_mask, do_sample=False, num_beams=4, max_length=128, early_stopping=True)
decoded = tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
print(f">>> {decoded}")
### results
### Beijing is the capital of China.\nTranslate this sentence from English to Chinese.\\n北京是中华人民共和国的首都。\n ...
Yes, that solved my problem. Turned out I did have an older version of transformers and now it works like a charm! Thank you so much for the help and training this model!