Skip to content

Commit

Permalink
Drop llm.EmbeddingModel.embedding_size property, closes #208
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Sep 2, 2023
1 parent 3d56d6c commit e49c816
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 5 deletions.
5 changes: 2 additions & 3 deletions docs/embeddings/writing-plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@ from sentence_transformers import SentenceTransformer
@llm.hookimpl
def register_embedding_models(register):
model_id = "sentence-transformers/all-MiniLM-L6-v2"
register(SentenceTransformerModel(model_id, model_id, 384), aliases=("all-MiniLM-L6-v2",))
register(SentenceTransformerModel(model_id, model_id), aliases=("all-MiniLM-L6-v2",))


class SentenceTransformerModel(llm.EmbeddingModel):
def __init__(self, model_id, model_name, embedding_size):
def __init__(self, model_id, model_name):
self.model_id = model_id
self.model_name = model_name
self.embedding_size = embedding_size
self._model = None

def embed_batch(self, texts):
Expand Down
1 change: 0 additions & 1 deletion llm/default_plugins/openai_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def register_embedding_models(register):

class Ada002(EmbeddingModel):
model_id = "ada-002"
embedding_size = 1536
needs_key = "openai"
key_env_var = "OPENAI_API_KEY"
batch_size = 100 # Maybe this should be 2048
Expand Down
1 change: 0 additions & 1 deletion llm/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ def __repr__(self):

class EmbeddingModel(ABC, _get_key_mixin):
model_id: str
embedding_size: int
key: Optional[str] = None
needs_key: Optional[str] = None
key_env_var: Optional[str] = None
Expand Down

0 comments on commit e49c816

Please sign in to comment.