Views
No views yet
trust_remote_code=True and use the causal backend.pip install torch transformers safetensors pypinyin jiebapypinyin is required
for raw Mandarin-to-pinyin preprocessing. jieba is required when
use_jieba is true; this export was created with use_jieba=true.1from transformers import (
2 AutoConfig,
3 AutoModel,
4 AutoModelForCausalLM,
5 AutoModelForSequenceClassification,
6 AutoTokenizer,
7)
8
9model_path = "PATH_OR_REPO_ID"
10
11config = AutoConfig.from_pretrained(model_path, trust_remote_code=True)
12tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
13base_model = AutoModel.from_pretrained(model_path, trust_remote_code=True)
14model = AutoModelForCausalLM.from_pretrained(model_path, trust_remote_code=True)
15classifier = AutoModelForSequenceClassification.from_pretrained(
16 model_path,
17 trust_remote_code=True,
18 num_labels=3,
19)causaltokenizer(text), tokenizer(text, add_special_tokens=False),
and tokenizer(texts, padding=True, truncation=True, return_tensors="pt"). The model supports
output_hidden_states=True for representation extraction tasks.patch_pathlib_utf8_open=true in config.json.
When loaded with trust_remote_code=True, the config installs a narrow
Windows compatibility shim so later text-mode Path.open("r") calls
without an explicit encoding default to UTF-8. Set
PINYIN_CODE_DISABLE_UTF8_OPEN_PATCH=1 before loading the model to
disable that shim.hybridpinyin-codetrue