Update README.md
Browse files
README.md
CHANGED
|
@@ -145,6 +145,7 @@ embeddings = model.encode(
|
|
| 145 |
'def save_act(self, path=None): if path is None: path = os.path.join(logger.get_dir(), "model.pkl") with tempfile.TemporaryDirectory() as td: save_variables(os.path.join(td, "model")) arc_name = os.path.join(td, "packed.zip") with zipfile.ZipFile(arc_name, "w") as zipf: for root, dirs, files in os.walk(td): for fname in files: file_path = os.path.join(root, fname) if file_path != arc_name: zipf.write(file_path, os.path.relpath(file_path, td)) with open(arc_name, "rb") as f: model_data = f.read() with open(path, "wb") as f: cloudpickle.dump((model_data, self._act_params), f)',
|
| 146 |
]
|
| 147 |
)
|
|
|
|
| 148 |
```
|
| 149 |
|
| 150 |
If you only want to handle shorter sequence, such as 2k, pass the `max_length` parameter to the `encode` function:
|
|
|
|
| 145 |
'def save_act(self, path=None): if path is None: path = os.path.join(logger.get_dir(), "model.pkl") with tempfile.TemporaryDirectory() as td: save_variables(os.path.join(td, "model")) arc_name = os.path.join(td, "packed.zip") with zipfile.ZipFile(arc_name, "w") as zipf: for root, dirs, files in os.walk(td): for fname in files: file_path = os.path.join(root, fname) if file_path != arc_name: zipf.write(file_path, os.path.relpath(file_path, td)) with open(arc_name, "rb") as f: model_data = f.read() with open(path, "wb") as f: cloudpickle.dump((model_data, self._act_params), f)',
|
| 146 |
]
|
| 147 |
)
|
| 148 |
+
print(cos_sim(embeddings[0], embeddings[1]))
|
| 149 |
```
|
| 150 |
|
| 151 |
If you only want to handle shorter sequence, such as 2k, pass the `max_length` parameter to the `encode` function:
|