Skip to main content

A lightweight Python package for loading, analyzing, and visualizing word embeddings.

Project description

image

WordViz is a Python visualization library designed for exploring and visualizing word embeddings. Built on top of popular libraries such as matplotlib, plotly, and gensim, WordViz provides intuitive tools for analyzing embeddings through clustering, similarity exploration, and dimensionality reduction, all wrapped in interactive and customizable plots. With WordViz, users can gain insights into the structure of their word embeddings, making it a valuable tool for researchers and practitioners in natural language processing.

This project was created as part of my Bachelor's Degree thesis in Statistics and Information Management with title (translated): "Word Embeddings in Practice: Designing a Library for Visualization and Operations"

version 0.3.0

PyPi Page: https://pypi.org/project/wordviz/
Documentation: https://wordviz.readthedocs.io/

Last Version Updates

Added

  • Support for contextual embeddings with two modes:
    • sentences: visualize entire sentences
    • word_contexts: visualize and compare multiple embeddings of the same word in different contexts
  • New encoding module to embed sentences and words in different contexts, supported by Transformers and PyTorch (optional requirements)
  • load_contextual method for EmbeddingLoader class
  • New type property for EmbeddingLoader class

Deprecated

  • From /plotting:
    • interactive_embeddings will change name to plot_interactive (FutureWarning added)
    • similarity_heatmap will change name to plot_similarity_heatmap (FutureWarning added)
  • Warnings added for imminent property name changes in similarity module and plot_similarity (no breaking changes yet)

Fixed

  • Fixed doubled parameter bug in MDS dimensionality reduction
  • Fixed support to pairwise distances for all distance types

See more about previous changes in CHANGELOG.md

Main Features

  • Load and explore pretrained embeddings (e.g., GloVe, FastText)
  • Select from a variety of available embeddings
  • Visualize embeddings in 2D or 3D with flexible dimensionality reduction options
  • Identify and plot the most similar words to a given token
  • Visualize clusters of related words
  • Interactive plots powered by plotly
  • Support for many light and dark themes

Installation

Install the latest version from PyPI:

pip install wordviz

Notes: Python version compatibility

Currently, wordviz is not compatible with Python 3.13, due to limitations of some key dependencies:

gensim, one of the core libraries used by wordviz, does not yet provide official support or precompiled wheels for Python 3.13.

For proper installation installation, we recommend that you create a virtual environment with Python 3.12, or just use uv:

uv init --python 3.12

The package will be updated as soon as the dependencies are compatible with Python 3.13.

Usage

You can load and manage embeddings though the EmbeddingLoader class, and then visualize them with the Visualizer (or Visualizer3D) class.

from wordviz.loading import EmbeddingLoader
from wordviz.plotting import Visualizer

loader = EmbeddingLoader()
loader.load_from_file('path/to/your/embedding/file', 'word2vec')

vis = Visualizer(loader)
vis.plot_embeddings()

You can explore all functionalities through the example notebook provided in the docs/ folder:

👉 View example notebook

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is licensed under the MIT License.

Contacts

Elena Zen - My Portfolio Website - info.elenazen@gmail.com

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

wordviz-0.3.0.tar.gz (20.3 kB view details)

Uploaded Source

Built Distribution

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

wordviz-0.3.0-py3-none-any.whl (23.4 kB view details)

Uploaded Python 3

File details

Details for the file wordviz-0.3.0.tar.gz.

File metadata

  • Download URL: wordviz-0.3.0.tar.gz
  • Upload date:
  • Size: 20.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.12.6 Windows/11

File hashes

Hashes for wordviz-0.3.0.tar.gz
Algorithm Hash digest
SHA256 818b56427dabd01dfbe8f7bf73c93f70a9629d8cfb79ba6db1841a51599fe4a7
MD5 c6b41702aaf69129d8341f4cd811788e
BLAKE2b-256 69ea4eaabbef66e36e2974c27f26cf1fa8fb1a1b43866bf153a93a72fcf37546

See more details on using hashes here.

File details

Details for the file wordviz-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: wordviz-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 23.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.12.6 Windows/11

File hashes

Hashes for wordviz-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c72d346e603aa64cb52ea210f76382fcc9caddfa56e8b318cc831e7ea8c7f778
MD5 392092bf5709d49a8190005faa3d4699
BLAKE2b-256 42af8827264ec2f926313b24ccc8e4aad6ed080c97b3da8d1125ac86d8db424c

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