Instructions to use razent/spbert-mlm-base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use razent/spbert-mlm-base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("question-answering", model="razent/spbert-mlm-base")# Load model directly from transformers import AutoTokenizer, AutoModelForMaskedLM tokenizer = AutoTokenizer.from_pretrained("razent/spbert-mlm-base") model = AutoModelForMaskedLM.from_pretrained("razent/spbert-mlm-base", device_map="auto") - Notebooks
- Google Colab
- Kaggle
| language: | |
| - code | |
| tags: | |
| - question-answering | |
| - knowledge-graph | |
| # SPBERT MLM (Initialized) | |
| ## Introduction | |
| Paper: [SPBERT: An Efficient Pre-training BERT on SPARQL Queries for Question Answering over Knowledge Graphs](https://arxiv.org/abs/2106.09997) | |
| Authors: _Hieu Tran, Long Phan, James Anibal, Binh T. Nguyen, Truong-Son Nguyen_ | |
| ## How to use | |
| For more details, do check out [our Github repo](https://github.com/heraclex12/NLP2SPARQL). | |
| Here is an example in Pytorch: | |
| ```python | |
| from transformers import AutoTokenizer, AutoModel | |
| tokenizer = AutoTokenizer.from_pretrained('razent/spbert-mlm-base') | |
| model = AutoModel.from_pretrained("razent/spbert-mlm-base") | |
| text = "select * where brack_open var_a var_b var_c sep_dot brack_close" | |
| encoded_input = tokenizer(text, return_tensors='pt') | |
| output = model(**encoded_input) | |
| ``` | |
| or Tensorflow | |
| ```python | |
| from transformers import AutoTokenizer, TFAutoModel | |
| tokenizer = AutoTokenizer.from_pretrained('razent/spbert-mlm-base') | |
| model = TFAutoModel.from_pretrained("razent/spbert-mlm-base") | |
| text = "select * where brack_open var_a var_b var_c sep_dot brack_close" | |
| encoded_input = tokenizer(text, return_tensors='tf') | |
| output = model(encoded_input) | |
| ``` | |
| ## Citation | |
| ``` | |
| @misc{tran2021spbert, | |
| title={SPBERT: An Efficient Pre-training BERT on SPARQL Queries for Question Answering over Knowledge Graphs}, | |
| author={Hieu Tran and Long Phan and James Anibal and Binh T. Nguyen and Truong-Son Nguyen}, | |
| year={2021}, | |
| eprint={2106.09997}, | |
| archivePrefix={arXiv}, | |
| primaryClass={cs.CL} | |
| } | |
| ``` |