Skip to main content

sentence2simvec

Vector-based sentence similarity (0.0 - 1.0) for Japanese & multilingual texts.

  • 3-gram Jaccard surface similarity
  • SBERT (MiniLM) semantic similarity
  • Python API + CLI (sentence2simvec)
  • Can output each sentence's embedding vector (numpy, 384-dim)
  • Embedding vectors for each sentence can be obtained and saved as a NumPy array.

Install

# macOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
# Windows
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

# 3.10, 3.11, 3.12, 3.13, ...
uv venv -p 3.10 .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate

uv pip install -U sentence2simvec
or
uv pip install -e .

Usage

  • CLI
    sentence2simvec "Hello!" "Hello world!" --save-vecs ./vecs
    
    # Similarity: 0.7135
    #    • n-gram  = 0.2727
    #    • cosine  = 0.9024
    # vecs/vec1.npy, vecs/vec2.npy written
    
  • Python API
    from sentence2simvec import similarity_score, sentence_vector
    
    # --- Similarity (with vectors) ---------------------------
    score, details, v1, v2 = similarity_score(
        "Hello!",
        "Hello world!",
        return_vectors=True
    )
    print(score)          # 0.87
    print(details)        # {'jaccard': 0.764…, 'cosine': 0.910…}
    print(v1.shape)       # (384,)
    
    # --- Get a single sentence vector ------------------------
    vec = sentence_vector("Hello")
    # ※ vec is L2 regularized (||vec||₂ = 1)
    

Development

uv venv -p 3.10 .venv && source .venv/bin/activate
uv pip install build twine pytest ipdb sentence-transformers numpy

# debug run
python sentence2simvec/core.py "Hello!" "Hello world!"

# tests
pytest

# build
python -m build

# upload PyPI
export TWINE_USERNAME="__token__"
export TWINE_PASSWORD="pypi-..."
twine upload dist/*
unset TWINE_USERNAME TWINE_PASSWORD

Release files for sentence2simvec 0.0.1

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

Source distribution (sdist)

Source distribution for sentence2simvec 0.0.1
File Size Uploaded
sentence2simvec-0.0.1.tar.gz 8.9 kB Details

Built distribution (wheel)

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

Total release size: 18.9 kB

Release files / sentence2simvec-0.0.1.tar.gz

Download URL sentence2simvec-0.0.1.tar.gz
Size 8.9 kB
Tags Source
SHA-256 checksum
How to use checksums
acb5b37f59b57ef3474b108f602bc348e2ba15f93817cfb78d87909bcc242ec7
BLAKE2b-256 checksum
How to use checksums
044ab095bf283e5a63738a5283769e1d08039031be0a83320accad3105a4fe8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Release files / sentence2simvec-0.0.1-py3-none-any.whl

Download URL sentence2simvec-0.0.1-py3-none-any.whl
Size 9.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5ab06dd54e63b6b4ae098d2646238e1057eb7f074a01fb8495f73c2cbe2fd222
BLAKE2b-256 checksum
How to use checksums
dddef65d3e74199933fd45f5fb169392127b90fc35d5bdd1be1cadd8486d67b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

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