Feature Extraction
sentence-transformers
PyTorch
Chinese
bert
mteb
Eval Results (legacy)
text-embeddings-inference
Instructions to use OpenSearch-AI/Ops-MoA-Conan-embedding-v1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use OpenSearch-AI/Ops-MoA-Conan-embedding-v1 with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("OpenSearch-AI/Ops-MoA-Conan-embedding-v1") sentences = [ "The weather is lovely today.", "It's so sunny outside!", "He drove to the stadium." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [3, 3] - Notebooks
- Google Colab
- Kaggle
Update modeling_adaptor.py
Browse files- modeling_adaptor.py +16 -0
modeling_adaptor.py
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import torch
|
| 2 |
import torch.nn as nn
|
| 3 |
import torch.nn.functional as F
|
| 4 |
|
|
|
|
| 5 |
class MoAGate(nn.Module):
|
| 6 |
def __init__(self, num_adaptors, hidden_dim):
|
| 7 |
super().__init__()
|
|
@@ -84,4 +88,16 @@ class MixtureOfAdaptors(nn.Module):
|
|
| 84 |
)
|
| 85 |
return adaptor_cache
|
| 86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import json
|
| 3 |
+
|
| 4 |
import torch
|
| 5 |
import torch.nn as nn
|
| 6 |
import torch.nn.functional as F
|
| 7 |
|
| 8 |
+
|
| 9 |
class MoAGate(nn.Module):
|
| 10 |
def __init__(self, num_adaptors, hidden_dim):
|
| 11 |
super().__init__()
|
|
|
|
| 88 |
)
|
| 89 |
return adaptor_cache
|
| 90 |
|
| 91 |
+
@classmethod
|
| 92 |
+
def load(cls, input_path):
|
| 93 |
+
with open(os.path.join(input_path, "config.json")) as fIn:
|
| 94 |
+
config = json.load(fIn)
|
| 95 |
+
|
| 96 |
+
adaptor = cls(**config)
|
| 97 |
+
adaptor.load_state_dict(
|
| 98 |
+
torch.load(
|
| 99 |
+
os.path.join(input_path, "adaptor.pth"), weights_only=True
|
| 100 |
+
)
|
| 101 |
+
)
|
| 102 |
+
return adaptor
|
| 103 |
|