knowledge-computing/geolm-base-toponym-recognition
826
1---2language:3- en4thumbnail: url to a thumbnail used in social sharing5tags:6- toponym detection7- language model8- geospatial understanding9- geolm10license: cc-by-nc-2.011datasets:12- GeoWebNews13metrics:14- f115pipeline_tag: token-classification16widget:17- text: >-18 Minneapolis, officially the City of Minneapolis, is a city in the state of Minnesota19 and the county seat of Hennepin County. As of the 2020 census the population was 20 429,954, making it the largest city in Minnesota and the 46th-most-populous in the 21 United States. Nicknamed the "City of Lakes", Minneapolis is abundant in water, 22 with thirteen lakes, wetlands, the Mississippi River, creeks, and waterfalls.23- text: >-24 Los Angeles, often referred to by its initials L.A., is the most populous 25 city in California, the most populous U.S. state. It is the commercial, financial, 26 and cultural center of Southern California. Los Angeles is the second-most populous27 city in the United States after New York City, with a population of roughly 3.9 28 million residents within the city limits as of 2020.29---30 31# Model Card for GeoLM model for Toponym Recognition32 33<!-- Provide a quick summary of what the model is/does. [Optional] -->34A language model for detecting toponyms (i.e. place names) from sentences. We pretrain the GeoLM model on world-wide OpenStreetMap (OSM), WikiData and Wikipedia data, then fine-tune it for Toponym Recognition task on GeoWebNews dataset35 36[UPDATE]: Demo can be found here: https://huggingface.co/spaces/zekun-li/geolm-base-toponym-recognition-demo37 38# Model Details39 40## Model Description41 42<!-- Provide a longer summary of what this model is/does. -->43Pretrain the GeoLM model on world-wide OpenStreetMap (OSM), WikiData and Wikipedia data, then fine-tune it for Toponym Recognition task on GeoWebNews dataset44 45<!--- **Developed by:** UMN Knowledge Computing Lab & USC LUKA Lab -->46- **Model type:** Language model for geospatial understanding47- **Language(s) (NLP):** en48- **License:** cc-by-nc-2.049- **Parent Model:** https://huggingface.co/zekun-li/geolm-base-cased50<!---- **Resources for more information:** Zekun Li (li002666[Shift+2]umn.edu) -->51 52 53 54# Uses55 56<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->57This is a fine-tuned GeoLM model for toponym detection task. The inputs are sentences and outputs are detected toponyms. 58 59 60 61<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->62<!-- If the user enters content, print that. If not, but they enter a task in the list, use that. If neither, say "more info needed." -->63 64 65To use this model, please refer to the code below.66 67* **Option 1:** Load weights to a BERT model (Same procedure as the demo on the right side panel)68 69```python70 71import torch72from transformers import AutoModelForTokenClassification, AutoTokenizer73 74 75# Model name from Hugging Face model hub76model_name = "zekun-li/geolm-base-toponym-recognition"77 78# Load tokenizer and model79tokenizer = AutoTokenizer.from_pretrained(model_name)80model = AutoModelForTokenClassification.from_pretrained(model_name)81 82# Example input sentence83input_sentence = "Minneapolis, officially the City of Minneapolis, is a city in the state of Minnesota and the county seat of Hennepin County."84 85# Tokenize input sentence86tokens = tokenizer.encode(input_sentence, return_tensors="pt")87 88# Pass tokens through the model89outputs = model(tokens) 90 91# Retrieve predicted labels for each token92predicted_labels = torch.argmax(outputs.logits, dim=2)93 94predicted_labels = predicted_labels.detach().cpu().numpy()95 96# Decode predicted labels97predicted_labels = [model.config.id2label[label] for label in predicted_labels[0]]98 99# Print predicted labels100print(predicted_labels)101# ['O', 'B-Topo', 'O', 'O', 'O', 'O', 'O', 'B-Topo', 'O', 'O', 'O', 'O', 'O', 'O',102# 'O', 'O', 'B-Topo', 'O', 'O', 'O', 'O', 'O', 'B-Topo', 'I-Topo', 'I-Topo', 'O', 'O', 'O']103```104* **Option 2:** Load weights to a GeoLM model 105 106To appear soon107 108 109# Training Details110 111## Training Data112 113<!-- This should link to a Data Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->114 115**GeoWebNews** (Credit to [Gritta et al.](https://arxiv.org/pdf/1810.12368.pdf))116 117Download link: https://github.com/milangritta/Pragmatic-Guide-to-Geoparsing-Evaluation/blob/master/data/GWN.xml 118 119## Training Procedure120 121<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->122 123 124 125### Speeds, Sizes, Times126 127<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->128 129More information needed130 131# Evaluation132 133<!-- This section describes the evaluation protocols and provides the results. -->134 135## Testing Data & Metrics & Results136 137### Testing Data138 139<!-- This should link to a Data Card if possible. -->140 141More information needed142 143 144### Metrics145 146<!-- These are the evaluation metrics being used, ideally with a description of why. -->147 148More information needed149 150### Results 151 152More information needed153 154 155 156# Technical Specifications [optional]157 158## Model Architecture and Objective159 160More information needed161 162## Compute Infrastructure163 164More information needed165 166 167 168 169# Bias, Risks, and Limitations170 171<!-- This section is meant to convey both technical and sociotechnical limitations. -->172 173Significant research has explored bias and fairness issues with language models (see, e.g., [Sheng et al. (2021)](https://aclanthology.org/2021.acl-long.330.pdf) and [Bender et al. (2021)](https://dl.acm.org/doi/pdf/10.1145/3442188.3445922)). Predictions generated by the model may include disturbing and harmful stereotypes across protected classes; identity characteristics; and sensitive, social, and occupational groups.174 175 176 177# Citation178 179<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->180 181**BibTeX:**182 183More information needed184 185**APA:**186 187More information needed188 189 190 191# Model Card Author [optional]192 193<!-- This section provides another layer of transparency and accountability. Whose views is this model card representing? How many voices were included in its construction? Etc. -->194 195<!--- Zekun Li (li002666[Shift+2]umn.edu) -->196 197 