Text Classification
Transformers
Safetensors
Chinese
bert
macbert
weibo
intent-classification
text-embeddings-inference
Instructions to use lostsky-service/weibo-service-intent-macbert with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use lostsky-service/weibo-service-intent-macbert with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="lostsky-service/weibo-service-intent-macbert")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("lostsky-service/weibo-service-intent-macbert") model = AutoModelForSequenceClassification.from_pretrained("lostsky-service/weibo-service-intent-macbert", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download preprocess.py from lostsky-service/weibo-service-intent-macbert: direct link, hf CLI and curl.
- Browser
- Download file 884 Bytes
-
https://huggingface.co/lostsky-service/weibo-service-intent-macbert/resolve/main/preprocess.py
- Command line
-
hf download hf://lostsky-service/weibo-service-intent-macbert/preprocess.py
-
curl -L -o preprocess.py https://huggingface.co/lostsky-service/weibo-service-intent-macbert/resolve/main/preprocess.py
884 Bytes
| import hashlib | |
| import re | |
| VERSION = "remove-first-leading-supertopic-v1" | |
| PATTERN = re.compile(r"\A([\s\u200b\u200c\u200d\ufeff]*)(?:#[^#\r\n]*?\[超话\]#|#[^#\r\n]*?超话#)") | |
| def transform(text: str) -> str: | |
| return PATTERN.sub(r"\1", text, count=1) | |
| def fingerprint() -> str: | |
| return hashlib.sha256((VERSION + "\0" + PATTERN.pattern).encode("utf-8")).hexdigest() | |
| def self_test() -> None: | |
| cases = { | |
| "#光遇陪玩[超话]# 正文 #第二个[超话]#": " 正文 #第二个[超话]#", | |
| "\u200b #王者荣耀超话#正文": "\u200b 正文", | |
| "#普通标签# 正文": "#普通标签# 正文", | |
| "正文 #中间超话#": "正文 #中间超话#", | |
| "#唯一[超话]#": "", | |
| } | |
| for source, expected in cases.items(): | |
| if transform(source) != expected: | |
| raise RuntimeError(f"preprocess self-test failed: {source!r}") | |