9 releases (5 breaking)

✓ Uses Rust 2018 edition

new 0.11.0 May 8, 2020
0.10.0 Nov 8, 2019
0.9.1 Oct 4, 2019
0.9.0 Sep 18, 2019
0.5.1 Mar 24, 2019
Download history 2/week @ 2020-02-04 9/week @ 2020-02-11 22/week @ 2020-02-18 18/week @ 2020-02-25 8/week @ 2020-03-03 8/week @ 2020-03-10 25/week @ 2020-03-17 27/week @ 2020-03-24 1/week @ 2020-03-31 25/week @ 2020-04-07 32/week @ 2020-04-14 1/week @ 2020-04-21 1/week @ 2020-04-28 20/week @ 2020-05-05

59 downloads per month

Custom license

270KB
5K SLoC

Travis CI

finalfusion-utils

Introduction

finalfusion-utils is a Rust crate offering various functionalities to process and query embeddings. finalfusion-utils supports conversion between different formats, quantization of embedding matrices, similarity and analogy queries as well as evaluation on analogy datasets.

Installation

Using cargo

finalfusion-utils can be installed using an up-to-date Rust toolchain, which can be installed with rustup.

With a valid Rust toolchain, the crate is most easily installed through cargo:

$ cargo install finalfusion-utils

Using Nix

The development version of finalfusion-utils can be directly installed from its repository using the Nix package manager. To install the current version from the master branch into your user profile:

$ nix-env -i \
  -f https://github.com/finalfusion/finalfusion-utils/tarball/master

To install the latest release version of finalfusion-utils, we recommend you to use the finalfusion package set. To install the current release version into your user profile:

nix-env -i \
  -f https://github.com/finalfusion/nix-packages/tarball/master \
  -A finalfusion-utils

You can get prebuilt Linux/macOS binaries using the finalfusion Cachix cache:

# If you haven't installed Cachix yet:
$ nix-env -iA cachix -f https://cachix.org/api/v1/install
$ cachix use finalfusion

Building from source

finalfusion-utils can also be built from source, after cloning this repository execute the following command in the directory to find the exectuable under target/release/finalfusion:

$ cargo build --release

Usage

finalfusion-utils is built as a single binary, the different functionality is invoked through subcommands:

Converting embeddings

# Convert embeddings in fastText format to finalfusion
$ finalfusion convert -f fasttext -t finalfusion \
    embeddings.bin embeddings.fifu

# Convert embeddings in word2vec format to finalfusion
$ finalfusion convert -f word2vec -t finalfusion \
    embeddings.w2v embeddings.fifu

# Print help with all supported combinations:
$ finalfusion convert --help

Quantizing an embedding matrix

# Quantize embeddings in finalfusion format with a
# single attempt through product quantization 
$ finalfusion quantize -f finalfusion -q pq  -a 1 \
    embeddings.pq

Analogy and similarity queries

# Get the 15 nearest neighbours of "Tübingen" for
# embeddings in finalfusion format.
$ finalfusion similar -f finalfusion -k 15 \
    embeddings.fifu

# Get the 5 best answers for the analogy query
# "Berlin" is to "Deutschland" as "Amsterdam" to:
$ finalfusion analogy -f finalfusion -k 5 \
    Berlin Deutschland Amsterdam embeddings.fifu

Evaluation on analogy datasets

# Evaluate embeddings on some analogy dataset
$ finalfusion compute-accuracy embeddings.fifu \
    analogies.txt

Dump metadata

# Dump optionally stored metadata and store in
# metadata.txt, only supported for finalfusion
# format
$ finalfusion metadata embeddings.fifu \
    > metadata.txt

Print completion script

# Print completion script for zsh
$ finalfusion completions zsh

Dependencies

~6–33MB
~584K SLoC