You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to translate a large amount of text in Chinese into English. So I tried to use "AutoModelForSeq2SeqLM" instead of "Pipeline" to run parallelism on gpus. But I found that this was a different between the two results.
When using "Pipeline" as follows: pipe1 = pipeline("translation", model="Helsinki-NLP/opus-mt-zh-en") outputs1 = pipe1("比特币系统性能的428倍!世界第三代公链拥有方与上海这所高校达成合作") print(outputs1)
I got "That's 428 times the amount of Bitcoin's systematic power! The third generation of public chain owners in the world has made a partnership with Shanghai's high school."
However when using "AutoModelForSeq2SeqLM": tokenizer = AutoTokenizer.from_pretrained("Helsinki-NLP/opus-mt-zh-en") model = AutoModelForSeq2SeqLM.from_pretrained("Helsinki-NLP/opus-mt-zh-en") encoded_input = tokenizer(["比特币系统性能的428倍!世界第三代公链拥有方与上海这所高校达成合作"], return_tensors="pt", padding=True, truncation=True, max_length=512) output = model.generate(**encoded_input, max_new_tokens=128, num_beams=1, num_return_sequences=1) output = tokenizer.batch_decode(output, skip_special_tokens=True) print(output)
I got "The world's third generation public chain owners have worked with Shanghai's college."
It seems "AutoModelForSeq2SeqLM" just translate the later part of the Chinese sentence. I guess it is because the prefix for this task is missing, but I find "model.config.prefix" is None. Could you show me the prefix for this task and this model, or could you help me do translation in a right way with "AutoModelForSeq2SeqLM"?
I was trying to translate a large amount of text in Chinese into English. So I tried to use "AutoModelForSeq2SeqLM" instead of "Pipeline" to run parallelism on gpus. But I found that this was a different between the two results.
When using "Pipeline" as follows:
pipe1 = pipeline("translation", model="Helsinki-NLP/opus-mt-zh-en") outputs1 = pipe1("比特币系统性能的428倍!世界第三代公链拥有方与上海这所高校达成合作") print(outputs1)
I got "That's 428 times the amount of Bitcoin's systematic power! The third generation of public chain owners in the world has made a partnership with Shanghai's high school."
However when using "AutoModelForSeq2SeqLM":
tokenizer = AutoTokenizer.from_pretrained("Helsinki-NLP/opus-mt-zh-en") model = AutoModelForSeq2SeqLM.from_pretrained("Helsinki-NLP/opus-mt-zh-en") encoded_input = tokenizer(["比特币系统性能的428倍!世界第三代公链拥有方与上海这所高校达成合作"], return_tensors="pt", padding=True, truncation=True, max_length=512) output = model.generate(**encoded_input, max_new_tokens=128, num_beams=1, num_return_sequences=1) output = tokenizer.batch_decode(output, skip_special_tokens=True) print(output)
I got "The world's third generation public chain owners have worked with Shanghai's college."
It seems "AutoModelForSeq2SeqLM" just translate the later part of the Chinese sentence. I guess it is because the prefix for this task is missing, but I find "model.config.prefix" is None. Could you show me the prefix for this task and this model, or could you help me do translation in a right way with "AutoModelForSeq2SeqLM"?
The colab link is https://colab.research.google.com/drive/1OTi_Nc8x1UTFUufbx7HsJfhn4VCUCkAs?usp=sharing
The text was updated successfully, but these errors were encountered: