Skip to main content

A soft and fast pattern matcher for billion-scale corpora.

PyPi GitHub

Paper | Website | Demo | Citation

Installation

You can install via PyPi:

pip install softmatcha

For the development purposes, you can install from the source via uv:

git clone https://github.com/softmatcha/softmatcha.git
cd softmatcha/
uv sync

or pip:

git clone https://github.com/softmatcha/softmatcha.git
cd softmatcha/
pip install -e ./

MacOS

Before running pip install, you need to setup libraries and environment variables:

brew install pkg-config icu4c
export CFLAGS="-std=c++11"
export PATH="$(brew --prefix)/opt/icu4c/bin:$(brew --prefix)/opt/icu4c/sbin:$PATH"
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$(brew --prefix)/opt/icu4c/lib/pkgconfig"
pip install softmatcha

Quick start

SoftMatcha implements two search types: scan and index.

  • Scan: search texts without indexing and any preprocessing like grep, which is useful for small corpora.
  • Index: search texts with an index, effectively works on billion-scale corpora.

Scan: softmatcha-grep

softmatcha-grep searches corpora without indexing:

$ softmatcha-grep "the jazz musician" corpus.txt

The first arugment is the pattern string and the second one is a file or files to be searched. The other arguments can be seen by softmatcha-grep -h.

softmatcha-index builds a search index from corpora:

$ softmatcha-index --index corpus.idx corpus.txt

softmatcha-search quickly searches patterns with a search index:

$ softmatcha-search --index corpus.idx "the jazz musician"

Options

For development purposes,

  • --profile=true measures the execution time.
  • --log outputs the verbose information.

For searchers,

  • --backend {gensim,fasttext,transformers}: Backend framework for embeddings.
  • --model <NAME>: Name of word embeddings.
  • --threshold specifies the threshold for soft matching.

For controlling outputs,

  • -n, --line_number prints line number with output lines.
  • -o, --only_matching outputs only matched patterns.

List of implementations

Embeddings

Searchers

Scan: softmatcha-grep

  • Naive search: --search naive
  • Quick search (default): --search quick

Index: softmatcha-index and softmatcha-search

  • Inverted index search

Citation

If you use this software, please cite:

@inproceedings{
  deguchi-iclr-2025-softmatcha,
  title={SoftMatcha: A Soft and Fast Pattern Matcher for Billion-Scale Corpus Searches},
  author={Deguchi, Hiroyuki and Kamoda, Go and Matsushita, Yusuke and Taguchi, Chihiro and Waga, Masaki and Suenaga, Kohei and Yokoi, Sho},
  booktitle={The Thirteenth International Conference on Learning Representations (ICLR 2025)},
  year={2025},
  url={https://openreview.net/forum?id=Q6PAnqYVpo}
}

License

This software is mainly developed by Hiroyuki Deguchi and published under the MIT-license.

Metadata

Release files for softmatcha 0.1.0

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

Source distribution (sdist)

Source distribution for softmatcha 0.1.0
File Size Uploaded Provenance Actions
softmatcha-0.1.0.tar.gz 35.8 kB Without provenance Details for softmatcha-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 89.3 kB

Release files / softmatcha-0.1.0.tar.gz

Download URL softmatcha-0.1.0.tar.gz
Size 35.8 kB
Tags Source
SHA-256 checksum
How to use checksums
e75479a6838e88b1efee0548636cf6a179523a6133577388fed1588a6a230da6
BLAKE2b-256 checksum
How to use checksums
6f93ec49cfedb6ca131e06c83d1a4903ed1549f8407dfeb18517825eade6ab11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.2

Release files / softmatcha-0.1.0-py3-none-any.whl

Download URL softmatcha-0.1.0-py3-none-any.whl
Size 53.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
117edb5905e46c2ca13b4910f727281c9c39cf165ebf1760af71edc67e9c0573
BLAKE2b-256 checksum
How to use checksums
86db47241a080ba0015d0fe1ad3f3e7697a2d38f1c032e0f9d047bcbf314771f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.2

Security for softmatcha 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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