Traceback (most recent call last): File "/home/bi-ai/ai/bottoms-up-embeddings/main.py", line 40, in <module> embed_model=InstructorEmbeddings(embed_batch_size=2), chunk_size=512 TypeError: Can't instantiate abstract class InstructorEmbeddings with abstract methods _aget_query_embedding, class_name
def class_name(self) -> str: return "InstructorEmbeddings" async def _aget_query_embedding(self, query: str) -> List[float]: return self._get_query_embedding(query)
Traceback (most recent call last): File "/home/bi-ai/ai/bottoms-up-embeddings/main.py", line 46, in <module> embed_model=InstructorEmbeddings(embed_batch_size=2), chunk_size=512 File "/home/bi-ai/ai/bottoms-up-embeddings/main.py", line 19, in __init__ self._model = INSTRUCTOR(instructor_model_name) File "pydantic/main.py", line 357, in pydantic.main.BaseModel.__setattr__ ValueError: "InstructorEmbeddings" object has no field "_model"
super().__init__( embed_batch_size=embed_batch_size, callback_manager=callback_manager, model_name=model_name, ) @classmethod def class_name(cls) -> str: """Get class name.""" return "LangchainEmbedding"
self._model = INSTRUCTOR(instructor_model_name)
class InstructorEmbeddings(BaseEmbedding): def __init__( self, instructor_model_name: str = "hkunlp/instructor-large", instruction: str = "Represent a document for semantic search:", **kwargs: Any, ) -> None: self._instruction = instruction super().__init__(**kwargs) self._model = INSTRUCTOR(instructor_model_name) def _get_query_embedding(self, query: str) -> List[float]: embeddings = self._model.encode([[self._instruction, query]]) return embeddings[0]
File "/home/bi-ai/ai/bottoms-up-embeddings/main.py", line 18, in __init__ self._instruction = instruction File "pydantic/main.py", line 357, in pydantic.main.BaseModel.__setattr__ ValueError: "InstructorEmbeddings" object has no field "_instruction"
File "pydantic/main.py", line 357, in pydantic.main.BaseModel.__setattr__ ValueError: "InstructorEmbeddings" object has no field "_model"
class InstructorEmbeddings(BaseEmbedding): def __init__( self, instructor_model_name: str = "hkunlp/instructor-large", **kwargs: Any, ) -> None: super().__init__(**kwargs) self._model = INSTRUCTOR(instructor_model_name) def _get_query_embedding(self, query: str) -> List[float]: embeddings = self._model.encode([[self._instruction, query]]) return embeddings[0]
@classmethod def from_defaults( cls, llm_predictor: Optional[BaseLLMPredictor] = None, llm: Optional[LLMType] = "default", prompt_helper: Optional[PromptHelper] = None, embed_model: Optional[EmbedType] = "default",
resolve_embed_model()
and resolve_llm()