Skip to main content

Unsupervised Learning for Embedding (USL)

This project implements the USL and USL-t methods for unsupervised learning with embeddings, allowing the use of embeddings to form clusters and potentially improve learning outcomes in unsupervised settings.

Installation

Clone the repository and install the required packages:

git clone [URL_to_this_repo]
cd [repo_name]
pip install -r requirements.txt

Usage

The usl_for_embedding function is designed to process embedding arrays for clustering. It can be used directly by importing from the selective_labeling.py:

from selective_labeling import usl_for_embedding

# Generate 10 embeddings, each with 10 random floating-point numbers
data = {'embedding': [list(np.random.rand(10)) for _ in range(10)]}

# method is 'usl' or 'usl-t'
# n_clusters is the number of samples that should be selected for labeling
selected_indices = usl_for_embedding(data['embedding'],method='usl',n_clusters=2,
                            learning_rate=0.001,batch_size=64,n_init=10,m_reg=0.9,k=10,lambda_=0.5,
                            epsilon=1e-5,alpha=0.75,num_epochs_cluster=100,num_heads=3)

print(selected_indices)

Parameters

  • embeddings (array-like): Input data, embeddings to be clustered.
  • method (str): The clustering method to use ('usl' or 'usl-t').
  • n_clusters (int): Number of clusters to form.
  • Additional parameters include learning rate, batch size, initialization runs, regularization term, and more described in main.py.

Project Structure

project_root/
│
├── methods/                # Module for clustering algorithms
│   ├── usl.py              # Contains the density regulation based USL
│   └── usl_t.py            # Contains the transformer based USL-t
│
├── models/                 # Models used in USL-t
│   └── ssl_t_models/
│       └── clustering_model.py  # Clustering model for USL-t
│
└── main.py                 # Main script to use USL methods

Main Files and Their Roles

  • main.py: Contains the primary functions used to interface with the USL methods and demonstrates an example usage.
  • usl.py and usl_t.py: Implementation of the USL and USL-t methods, respectively.
  • clustering_model.py: Defines the neural network models used in the USL-t method.

Contributing

Contributions to this project are welcome. Please fork the repository and submit a pull request with your features or fixes. This code is used parts of the paper and codebase from repository: https://github.com/TonyLianLong/UnsupervisedSelectiveLabeling

License

This project is licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for usl-embedding 0.1.2

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

Source distribution (sdist)

Source distribution for usl-embedding 0.1.2
File Size Uploaded Provenance
usl_embedding-0.1.2.tar.gz 10.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for usl-embedding 0.1.2
File Interpreter ABI Platform
usl_embedding-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 21.9 kB

Release files / usl_embedding-0.1.2.tar.gz

Download URL usl_embedding-0.1.2.tar.gz
Size 10.6 kB
Tags Source
SHA-256 checksum
How to use checksums
b73e46905505b77508360b4748a8f0ecfd0ddb4f9e0dac2f48027d55d298a9be
BLAKE2b-256 checksum
How to use checksums
d618143e549d435ef87eaf231429707d7cbd4efa678b94cb0c977d22c84cc2da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12

Release files / usl_embedding-0.1.2-py3-none-any.whl

Download URL usl_embedding-0.1.2-py3-none-any.whl
Size 11.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2c4554e301ac273c7be07c56b49b8b520e65d91d731398388a4bd0d9cafc31d9
BLAKE2b-256 checksum
How to use checksums
6c42b6efe7fa3b0c7eb02ea6f7d34370c2dcde5d6ce874bdf49293a154d8ef31
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12

Security for usl-embedding 0.1.2

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.

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