Skip to main content

Bilingual word alignment using multilingual embeddings - a spiritual implementation of SimAlign

Project description

VectorAlign

Bilingual word alignment using multilingual embeddings — no training required!

For non-nerds: a word matching engine for any language pair using parallel data.

Installation

pip install vectoralign

Quick Start

from vectoralign import align

# Your parallel sentences
english = [
    "Hello world",
    "How are you today",
    "The weather is nice"
]
hindi = [
    "नमस्ते दुनिया",
    "आज आप कैसे हैं",
    "मौसम अच्छा है"
]

# Align and build dictionary
dictionary = align(english, hindi)

Features

  • No training required — Uses pre-trained multilingual embeddings
  • Batch processing — Batch processing with automatic CUDA detection
  • Multiple models — Supports LaBSE, mBERT, and other HuggingFace models
  • Bidirectional alignment — Intersection of forward and backward alignments

Version 0.2.0 added features:

  • Memory management — Automatic garbage collection and CUDA cache management for efficient memory usage

Advanced Usage

from vectoralign import align

# Custom model and batch size
dictionary = align(
    src_sentences,
    tgt_sentences,
    model_name="setu4993/LaBSE",  # or "bert" for mBERT
    batch_size=64,
    threshold=0.6,  # Sentence similarity threshold
    output="my_dictionary.txt"
)

Supported Models

Model Name
LaBSE setu4993/LaBSE (default)
mBERT bert with mode='multilingual'
Any HuggingFace model with pooler_output Full model path

Output Format

The dictionary is saved as a TSV file:

word1    translation1    count
word2    translation2    count

Acknowledgments

This is a spiritual implementation of SimAlign by the Centre for Language and Information Processing, LMU Munich.

License

MIT License

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

vectoralign-0.2.2.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

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

vectoralign-0.2.2-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file vectoralign-0.2.2.tar.gz.

File metadata

  • Download URL: vectoralign-0.2.2.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for vectoralign-0.2.2.tar.gz
Algorithm Hash digest
SHA256 e8f3bbfe0dd7e61e40a727b02918c68f1eb55328e6ebf657b83bdccdffdc37c8
MD5 fd6fd8d47f66d076d57813c5c824280a
BLAKE2b-256 13ac33d85c616f071ef1197c19ccf9c08183075d053f6435b89fdd9e7a49c11d

See more details on using hashes here.

File details

Details for the file vectoralign-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: vectoralign-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for vectoralign-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 40aa9cd7178a3a0c8114d6d0668efc8d3996c62fa44f57195cb6433f67a8f8ea
MD5 c2e7d5b4df655abc5ef31efead2fa7af
BLAKE2b-256 1d52c8620a885c9d189e6663730abcddec191048459661529aaea7d8252f9805

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