Upload folder using huggingface_hub
Browse files- README.md +6 -47
- category_mappings.json +9 -9
- model.safetensors +1 -1
- pipeline.skops +1 -1
- tokenizer.json +0 -0
README.md
CHANGED
|
@@ -11,67 +11,27 @@ tags:
|
|
| 11 |
|
| 12 |
# category_classifier Model Card
|
| 13 |
|
| 14 |
-
This [Model2Vec](https://github.com/MinishLab/model2vec) model is a
|
| 15 |
-
|
| 16 |
|
| 17 |
## Installation
|
| 18 |
|
| 19 |
Install model2vec using pip:
|
| 20 |
```
|
| 21 |
-
pip install model2vec
|
| 22 |
```
|
| 23 |
|
| 24 |
## Usage
|
| 25 |
-
|
| 26 |
-
### Using Model2Vec
|
| 27 |
-
|
| 28 |
-
The [Model2Vec library](https://github.com/MinishLab/model2vec) is the fastest and most lightweight way to run Model2Vec models.
|
| 29 |
-
|
| 30 |
Load this model using the `from_pretrained` method:
|
| 31 |
```python
|
| 32 |
-
from model2vec import
|
| 33 |
|
| 34 |
# Load a pretrained Model2Vec model
|
| 35 |
-
model =
|
| 36 |
-
|
| 37 |
-
# Compute text embeddings
|
| 38 |
-
embeddings = model.encode(["Example sentence"])
|
| 39 |
-
```
|
| 40 |
-
|
| 41 |
-
### Using Sentence Transformers
|
| 42 |
-
|
| 43 |
-
You can also use the [Sentence Transformers library](https://github.com/UKPLab/sentence-transformers) to load and use the model:
|
| 44 |
-
|
| 45 |
-
```python
|
| 46 |
-
from sentence_transformers import SentenceTransformer
|
| 47 |
-
|
| 48 |
-
# Load a pretrained Sentence Transformer model
|
| 49 |
-
model = SentenceTransformer("category_classifier")
|
| 50 |
|
| 51 |
-
#
|
| 52 |
-
|
| 53 |
```
|
| 54 |
|
| 55 |
-
### Distilling a Model2Vec model
|
| 56 |
-
|
| 57 |
-
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:
|
| 58 |
-
|
| 59 |
-
```python
|
| 60 |
-
from model2vec.distill import distill
|
| 61 |
-
|
| 62 |
-
# Distill a Sentence Transformer model, in this case the BAAI/bge-base-en-v1.5 model
|
| 63 |
-
m2v_model = distill(model_name="BAAI/bge-base-en-v1.5", pca_dims=256)
|
| 64 |
-
|
| 65 |
-
# Save the model
|
| 66 |
-
m2v_model.save_pretrained("m2v_model")
|
| 67 |
-
```
|
| 68 |
-
|
| 69 |
-
## How it works
|
| 70 |
-
|
| 71 |
-
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.
|
| 72 |
-
|
| 73 |
-
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.
|
| 74 |
-
|
| 75 |
## Additional Resources
|
| 76 |
|
| 77 |
- [Model2Vec Repo](https://github.com/MinishLab/model2vec)
|
|
@@ -80,7 +40,6 @@ It works by passing a vocabulary through a sentence transformer model, then redu
|
|
| 80 |
- [Model2Vec Tutorials](https://github.com/MinishLab/model2vec/tree/main/tutorials)
|
| 81 |
- [Website](https://minishlab.github.io/)
|
| 82 |
|
| 83 |
-
|
| 84 |
## Library Authors
|
| 85 |
|
| 86 |
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).
|
|
|
|
| 11 |
|
| 12 |
# category_classifier Model Card
|
| 13 |
|
| 14 |
+
This [Model2Vec](https://github.com/MinishLab/model2vec) model is a fine-tuned version of the [unknown](https://huggingface.co/unknown) Model2Vec model. It also includes a classifier head on top.
|
|
|
|
| 15 |
|
| 16 |
## Installation
|
| 17 |
|
| 18 |
Install model2vec using pip:
|
| 19 |
```
|
| 20 |
+
pip install model2vec[inference]
|
| 21 |
```
|
| 22 |
|
| 23 |
## Usage
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
Load this model using the `from_pretrained` method:
|
| 25 |
```python
|
| 26 |
+
from model2vec.inference import StaticModelPipeline
|
| 27 |
|
| 28 |
# Load a pretrained Model2Vec model
|
| 29 |
+
model = StaticModelPipeline.from_pretrained("category_classifier")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
+
# Predict labels
|
| 32 |
+
predicted = model.predict(["Example sentence"])
|
| 33 |
```
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
## Additional Resources
|
| 36 |
|
| 37 |
- [Model2Vec Repo](https://github.com/MinishLab/model2vec)
|
|
|
|
| 40 |
- [Model2Vec Tutorials](https://github.com/MinishLab/model2vec/tree/main/tutorials)
|
| 41 |
- [Website](https://minishlab.github.io/)
|
| 42 |
|
|
|
|
| 43 |
## Library Authors
|
| 44 |
|
| 45 |
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).
|
category_mappings.json
CHANGED
|
@@ -32,19 +32,19 @@
|
|
| 32 |
"13": "space_exploration"
|
| 33 |
},
|
| 34 |
"valid_categories": [
|
| 35 |
-
"
|
| 36 |
-
"intelligence",
|
| 37 |
"immersive",
|
| 38 |
-
"energy",
|
| 39 |
-
"efficient_movement",
|
| 40 |
-
"quantum",
|
| 41 |
-
"neuro_tech",
|
| 42 |
"human_health",
|
| 43 |
-
"
|
| 44 |
"food_agri",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
"space_exploration",
|
| 46 |
"impossible_problems",
|
| 47 |
-
"
|
| 48 |
-
"
|
|
|
|
| 49 |
]
|
| 50 |
}
|
|
|
|
| 32 |
"13": "space_exploration"
|
| 33 |
},
|
| 34 |
"valid_categories": [
|
| 35 |
+
"machines_robotics",
|
|
|
|
| 36 |
"immersive",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
"human_health",
|
| 38 |
+
"efficient_movement",
|
| 39 |
"food_agri",
|
| 40 |
+
"earth_rejuvination",
|
| 41 |
+
"energy",
|
| 42 |
+
"intelligence",
|
| 43 |
+
"governance",
|
| 44 |
"space_exploration",
|
| 45 |
"impossible_problems",
|
| 46 |
+
"secure_digital_world",
|
| 47 |
+
"quantum",
|
| 48 |
+
"neuro_tech"
|
| 49 |
]
|
| 50 |
}
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 129967700
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c286d87884144f0199d1ca933e663af7724428039d66f317336b97bf914b46d2
|
| 3 |
size 129967700
|
pipeline.skops
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 7625043
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4e17d16f27337af7a87148b8f11adda7fbc841ce8150289e50b08b8ee2a1387a
|
| 3 |
size 7625043
|
tokenizer.json
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|