Skip to main content

DSSM

An industrial-grade implementation of the paper: Learning Deep Structured Semantic Models for Web Search using Clickthrough Data

Latent semantic models, such as LSA, intend to map a query to its relevant documents at the semantic level where keyword-based matching often fails. DSSM project queries and documents into a common low-dimensional space where the relevance of a document given a query is readily computed as the distance between them.

This model can be used as a search engine that helps people find out their desired document even with searching a query that:

  1. is abbreviation of the document words;
  2. changed the order of the words in the document;
  3. shortened words in the document;
  4. has typos;
  5. has spacing issues.

Install

DSSM is dependent on PyTorch. Two ways to install DSSM:

Install DSSM from Pypi:

pip install dssm

Install DSSM from the Github source:

git clone https://github.com/Chiang97912/dssm.git
cd dssm
python setup.py install

Usage

Train

from dssm.model import DSSM

queries = ['...']  # query list, words need to be segmented in advance, and tokens should be spliced with spaces.
documents = ['...']  # document list, words need to be segmented in advance, and tokens should be spliced with spaces.
model = DSSM('dssm-model', device='cuda:0', lang='en')
model.fit(queries, documents)

Test

from dssm.model import DSSM
from sklearn.metrics.pairwise import cosine_similarity

text_left = '...'
text_right = '...'
model = DSSM('dssm-model', device='cpu')
vectors = model.encode([text_left, text_right])
score = cosine_similarity([vectors[0]], [vectors[1]])
print(score)

Dependencies

  • Python version 3.6
  • Numpy version 1.19.5
  • PyTorch version 1.9.0

Release files for dssm 0.1.3

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

Source distribution (sdist)

Source distribution for dssm 0.1.3
File Size Uploaded
dssm-0.1.3.tar.gz 7.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dssm 0.1.3
File Interpreter ABI Platform
dssm-0.1.3-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 16.1 kB

Release files / dssm-0.1.3.tar.gz

Download URL dssm-0.1.3.tar.gz
Size 7.5 kB
Tags Source
SHA-256 checksum
How to use checksums
68c8d6fffa3390414bbf8a7f3f156cd45609f509dde5091360d976d74bc851f9
BLAKE2b-256 checksum
How to use checksums
40c4f73359cc1f4d9f08a15d80cb5a41c50607a1ee37738028ea1fd283f8d673
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.6.1 requests/2.25.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.8

Release files / dssm-0.1.3-py2.py3-none-any.whl

Download URL dssm-0.1.3-py2.py3-none-any.whl
Size 8.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
177022a75ef3e7a3409701b21afca395dc45c57fa5b7f27d79b8bce33e21b930
BLAKE2b-256 checksum
How to use checksums
c6114d1e6fb0ad15f45bf9ffcb1a30c639473e68d10b70d427afba6a433802b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.6.1 requests/2.25.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.8

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

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