Skip to main content

salto

Playing with embedding vectors

Installation

You can install this library from PyPI

pip install salto

or from the GitHub repo:

pip install git+https://github.com/krzjoa/salto.git

Motivation

The goal of the salto package is to explore embeddings and check, how the distance between two points (vectors) can be interpreted. We get two arbitrary selected points, such as embedding vectors for ice and fire draw a straight line passing trough the both these points. Then, we treat the newly created line as a new axis by projecting the rest of the points onto this line.

Drawn using: https://www.geogebra.org/m/JMMKv7cx

I named the package salto, which means somersault in many languages or simply jump in Romance languages like Italian, where this word originally comes from. It's because the operation of changing space for me resembles a kind of acrobatics 😉.

Usage

import numpy as np
import spacy
import salto

nlp = spacy.load('en_core_web_md')

fire = nlp('fire')
ice = nlp('ice')

ice_fire_axis = salto.axis(ice.vector, fire.vector)

cold = ['ice cream', 'polar', 'snow', 'winter', 'fridge', 'Antarctica']
warm = ['boiling water', 'tropical', 'sun', 'summer', 'oven', 'Africa']

cold_vecs = [nlp(w).vector for w in cold]
warm_vecs = [nlp(w).vector for w in warm]

cold_values = [ice_fire_axis(p) for p in cold_vecs]
warm_values = [ice_fire_axis(p) for p in warm_vecs]

ice_fire_axis.plot(
        {'values': cold_values, 'labels': cold, 'color': 'tab:blue'},
        {'values': warm_values, 'labels': warm, 'color': 'tab:red'},
        poles = {'negative': {'label': 'ice', 'color': 'blue'}, 
                 'positive': {'label': 'fire', 'color': 'red'}}
    )  

Metadata

Release files for salto 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for salto 0.0.4
File Size Uploaded Provenance Actions
salto-0.0.4.tar.gz 5.4 kB Without provenance Details for salto-0.0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for salto 0.0.4
File Interpreter ABI Platform Actions
salto-0.0.4-py3-none-any.whl Python 3 none any Details for salto-0.0.4-py3-none-any.whl

Total release size: 11.6 kB

Release files / salto-0.0.4.tar.gz

Download URL salto-0.0.4.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
43ab112ea80eb997690a4bf089f3f944280d3d1ddf757a734017f7842f97b1e4
BLAKE2b-256 checksum
How to use checksums
266f73ce792a0447769159885c340dfa96ceded43e104b6bef93a0264cc4450c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.8.10

Release files / salto-0.0.4-py3-none-any.whl

Download URL salto-0.0.4-py3-none-any.whl
Size 6.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
487936ead4a99100a6ff1824505d4644631f5dc9b78c6f9fb927ca894551e7f5
BLAKE2b-256 checksum
How to use checksums
ca7d4b152863456238c4387eead7f85215facc26b7dd1b3820ead1d94f2fc9d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.8.10

Security for salto 0.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page