How to use from the
Use from the
Transformers library
# Use a pipeline as a high-level helper
# Warning: Pipeline type "translation" is no longer supported in transformers v5.
# You must load the model directly (see below) or downgrade to v4.x with:
# 'pip install "transformers<5.0.0'
from transformers import pipeline

pipe = pipeline("translation", model="ENLP/mrasp", trust_remote_code=True)
# Load model directly
from transformers import AutoTokenizer, AutoModel

tokenizer = AutoTokenizer.from_pretrained("ENLP/mrasp", trust_remote_code=True)
model = AutoModel.from_pretrained("ENLP/mrasp", trust_remote_code=True)
Quick Links

一、项目介绍

此项目是参考github上优秀的机器翻译项目mRASP,将官方开源的fairseq预训练权重改写为transformers架构,使其能够更加方便使用。

二、使用方法

from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
model_path = 'ENLP/mrasp'
model = AutoModelForSeq2SeqLM.from_pretrained(model_path, trust_remote_code=True, cache_dir=model_path)
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True, cache_dir=model_path)
input_text = ["Welcome to download and use!"]
inputs = tokenizer(input_text, return_tensors="pt", padding=True, max_length=300, truncation=True)
result = model.generate(**inputs)
result = tokenizer.batch_decode(result, skip_special_tokens=True)
result = [pre.strip() for pre in result]
# ['欢迎下载和使用!']

三、使用说明

该模型支持32种语言,更多详细参考mRASP,此模型库的tokenizer仅针对中英双语进行优化,如果需要使用其他语言请 自行参考tokenization_bat.py进行修改。

四、其他模型

ENLP/mrasp2

Downloads last month
13
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support