Instructions to use enguard/tiny-guard-4m-en-response-refusal-binary-polyguard with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Model2Vec
How to use enguard/tiny-guard-4m-en-response-refusal-binary-polyguard with Model2Vec:
from model2vec import StaticModel model = StaticModel.from_pretrained("enguard/tiny-guard-4m-en-response-refusal-binary-polyguard") embeddings = model.encode(["It's dangerous to go alone!", "It's a secret to everybody."]) print(embeddings.shape) - Notebooks
- Google Colab
- Kaggle
Upload folder using huggingface_hub
Browse filesFiles changed (7)
- .gitattributes+1
- README.mdAdded+100
- config.jsonAdded+5
- model.safetensorsAdded+3
- modules.jsonAdded+14
- pipeline.skopsAdded+3
- tokenizer.jsonAdded
32 unmodified lines33343532 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -text32 unmodified lines3334353632 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -textpipeline.skops filter=lfs diff=lfs merge=lfs -text
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100---base_model: unknownlibrary_name: model2veclicense: mitmodel_name: tmpysaj4ch1tags:- embeddings- static-embeddings- sentence-transformers---
# tmpysaj4ch1 Model Card
This [Model2Vec](https://github.com/MinishLab/model2vec) model is a distilled version of the unknown(https://huggingface.co/unknown) Sentence Transformer. It uses static embeddings, allowing text embeddings to be computed orders of magnitude faster on both GPU and CPU. It is designed for applications where computational resources are limited or where real-time performance is critical. Model2Vec models are the smallest, fastest, and most performant static embedders available. The distilled models are up to 50 times smaller and 500 times faster than traditional Sentence Transformers.
## Installation
Install model2vec using pip:```pip install model2vec```
## Usage
### Using Model2Vec
The [Model2Vec library](https://github.com/MinishLab/model2vec) is the fastest and most lightweight way to run Model2Vec models.
Load this model using the `from_pretrained` method:```pythonfrom model2vec import StaticModel
# Load a pretrained Model2Vec modelmodel = StaticModel.from_pretrained("tmpysaj4ch1")
# Compute text embeddingsembeddings = model.encode(["Example sentence"])```
### Using Sentence Transformers
You can also use the [Sentence Transformers library](https://github.com/UKPLab/sentence-transformers) to load and use the model:
```pythonfrom sentence_transformers import SentenceTransformer
# Load a pretrained Sentence Transformer modelmodel = SentenceTransformer("tmpysaj4ch1")
# Compute text embeddingsembeddings = model.encode(["Example sentence"])```
### Distilling a Model2Vec model
You can distill a Model2Vec model from a Sentence Transformer model using the `distill` method. First, install the `distill` extra with `pip install model2vec[distill]`. Then, run the following code:
```pythonfrom model2vec.distill import distill
# Distill a Sentence Transformer model, in this case the BAAI/bge-base-en-v1.5 modelm2v_model = distill(model_name="BAAI/bge-base-en-v1.5", pca_dims=256)
# Save the modelm2v_model.save_pretrained("m2v_model")```
## How it works
Model2vec creates a small, fast, and powerful model that outperforms other static embedding models by a large margin on all tasks we could find, while being much faster to create than traditional static embedding models such as GloVe. Best of all, you don't need any data to distill a model using Model2Vec.
It works by passing a vocabulary through a sentence transformer model, then reducing the dimensionality of the resulting embeddings using PCA, and finally weighting the embeddings using [SIF weighting](https://openreview.net/pdf?id=SyK00v5xx). During inference, we simply take the mean of all token embeddings occurring in a sentence.
## Additional Resources
- [Model2Vec Repo](https://github.com/MinishLab/model2vec)- [Model2Vec Base Models](https://huggingface.co/collections/minishlab/model2vec-base-models-66fd9dd9b7c3b3c0f25ca90e)- [Model2Vec Results](https://github.com/MinishLab/model2vec/tree/main/results)- [Model2Vec Docs](https://minish.ai/packages/model2vec/introduction)
## Library Authors
Model2Vec was developed by the [Minish Lab](https://github.com/MinishLab) team consisting of [Stephan Tulkens](https://github.com/stephantul) and [Thomas van Dongen](https://github.com/Pringled).
## Citation
Please cite the [Model2Vec repository](https://github.com/MinishLab/model2vec) if you use this model in your work.```@software{minishlab2024model2vec, author = {Stephan Tulkens and {van Dongen}, Thomas}, title = {Model2Vec: Fast State-of-the-Art Static Embeddings}, year = {2024}, publisher = {Zenodo}, doi = {10.5281/zenodo.17270888}, url = {https://github.com/MinishLab/model2vec}, license = {MIT}}```12345{ "normalize": true, "embedding_dtype": "float32", "vocabulary_quantization": 29528}123version https://git-lfs.github.com/spec/v1oid sha256:e11affb1ab7d67d34b8306fe5885dd7e83c374cc3ad6a48f3bc1f52afb005656size 154729121234567891011121314[ { "idx": 0, "name": "0", "path": ".", "type": "sentence_transformers.models.StaticEmbedding" }, { "idx": 1, "name": "1", "path": "1_Normalize", "type": "sentence_transformers.models.Normalize" }]123version https://git-lfs.github.com/spec/v1oid sha256:11ed998aa53314d2df8281e7174edf19769d4e29247df33572c8a592d1c67045size 1938787.gitattributes+1
README.mdAdded+100
config.jsonAdded+5
model.safetensorsAdded+3
modules.jsonAdded+14
pipeline.skopsAdded+3
tokenizer.jsonAdded