Giter Site home page Giter Site logo

poi_description's Introduction

Install

We recommend using Anaconda to create a python virtual environment.

Follow the instructions on the pytorch homepage to install pytorch. We recommend using version 1.10, other versions may work just as well.

Then install some other packages:

pip install -r requirements.txt

Usage

Setting Parameters

Firstly, modify the configuration files reasonably, including CONSTANTS.py and gs_model_config.py. In CONSTANTS.py, DATA_ROOT_PATH is the directory where the dataset is located, and PRETRAINED_ROOT is the directory where the pre-trained models are included. In gs_model_config.py, dataset_config["data_path"] should be changed to the corresponding file path. Similarly, token_config["src_vocab_path"] and token_config["trg_vocab_path"] should be replaced by the corresponding vocabulary name. model_config["encoder_config"]["loc_pos_encode_config"]["side_len"] should be replaced by the side length (meter) corresponding to the actual background area. train_config["gpu_ids"] is the serial number of the GPU used. Other parameters can also be modified as needed.

Data

You can simply organize your POI data into something like this:

data1 = {'review': ["review1", "review2", ...],
         "category": 'POI category',
         "lng": "125.0",
         "lat": "43.0",
         "poi_id": "1",
         "reference": "reference text",
         "near_pois": [["type1", "125.3,43.8"], ["type2", "125.2,43.9"], ...]
         }
data_list = [data1, data2, ...]

where lng represents longitude and lat represents latitude. Save data_list through json, and the obtained file can be used as a dataset file. Note that the data processor assumes that the texts in review and reference are pre-tokenized and separated using #.

Training and Testing

Running the code below will start training and run inference on the test set after training:

cd train
python train_main.py

You can also run the following code just for testing:

python test.py

After testing, you can use the following command to calculate automatic metrics:

python eval.py

Note that you have modified the paths in eval.py reasonably. We use nlg-eval to calculate the metrics except for Distinct.

References

Some codes are from:

https://github.com/JunjieHu/ReCo-RL

https://github.com/jadore801120/attention-is-all-you-need-pytorch/tree/master/transformer

https://github.com/huggingface/transformers

Our codes about Adapter are inspired by adapter-transformers.

poi_description's People

Contributors

liuhq-dl avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.