salto


Namesalto JSON
Version 0.0.4 PyPI version JSON
download
home_pagehttps://github.com/krzjoa/salto
SummaryPlaying with embedding vectors
upload_time2023-01-14 12:42:22
maintainer
docs_urlNone
authorKrzysztof Joachimiak
requires_python>=3.7
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # salto <img src='img/salto-logo.png' align="right" height="139" />

> Playing with embedding vectors


## Installation

You can install this library from *PyPI*

```bash
pip install salto
```

or from the GitHub repo:
 
```bash
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.

 

<img src = "https://raw.githubusercontent.com/krzjoa/salto/main/examples/plot_3.png"></a>
<center> <i>Drawn using: <a>https://www.geogebra.org/m/JMMKv7cx<a></i>
 
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

```python
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'}}
    )  
```
<img src = "https://raw.githubusercontent.com/krzjoa/salto/main/examples/word-embedding_45_0.png"></a>

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/krzjoa/salto",
    "name": "salto",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "",
    "author": "Krzysztof Joachimiak",
    "author_email": "Krzysztof Joachimiak <joachimiak.krzysztof@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/26/6f/73ce792a0447769159885c340dfa96ceded43e104b6bef93a0264cc4450c/salto-0.0.4.tar.gz",
    "platform": null,
    "description": "# salto <img src='img/salto-logo.png' align=\"right\" height=\"139\" />\n\n> Playing with embedding vectors\n\n\n## Installation\n\nYou can install this library from *PyPI*\n\n```bash\npip install salto\n```\n\nor from the GitHub repo:\n \n```bash\npip install git+https://github.com/krzjoa/salto.git\n```\n\n## Motivation\n\nThe goal of the **salto** package is to explore embeddings and check, \nhow the distance between two points (vectors) can be interpreted.\nWe get two arbitrary selected points, such as embedding vectors for **ice** and **fire**\ndraw a straight line passing trough the both these points. Then, we treat the \nnewly created line as a new axis by projecting the rest of the points onto this line.\n\n \n\n<img src = \"https://raw.githubusercontent.com/krzjoa/salto/main/examples/plot_3.png\"></a>\n<center> <i>Drawn using: <a>https://www.geogebra.org/m/JMMKv7cx<a></i>\n \nI named the package **salto**, which means *somersault* in many languages or simply *jump* in Romance languages like Italian, where this word originally comes from.\nIt's because the operation of changing space for me resembles a kind of acrobatics \ud83d\ude09.\n\n## Usage\n\n```python\nimport numpy as np\nimport spacy\nimport salto\n\nnlp = spacy.load('en_core_web_md')\n\nfire = nlp('fire')\nice = nlp('ice')\n\nice_fire_axis = salto.axis(ice.vector, fire.vector)\n\ncold = ['ice cream', 'polar', 'snow', 'winter', 'fridge', 'Antarctica']\nwarm = ['boiling water', 'tropical', 'sun', 'summer', 'oven', 'Africa']\n\ncold_vecs = [nlp(w).vector for w in cold]\nwarm_vecs = [nlp(w).vector for w in warm]\n\ncold_values = [ice_fire_axis(p) for p in cold_vecs]\nwarm_values = [ice_fire_axis(p) for p in warm_vecs]\n\nice_fire_axis.plot(\n        {'values': cold_values, 'labels': cold, 'color': 'tab:blue'},\n        {'values': warm_values, 'labels': warm, 'color': 'tab:red'},\n        poles = {'negative': {'label': 'ice', 'color': 'blue'}, \n                 'positive': {'label': 'fire', 'color': 'red'}}\n    )  \n```\n<img src = \"https://raw.githubusercontent.com/krzjoa/salto/main/examples/word-embedding_45_0.png\"></a>\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Playing with embedding vectors",
    "version": "0.0.4",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ca7d4b152863456238c4387eead7f85215facc26b7dd1b3820ead1d94f2fc9d0",
                "md5": "ae48581e91cba8103e8add4f4063d3f1",
                "sha256": "487936ead4a99100a6ff1824505d4644631f5dc9b78c6f9fb927ca894551e7f5"
            },
            "downloads": -1,
            "filename": "salto-0.0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ae48581e91cba8103e8add4f4063d3f1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 6173,
            "upload_time": "2023-01-14T12:42:20",
            "upload_time_iso_8601": "2023-01-14T12:42:20.249082Z",
            "url": "https://files.pythonhosted.org/packages/ca/7d/4b152863456238c4387eead7f85215facc26b7dd1b3820ead1d94f2fc9d0/salto-0.0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "266f73ce792a0447769159885c340dfa96ceded43e104b6bef93a0264cc4450c",
                "md5": "96ef6f24a9e2fd4cb00603d00cd8920e",
                "sha256": "43ab112ea80eb997690a4bf089f3f944280d3d1ddf757a734017f7842f97b1e4"
            },
            "downloads": -1,
            "filename": "salto-0.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "96ef6f24a9e2fd4cb00603d00cd8920e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 5382,
            "upload_time": "2023-01-14T12:42:22",
            "upload_time_iso_8601": "2023-01-14T12:42:22.059826Z",
            "url": "https://files.pythonhosted.org/packages/26/6f/73ce792a0447769159885c340dfa96ceded43e104b6bef93a0264cc4450c/salto-0.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-14 12:42:22",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "krzjoa",
    "github_project": "salto",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "salto"
}
        
Elapsed time: 0.02721s