{"id":18438703,"url":"https://github.com/sajari/word2vec","last_synced_at":"2025-05-08T00:08:59.240Z","repository":{"id":35923391,"uuid":"40211237","full_name":"sajari/word2vec","owner":"sajari","description":"Go library for performing computations in word2vec binary models","archived":false,"fork":false,"pushed_at":"2022-06-27T22:37:42.000Z","size":60,"stargazers_count":200,"open_issues_count":2,"forks_count":35,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-05-08T00:08:54.001Z","etag":null,"topics":["embedding","go","golang","word","word2vec","word2vec-model"],"latest_commit_sha":null,"homepage":"https://www.search.io","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sajari.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-04T21:59:57.000Z","updated_at":"2025-04-17T04:10:06.000Z","dependencies_parsed_at":"2022-07-11T22:46:19.257Z","dependency_job_id":null,"html_url":"https://github.com/sajari/word2vec","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sajari%2Fword2vec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sajari%2Fword2vec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sajari%2Fword2vec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sajari%2Fword2vec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sajari","download_url":"https://codeload.github.com/sajari/word2vec/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252973690,"owners_count":21834108,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["embedding","go","golang","word","word2vec","word2vec-model"],"created_at":"2024-11-06T06:21:17.697Z","updated_at":"2025-05-08T00:08:59.215Z","avatar_url":"https://github.com/sajari.png","language":"Go","readme":"# word2vec\n[![Build Status](https://travis-ci.org/sajari/word2vec.svg?branch=master)](https://travis-ci.org/sajari/word2vec)\n[![GoDoc](https://godoc.org/code.sajari.com/word2vec?status.svg)](https://godoc.org/code.sajari.com/word2vec)\n\nword2vec is a Go package which provides functions for querying word2vec models (see [https://code.google.com/p/word2vec](https://code.google.com/p/word2vec)).  Any binary word2vec model file can be loaded and queried.\n\n## Requirements\n\n- [Go 1.4+](http://golang.org/dl/) (only tested on 1.4+)\n- A [word2vec](https://code.google.com/p/word2vec) model (binary format)\n\n## Installation\n\nIf you haven't setup Go before, you need to first set a `GOPATH` (see [https://golang.org/doc/code.html#GOPATH](https://golang.org/doc/code.html#GOPATH)).\n\nTo fetch and build the code:\n\n    $ go get code.sajari.com/word2vec/...\n\nThis will build the command line tools (in particular `word-calc`, `word-server`, `word-client`) into `$GOPATH/bin` (assumed to be in your `PATH` already).\n\n## Usage\n\n### word-calc\n\nThe `word-calc` tool is a quick way to perform basic word calculations on a word2vec model.  For instance: `vec(king) - vec(man) + vec(woman)` would be equivalent to:\n\n    $ word-calc -model /path/to/model.bin -add king,woman -sub man\n\nSee `word-calc -h` for full more details.  Note that `word-calc` first loads the model every time,  and so can appear to be quite slow. Use `word-server` and `word-client` to get better performance when running multiple queries on the same model.\n\n###  word-server and word-client\n\nThe `word-server` tool (see `cmd/word-server`) creates an HTTP server which wraps a word2vec model which can be queried from Go using a [Client](http://godoc.org/code.sajari.com/word2vec#Client), or using the `word-client` tool (see `cmd/word-client`).\n\n    $ word-server -model /path/to/model.bin -listen localhost:1234\n\nA simple code example using `Client`:\n\n```go\nc := word2vec.Client{Addr: \"localhost:1234\"}\n\n// Create an expression.\nexpr := word2vec.Expr{}\nexpr.Add(1, \"king\")\nexpr.Add(-1, \"man\")\nexpr.Add(1, \"woman\")\n\n// Find the most similar result by cosine similarity.\nmatches, err := c.CosN(expr, 1)\nif err != nil {\n\tlog.Fatalf(\"error evaluating cosine similarity: %v\", err)\n}\n```\n\n### API Example\nAlternatively you can interact with a word2vec model directly in your code:\n\n```go\n// Load the model from an io.Reader (i.e. a file).\nmodel, err := word2vec.FromReader(r)\nif err != nil {\n\tlog.Fatalf(\"error loading model: %v\", err)\n}\n\n// Create an expression.\nexpr := word2vec.Expr{}\nexpr.Add(1, \"king\")\nexpr.Add(-1, \"man\")\nexpr.Add(1, \"woman\")\n\n// Find the most similar result by cosine similarity.\nmatches, err := model.CosN(expr, 1)\nif err != nil {\n\tlog.Fatalf(\"error evaluating cosine similarity: %v\", err)\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsajari%2Fword2vec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsajari%2Fword2vec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsajari%2Fword2vec/lists"}