Update README.md
Browse files
README.md
CHANGED
|
@@ -18,13 +18,40 @@ It's so funny that the huggingface hub lets you do this
|
|
| 18 |
|
| 19 |
multiprocessing is suuuper weird so make sure you dont have the variables "p" or "calculate_ncd_row" in your code anywhere..
|
| 20 |
|
| 21 |
-
|
|
|
|
|
|
|
| 22 |
```python
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
model.config.update({
|
| 26 |
-
"corpus":
|
| 27 |
})
|
|
|
|
|
|
|
| 28 |
```
|
| 29 |
|
| 30 |
config:
|
|
|
|
| 18 |
|
| 19 |
multiprocessing is suuuper weird so make sure you dont have the variables "p" or "calculate_ncd_row" in your code anywhere..
|
| 20 |
|
| 21 |
+
### Usage
|
| 22 |
+
|
| 23 |
+
|
| 24 |
```python
|
| 25 |
+
# Requirements
|
| 26 |
+
%pip install -qq transformers
|
| 27 |
+
|
| 28 |
+
# Download Model
|
| 29 |
+
from transformers import AutoModel
|
| 30 |
+
model = AutoModel.from_pretrained("crumb/gzip-openhermes", trust_remote_code=True)
|
| 31 |
+
|
| 32 |
+
# Prune model
|
| 33 |
+
model.config.update({
|
| 34 |
+
"corpus": model.config.corpus[:1024]
|
| 35 |
+
})
|
| 36 |
+
model.dimensionality() # 1024
|
| 37 |
+
|
| 38 |
+
# Inference
|
| 39 |
+
model(["this is a test sequence"], num_procs=16).shape # [1, 1024]
|
| 40 |
+
|
| 41 |
+
# Finetuning
|
| 42 |
+
from tqdm.auto import tqdm
|
| 43 |
+
|
| 44 |
+
new_data = ["i love GZIP! it is my favorite!", "i HATE transformers!"]
|
| 45 |
+
normalized_data = [
|
| 46 |
+
model.normalize(i) for i in tqdm(new_data)
|
| 47 |
+
]
|
| 48 |
+
print(f"Input: '{new_data[0]}'\nTransformed: '{normalized_data[0]}'")
|
| 49 |
+
|
| 50 |
model.config.update({
|
| 51 |
+
"corpus": model.config.corpus + normalized_data
|
| 52 |
})
|
| 53 |
+
model.dimensionality()
|
| 54 |
+
model.save_pretrained("my-finetuned-gzip-model")
|
| 55 |
```
|
| 56 |
|
| 57 |
config:
|