triton-inference-server / server

The Triton Inference Server provides an optimized cloud and edge inferencing solution.
https://docs.nvidia.com/deeplearning/triton-inference-server/user-guide/docs/index.html
BSD 3-Clause "New" or "Revised" License
8.2k stars 1.46k forks source link

UnicodeEncodeError when deploying Vietnamese n-gram language model on the Triton Inference Server. #2476

Closed ductho9799 closed 3 years ago

ductho9799 commented 3 years ago

I'm deploying a speech to text model on Triton Inference Server using Quartznet and n-gram language model for the Vietnamese language. I used Python Backend for this model. I have a problem with UnicodeEncode on Triton Inference Server when loading the Vietnamese character to decode with the beam search algorithm. Code: from nemo.collections.asr.modules import BeamSearchDecoderWithLM

vocab = [' ', "'", '-', '@', '+', '?', '-', '|', '\', '!', '%', '/', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'Á', 'Â', 'Ú', 'à', 'á', 'â', 'ã', 'è', 'é', 'ê', 'ì', 'í', 'ò', 'ó', 'ô', 'õ', 'ù', 'ú', 'ý', 'ă', 'Đ', 'đ', 'ĩ', 'ũ', 'ơ', 'ư', 'ạ', 'Ả', 'ả', 'ấ', 'ầ', 'ẩ', 'ẫ', 'ậ', 'ắ', 'ằ', 'ẳ', 'ẵ', 'ặ', 'ẹ', 'ẻ', 'ẽ', 'ế', 'ề', 'ể', 'ễ', 'ệ', 'ỉ', 'ị', 'ọ', 'ỏ', 'ố', 'ồ', 'ổ', 'ỗ', 'ộ', 'ớ', 'ờ', 'ở', 'ỡ', 'ợ', 'ụ', 'ủ', 'ứ', 'ừ', 'ử', 'ữ', 'ự', 'ỳ', 'ỷ', 'ỹ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9']

beam_search_lm = BeamSearchDecoderWithLM( vocab=vocab, beam_width=128, alpha=1.5, beta=1, lm_path=language_model_path, num_cpus=max(os.cpu_count(), 1), input_tensor=False, ) Error: UnicodeEncodeError: 'ascii' codec can't encode character '\u1ed9' in position 1: ordinal not in range(128).

Tabrizian commented 3 years ago

@ductho9799 Can you share your model.py file? We do support unicode in the Python backend. There is an example for it here:

https://github.com/triton-inference-server/server/blob/004cee086810657e079bdf65afff83f212666554/qa/L0_backend_python/python_test.py#L248

ductho9799 commented 3 years ago

@Tabrizian Thank you so much for your support, I tried again successfully with the latest version - 20.12.

Tabrizian commented 3 years ago

Great!