Views
No views yet
A01B: SOIL WORKING IN AGRICULTURE OR FORESTRYB25J: MANIPULATORS; CHAMBERS PROVIDED WITH MANIPULATION DEVICESC07D: HETEROCYCLIC COMPOUNDSG06F: ELECTRIC DIGITAL DATA PROCESSINGH04L: TRANSMISSION OF DIGITAL INFORMATION1from transformers import BertForSequenceClassification, BertTokenizer
2import json
3import torch
4
5# Load model and tokenizer
6model = BertForSequenceClassification.from_pretrained('ZoeYou/patentbert-pytorch')
7tokenizer = BertTokenizer.from_pretrained('ZoeYou/patentbert-pytorch')
8
9# Inference example
10text = "A method for producing synthetic materials with enhanced thermal properties..."
11inputs = tokenizer(text, return_tensors="pt", max_length=512, truncation=True, padding=True)
12
13with torch.no_grad():
14 outputs = model(**inputs)
15 predictions = outputs.logits.softmax(dim=-1)
16
17# Get prediction
18predicted_class_id = predictions.argmax().item()
19confidence = predictions.max().item()
20
21# Use model labels (CPC codes)
22predicted_label = model.config.id2label[str(predicted_class_id)]
23
24print(f"Predicted CPC class: {predicted_label} (ID: {predicted_class_id})")
25print(f"Confidence: {confidence:.2%}")model.safetensors: Model weights (420 MB)config.json: Configuration with integrated CPC labelsvocab.txt: Tokenizer vocabularytokenizer_config.json: Tokenizer configurationlabels.json: Complete CPC label mapping (656 authentic labels)README.md: This documentation@article{patent_bert,
author = "Jieh-Sheng Lee and Jieh Hsiang",
title = "{PatentBERT: Patent classification with fine-tuning a pre-trained BERT model}",
journal = "World Patent Information",
volume = "61",
number = "101965",
year = "2020",
}