Add GeoLM
Author: zekun-li
Pull request: yes

# What does this PR do?

Add a new model called **GeoLM** into the Transformer library. GeoLM is a language model based on BERT that facilitates **geospatial understanding** in NL documents. It is pretrained on world-wide OpenStreetMap (OSM), WikiData and Wikipedia data, and can be adapted to various geospatial related downstream tasks such as **toponym recognition** and **toponym linking**.

Paper not published yet. 

<!--
Congratulations! You've made it this far! You're not quite done yet though.

Once merged, your PR is going to appear in the release notes with the title you set, so make sure it's a great title that fully reflects the extent of your awesome contribution.

Then, please replace this with a description of the change and which issue is fixed (if applicable). Please also include relevant motivation and context. List any dependencies (if any) that are required for this change.

Once you're done, someone will review your PR shortly (see the section "Who can review?" below to tag some potential reviewers). They may suggest changes to make the code even better. If no one reviewed your PR after a week has passed, don't hesitate to post a new comment @-mentioning the same persons---sometimes notifications get lost.
-->

<!-- Remove if not applicable -->

## Model Weights:
* Pretrained GeoLM (ready-to-use for zero-shot toponym linking): [zekun-li/geolm-base-cased](https://huggingface.co/zekun-li/geolm-base-cased)
* Fine-tuned GeoLM for toponym recognition: [zekun-li/geolm-base-toponym-recognition](https://huggingface.co/zekun-li/geolm-base-toponym-recognition)


## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [x] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#start-contributing-pull-requests), Pull Request section?
- [ ] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link to it if that's the case.
- [x] Did you make sure to update the documentation with your changes? Here are the [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [x] Did you write any new necessary tests?

## Open Source Status: 
- [x] The model implementation is available in this PR
- [x] The model weights are available in HuggingFace model hub

## Who can review?

Anyone in the community is free to review the PR once the tests have passed. 

Feel free to tag members/contributors who may be interested in your PR:  @sgugger , @ArthurZucker and @younesbelkada

<!-- Your PR will be replied to more quickly if you can figure out the right person to tag with @

 If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**.
 Please tag fewer than 3 people.

Models:

- text models: @ArthurZucker and @younesbelkada
- vision models: @amyeroberts
- speech models: @sanchit-gandhi
- graph models: @clefourrier

Library:

- flax: @sanchit-gandhi
- generate: @gante
- pipelines: @Narsil
- tensorflow: @gante and @Rocketknight1
- tokenizers: @ArthurZucker
- trainer: @sgugger

Integrations:

- deepspeed: HF Trainer/Accelerate: @pacman100
- ray/raytune: @richardliaw, @amogkam

Documentation: @sgugger, @stevhliu and @MKhalusova

HF projects:

- accelerate: [different repo](https://github.com/huggingface/accelerate)
- datasets: [different repo](https://github.com/huggingface/datasets)
- diffusers: [different repo](https://github.com/huggingface/diffusers)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Maintained examples (not research project or legacy):

- Flax: @sanchit-gandhi
- PyTorch: @sgugger
- TensorFlow: @Rocketknight1

 -->


Comments:
Hi @zekun-li, thanks for opening this PR! 

The easiest and recommended way to make a model available in transformers is to add the modeling code directly on the hub: https://huggingface.co/docs/transformers/custom_models

This means, once working, the model can be found and used immediately without having to go through the PR process. We find this is a lot quicker as the bar for adding code into the library is high due to the maintenance cost of every new model, and so reviews take quite a while.

Let us know if you have any questions about how to add a model using this process. Looking forward to seeing this model in action!

> Hi @zekun-li, thanks for opening this PR!
> 
> The easiest and recommended way to make a model available in transformers is to add the modeling code directly on the hub: https://huggingface.co/docs/transformers/custom_models
> 
> This means, once working, the model can be found and used immediately without having to go through the PR process. We find this is a lot quicker as the bar for adding code into the library is high due to the maintenance cost of every new model, and so reviews take quite a while.
> 
> Let us know if you have any questions about how to add a model using this process. Looking forward to seeing this model in action!

Hi @amyeroberts Thanks a lot for the suggestion! 

Although this model is built upon BERT, it has a customized embedding layer and the model input can be different from BERT. This model can take geocoordinates as additional inputs. So unlike the changes of using different values for `num_layers` or `num_hidden_units`,  these changes require a different model structure, which is not supported in the existing models in Transformer.  

I wonder are these supported in the "Sharing custom models" approach? 

Thanks for your time!



@zekun-li Yes - you can add any model architecture directly onto the hub and share the model that way! In fact, it's an even more flexible way to define models as you don't have to be as strict about following certain library patterns. 

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.