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:
- is abbreviation of the document words;
- changed the order of the words in the document;
- shortened words in the document;
- has typos;
- 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
Pythonversion 3.6Numpyversion 1.19.5PyTorchversion 1.9.0
Metadata
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)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| dssm-0.1.3.tar.gz | 7.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 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
|
Security for dssm 0.1.3
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.