GithubHelp home page GithubHelp logo

person2vec's Introduction

person2vec

person2vec will create embeddings to encapsulate text associated with entities you care about. You can then use these embedding vectors for any other machine learning task.

person2vec uses a novel approach for creating text embeddings. You can read more about the approach in my blog post here: https://blog.insightdatascience.com/entity2vec-dad368c5b830

To use person2vec, you'll first need to create a mongodb database containing information about your entities. In the database entry (document) for each entity of interest, you must include a 'texts' field as an array of strings of text you have about this entity. This 'texts' field is where person2vec will look when it tries to find text from which to create the embeddings.

To set up a mongodb database, follow these instructions: https://docs.mongodb.com/manual/installation/

Once you have mongodb installed, make sure it is running. To make sure it's running type this into your command prompt:

sudo service mongod start

Once you have mongodb working, you can load all the information you want about the entities you care about into it, making sure to store any text you want to embed in a field called 'texts' as an array of strings. For an example of how to do this, you can look in the file "yelp_loader.py" in the person2vec/utils directory of this repo.

Next, you'll want to install person2vec. To do that, clone this repo, then navigate to the directory you cloned it into.

To install necessary dependencies, you'll need to execute the command: pip install -e .

If that doesn't work, you may need to do: sudo pip install -e .

Once dependencies finish installing, you can begin training your embeddings. There are a few ways to do this. The easiest way is to use the command line tool. From the person2vec directory of this repo, simply type the command:

python embed_database.py 'name_of_your_database'

The process may take a while, depending on the size of your database, so give it time.

If you want a bit more control, you can use the python package to play with the various settings. To train embeddings in your own python script, the essential pieces you'll need are as follows:

from person2vec import data_handler
from person2vec.generators import training_data_generator
from person2vec.utils import snippet_creator
from person2vec.train_embeddings import train

# creates an object that handles transactions with the mongodb database
handler = data_handler.DataHandler('name_of_your_database')
# creates snippets from the text in the database that'll serve as training data for the embeddings
snippet_creator.snippetize_db(handler)
# a generator that, when invoked, will continuously generate training data from the snippets
data_gen = training_data_generator.EmbeddingDataGenerator(db_name=db_name)
# this command trains the embeddings and yields the trained model. 
# You can also pass train.train_model() a pre-defined or even pre-trained model, and it'll train that instead of the default 
model, data_gen = train.train_model(data_gen=data_gen)
# this saves the embeddings to the database for later use
handler.save_embeddings_to_db(model, data_gen)

Training of embeddings for more than 10,000 entities is not recommended in this release. This limit will improve in future releases.

person2vec's People

Contributors

javedqadruddin avatar agude avatar

Watchers

James Cloos avatar Rahul 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.