FlagEmbedding icon indicating copy to clipboard operation
FlagEmbedding copied to clipboard

为什么只在LLMEmbedder的encode前加下划线,前面的模型没有

Open dream-tentacle opened this issue 1 year ago • 2 comments

https://github.com/FlagOpen/FlagEmbedding/blob/274f4c055a3685e0296a1593fd822f63b98bbca9/FlagEmbedding/flag_models.py#L516 是否应该删除下划线以保持一致性

dream-tentacle avatar Sep 20 '24 06:09 dream-tentacle

在python函数命名标准里,一般以单下划线起命名的函数是供内部其他函数调用的,不直接在API中使用 参考PEP 8 – Style Guide for Python Code

_single_leading_underscore: weak “internal use” indicator. E.g. from M import * does not import objects whose names start with an underscore.

LLMEmbedder是根据6个具体任务分别用不同的query instruction和key instruction进行微调的,所以在encode时需要针对不同任务对query和key选择不同的instruction,建议直接使用函数encode_queries()encode_keys()(他们都分别调用了_encode()),用法可以参考LLMEmbedder的README

ZiyiXia avatar Sep 21 '24 13:09 ZiyiXia

@ZiyiXia 谢谢,但我是和前面其他模型(FlagLLMModel、FlagModel)对比的,它们的接口看起来都是差不多的,如果是这样的话前面两个是否应该加上下划线?谢谢!

dream-tentacle avatar Sep 22 '24 01:09 dream-tentacle