Downloads · 30 days
9
2% of all-time downloads
bigpang/xlmr-tatoeba
xlmr-tatoeba is a text classification model from bigpang. Use it when you need a label for a piece of text. It is set up for transformers.
from optimum.onnxruntime import ORTModelForSequenceClassification from transformers import AutoModelForSequenceClassification, AutoTokenizer, pipeline
Downloads · 30 days
9
2% of all-time downloads
All-time downloads
570
Public
Repo size
14.5 GB
Likes
1
Public
Click a slice to open those files.
.bin1.1 GB · 98%
From the Hugging Face model README
from optimum.onnxruntime import ORTModelForSequenceClassification from transformers import AutoModelForSequenceClassification, AutoTokenizer, pipeline
def convert(path, onnx_path, onnx_path): onnx_model = ORTModelForSequenceClassification.from_pretrained(path, from_transformers=True) tokenizer = AutoTokenizer.from_pretrained(path)
onnx_model.save_pretrained(onnx_path)
tokenizer.save_pretrained(onnx_path)
def load_model(model_name): model = AutoModelForSequenceClassification.from_pretrained(model_name) tokenizer = AutoTokenizer.from_pretrained(model_name) text_classification_pipeline = pipeline("text-classification", model=model, tokenizer=tokenizer) print(text_classification_pipeline('这是一个简单的demo,用来防止忘记')) return text_classification_pipeline
def load_onnx_model(onnx_path): lang_tokenizer = AutoTokenizer.from_pretrained(onnx_path) lang_model = ORTModelForSequenceClassification.from_pretrained(onnx_path) lang_detecter = pipeline("text-classification", model=lang_model, tokenizer=lang_tokenizer, truncation=True) print(lang_detecter('这是一个简单的demo,用来防止忘记')) return lang_detecter