Skip to main content

A package for generating, exploring, and visualizing word embeddings graphs.

Project description

Embeddings Explorer

For the motivation behind this project, check this article.

In short, this is a framework that allows to generate a graph from a corpus of embeddings and to traverse it.

Example Pizza to Pineapple

Setup

If you want to generate embeddings with OpenAI or Voyage, add a .env file in the roof of the project with OPENAI_API_KEY and VOYAGE_API_KEY

Usage

You can install the library with the following command:

python3 -m pip install embeddings-explorer

The goal of this library is to offer a few building blocks that allow to generate and navigate an embedding space.

This is a full example usage of the library to get the path and distance from Pizza to Pineapple:

from embeddings_explorer.corpus.food_corpus_provider import FoodCorpusProvider, Language
from embeddings_explorer.models.openai import OpenAIGenerator
from embeddings_explorer.graph.knn_graph import KnnGraphConstructor
from embeddings_explorer.graph.weighted_traverser import WeightedTraverser
from embeddings_explorer.orchestrator.explorer import EmbeddingsExplorer

language = Language.EN
k=5
path_to_cache = "/path/to/cache/folder/"

start_node = 'Pizza'
end_node = 'Pineapple'

corpus_provider = FoodCorpusProvide (language=language)
embedding_generator = OpenAIGenerator(model_size=model_size)
graph_constructor = KnnGraphConstructor(
    k=k, metric='euclidean', weighted=True, normalize_euclidean=True)
traverser = WeightedTraverser()

explorer = EmbeddingsExplorer(
    corpus_provider, embedding_generator, graph_constructor, traverser, path_to_cache)
path, total_distance = explorer.explore(
    start_node=start_node, end_node=end_node)

print(path)
print(total_distance)

The framework defines some key abstract classes that can be extended in order to create something customized:

  • CorpusProvider: supplies the corpus to generate embeddings for
  • Generator: given a set of words, generates the embeddings for it
  • GraphConstructor: given a list of embedding vectors, generates a traversable graph
  • Traverser: given a start node, end node and graph, traverses the graph to get from one point to the other

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

embeddings_explorer-0.1.2.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

embeddings_explorer-0.1.2-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file embeddings_explorer-0.1.2.tar.gz.

File metadata

  • Download URL: embeddings_explorer-0.1.2.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.1

File hashes

Hashes for embeddings_explorer-0.1.2.tar.gz
Algorithm Hash digest
SHA256 b708b47fdd6f695a0fc437d45027fbf67680d041405ff1910ac4608fa3e75f2c
MD5 8e21f9743c357865ca3200f1beafff89
BLAKE2b-256 4fec2f88f66f50e0edd90b7893edd2e4529da09363b6d180fbb1f3d29b73e6c2

See more details on using hashes here.

File details

Details for the file embeddings_explorer-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for embeddings_explorer-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9c5344fc3cab51e67dde554d5b12e0fe972ced5bd2d8c635fe9c20089ffbd246
MD5 a58347326c2411cdc33cde60f3393ac5
BLAKE2b-256 dfb34bf42ef7d9454fda3531e4b30122db8a25c7f17313fca65fbcfab80592ee

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page