Code Monkey home page Code Monkey logo

attr2vec's Introduction

attr2vec

TensorFlow implementation of the attr2vec model, based on the following publication:

  • Fabio Petroni, Vassilis Plachouras, Timothy Nugent and Jochen L. Leidner: "attr2vec: : Jointly Learning Word and Contextual Attribute Embeddings with Factorization Machines." In: Proceedings of the 16th Annual Conference of the North American Chapter of the Association for Computational Linguistics (NAACL), 2018.

If you use the application please cite the paper.

Modeling input data

The input corpus is represented as two files: Cooccur.csv and Word2Id.csv. The first file follows the original libfm format (http://www.libfm.org) and contains the target vector Y as well as the feature matrix X.

We will use an example to concretely show how to model the input data, using as corpus the following text:

Prime Minister Theresa May will remind her cabinet that discussions must remain private. 
Theresa Mary May is a British politician who has served as Prime Minister.

The folder data_pos contains the modeling of such example corpus using Part-of-Speech (POS) as additional contextual attribute, while the folder data_dependency contains the input data to train dependency-based embeddings.

The Word2Id.csv file contains the symbols vocabulary, and looks like this:

"IN",2,2
"NNP",6,2
"NNS",7,2
"discussions",17,0
"minister",23,0
"prime",26,0
"that",31,0
[...]

The first column contains the word form or the POS tag, the second column an unique identifier, the third column a meta information to distinguish words from POS tags (i.e., 0 for words, 2 for POS tag).

The Cooccur.csv file looks like this:

1.0 17:1.0 31:1.0 7:1.0 2:1.0
2.0 23:1.0 26:1.0 6:2.0
[...]

Please read the libfm manual (http://www.libfm.org/libfm-1.42.manual.pdf) for an extensive description of this format. Here, the first line conveys the information that symbols with id 17, 31, 7, 2 (all with value 1.0) co-occur in the corpus with frequency 1.0.

Train the attr2vec model

To train the attr2vec model on the example data simply run

python train.py

Open the file and edit it to change the paramenters.

The application will write vectors and model metadata in the log folder. You can use TensorBoard to explore the model internals, as follows:

tensorboard --logdir log/

TensorBoard

attr2vec's People

Contributors

babakx avatar fabiopetroni avatar geffy avatar peterewills avatar xujin1982 avatar yasyf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

fabiopetroni

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.