Downloads · 30 days
3
11% of all-time downloads
fresher-freeze/legal_illegal_distinct_bert_model
legal_illegal_distinct_bert_model is a machine learning model from fresher-freeze. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This model is based on bert-base-chinese, but its max-length is 256.After fine tuned in local, the model now can classify the inputs into legal inputs and illegal inputs.
Downloads · 30 days
3
11% of all-time downloads
All-time downloads
27
Public
Parameters
102M
409 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors409 MB · 100%
From the Hugging Face model README
This model is based on bert-base-chinese, but its max-length is 256.After fine tuned in local, the model now can classify the inputs into legal inputs and illegal inputs.
the functionality of this model is simple, if it can't meet your requirement, you can train it furtherly.
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
Use the code below to get started with the model.
tokenizer = AutoTokenizer.from_pretrained("fresher-freeze/legal_illegal_distinct_bert_model")
model = AutoModelForSequenceClassification.from_pretrained("fresher-freeze/legal_illegal_distinct_bert_model")
if you need to use it to judge whether the input is relevant to laws, use this function:
def is_legal(text, threshold=0.6): # 阈值可以自行设置,大于0.5即可
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=256)
with torch.no_grad():
logits = model(**inputs).logits
prob = torch.softmax(logits, dim=-1)[0, 1].item()
return prob > threshold, prob