Initialize the LLM embedding client and (optionally) a separate embedding model based on specified names.
Parameters: |
-
model_category
(str )
–
The name of the language model provider (e.g., 'openai', 'huggingface', 'cohere').
-
embedding_model_name
(str )
–
The name of the embedding model.
-
api_key
(str , default:
None
)
–
The API key for the selected provider. Default is None.
-
model_parameters
(dict , default:
None
)
–
Additional parameters for model configuration. Default is an empty dictionary if not provided.
|
Source code in llamarch/common/llm_embedding.py
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 | def __init__(self,
model_category: str,
embedding_model_name: str,
api_key: Optional[str] = None,
model_parameters: Optional[Dict[str, Any]] = None):
"""
Initialize the LLM embedding client and (optionally) a separate embedding model based on specified names.
Parameters
----------
model_category : str
The name of the language model provider (e.g., 'openai', 'huggingface', 'cohere').
embedding_model_name : str
The name of the embedding model.
api_key : str, optional
The API key for the selected provider. Default is None.
model_parameters : dict, optional
Additional parameters for model configuration. Default is an empty dictionary if not provided.
"""
self.model_category = model_category.lower()
self.embedding_model_name = embedding_model_name.lower(
) if embedding_model_name else None
self.api_key = api_key
self.model_parameters = model_parameters or {}
# Initialize the language model and embedding model
self.embedding_model = self._initialize_embeddings()
|