Metadata-Version: 2.4
Name: gt-all-minilm-l6-v2
Version: 0.1.0
Summary: A packaged version of the sentence-transformers/all-MiniLM-L6-v2 model for complete offline PyTorch use.
Author-email: Matt <matt@example.com>
License: MIT
License-File: LICENSE
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.8
Requires-Dist: sentence-transformers>=2.2.0
Description-Content-Type: text/markdown

# gt-all-minilm-l6-v2

A complete, offline-first Python packaging of the Hugging Face **`sentence-transformers/all-MiniLM-L6-v2`** model.

This package bundles the model's metadata, tokenizers, and weights (in standard `model.safetensors` format, ~90MB) directly inside the Python distribution. It is specifically designed for secure, air-gapped, or network-constrained offline environments where packages can only be installed via `pip install`, and downloading assets from the Hugging Face Hub at runtime is impossible.

---

## Key Features

- **Offline-First:** No network requests are made at runtime. The model weights (`model.safetensors`) and configs are packaged directly into the library's wheel.
- **Official Integration:** Directly integrates with the `sentence-transformers` library for robust, standard loading.
- **Convenient Export:** Exposes a simple API and CLI to easily export the raw model and tokenizer files to any external directory.
- **Minimal CLI:** Zero-fuss CLI command `gt-all-minilm-l6-v2` to get the internal model directory or export components.

---

## Installation

### Installation in Online Environment (Building from Source)

Clone the repository and install dependencies, then build and install the package:

```bash
# 1. Clone the repository
git clone https://github.com/your-org/gt-all-minilm-l6-v2.git
cd gt-all-minilm-l6-v2

# 2. Download the model weights and assets locally
python scripts/download_model.py

# 3. Build the wheel
pip install build
python -m build

# 4. Install the package
pip install dist/gt_all_minilm_l6_v2-0.1.0-py3-none-any.whl
```

### Installation in Offline Environment

Once the `.whl` file is built in an internet-enabled environment, copy the `.whl` file to your offline/air-gapped environment and install it using standard pip:

```bash
pip install gt_all_minilm_l6_v2-0.1.0-py3-none-any.whl
```

---

## Python API Usage

The package exposes three main functions under the `gt_all_minilm_l6_v2` namespace.

### 1. Loading the Model

Load the model as a standard `SentenceTransformer` instance:

```python
import gt_all_minilm_l6_v2

# Load the packaged model (automatically uses GPU if available)
model = gt_all_minilm_l6_v2.load_model()

# Generate sentence embeddings offline
sentences = ["This is an offline sentence embedding", "Another text to embed"]
embeddings = model.encode(sentences)

print("Embedding dimensions:", embeddings.shape)  # Output: (2, 384)
```

### 2. Locating the Bundled Model Files

Get the absolute path to the local directory where the model files are located inside your Python installation (`site-packages`):

```python
import gt_all_minilm_l6_v2

model_path = gt_all_minilm_l6_v2.get_model_path()
print("Model directory:", model_path)
```

### 3. Exporting Model Components

Export the raw model, tokenizer, and config files to an external directory. This is extremely useful if you need to load the model from disk in other frameworks (like Hugging Face `transformers` or C++ deployments) without referencing the Python package.

```python
import gt_all_minilm_l6_v2

# Export all components to a local folder
export_path = gt_all_minilm_l6_v2.export_model("./my-local-model-directory")
print("Model exported to:", export_path)
```

---

## Command-Line Interface (CLI)

The package exposes a command-line utility `gt-all-minilm-l6-v2` with two subcommands.

### `path`
Print the absolute path to the bundled model files within the Python environment:

```bash
gt-all-minilm-l6-v2 path
```
*Example Output:*
`/home/user/venv/lib/python3.10/site-packages/gt_all_minilm_l6_v2/model`

### `export`
Export the bundled model components to a specified external folder:

```bash
gt-all-minilm-l6-v2 export ./my_offline_model
```

---

## Guaranteeing Offline Success

To verify that the model is running entirely from local files and does not attempt to contact Hugging Face Hub, set the standard environment variables to disable network calls:

```python
import os
os.environ["HF_HUB_OFFLINE"] = "1"
os.environ["TRANSFORMERS_OFFLINE"] = "1"

import gt_all_minilm_l6_v2
model = gt_all_minilm_l6_v2.load_model()
```

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
The model weights are distributed under their respective Apache 2.0 license by the Sentence Transformers team.
