-
Notifications
You must be signed in to change notification settings - Fork 8
Feat/api embeddings #263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Feat/api embeddings #263
Conversation
сейчас мне немного разонравилось то как устроены dump и load у Embedder и VectorIndex и в целом конфиги для них - по-моему в таком варианте нельзя задать конфиг из yaml файла я это поправлю в другом PR |
""" | ||
return self._backend.get_hash() | ||
|
||
def train(self, utterances: list[str], labels: ListOfLabels, config: EmbedderFineTuningConfig) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Мб в BaseEmbeddingBackend
добавить train и его вызывать?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не думаю что красивее сделать получится
тут потому что EmbedderFineTuningConfig
содержит специфичные для sentence-transformers
параметры
я бы тогда просто предложил переименовать train
-> train_st
и в докстринге обозначить что этот метод работает только с SentenceTransformersEmbeddingBackend
все равно пока что фича с тренировкой эмбедингов не встроена в наш EmbeddingNode
batch = utterances[i : i + self.config.batch_size] | ||
|
||
# Prepare API call parameters | ||
kwargs: EmbeddingsCreateKwargs = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Можно добавить truncate_prompt_tokens
, не знаю есть такое у openai или нет (но на сколько помню у них вообще криво все сделано по токенизации)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не очень вообще шарю за то, что за truncate_prompt_tokens
можешь подробнее рассказать в будущем или открыть issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
У vllm есть параметр truncate_prompt_tokens
, который будет обрезать ввод по количеству токенов, если больше max_tokens модели отправить, то выдается ошибка. Если в openai отправить больше чем 8191 токен, то тоже просто ошибка будет
kwargs: EmbeddingsCreateKwargs = { | ||
"input": batch, | ||
"model": self.config.model_name, | ||
} | ||
if self.config.dimensions is not None: | ||
kwargs["dimensions"] = self.config.dimensions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Можно вынести в функцию
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
в аргументы функции _process_embeddings_sync
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Создание kwargs можно вынести в функцию, тк дублируется между функциями
No description provided.