Giter VIP home page Giter VIP logo

hammock-public's Introduction

Visualize and compare embeddings for text sequences

This is a small project for visualizing embeddings.

A screenshot of the interactive output visualizing embeddings for Anki cards

See the screenshot above or the interactive demo output here.

The overall flow is:

  1. One or more text sequences is split into sentences or paragraphs.
  2. Each resulting text fragment is embedded using the requested embedding model.
  3. The embeddings are reduced to two or three dimensions (as requested) via UMAP.
  4. The low dimensionality embeddings are optionally clustered with hdbscan. A single set of embeddings can be clustered at multiple granularities.
  5. Clusters are optionally summarized using the requested language model.

The resulting points and cluster info are plotted in an interactive 3D scatter plot.

  • Plotly provides a number of default handlers for interaction.
  • Left and right arrow keys step through text fragments in original text order (i.e. you could, in theory, read a book by stepping through its fragments and simultaneously see how the fragments relate to each other in embedding space).
  • Up and down arrow keys step through clustering granularities. (i.e. you can see a very high-level "table" of contents and then "zoom in" to more and more granular "tables" of contents)

There's also some support and integration with a few existing text sources. A small web interface (python -m hammock.gunicorn) is provided for:

  • Visualizing arbitrary text submitted in a textarea
  • Fetching one or more books from Project Gutenberg by title and visualizing them
  • Fetching one or more articles from Wikipedia by title and visualizing them

Modules can be accessed from the command line to:

  • Batch process epubs from Calibre (python -m hammock.calibre.core)
  • Fetch cards from an Anki database and visualize them (python -m hammock.anki -d <path-to-DB> -p <path-to-excluded-substrings-file>)

If you have nix, you can simply do nix run from the project directory to set up the project launch the web server on localhost. nix develop will dump you into a shell with all the dependencies set up.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.