run-llama / llama_index

LlamaIndex is a data framework for your LLM applications
https://docs.llamaindex.ai
MIT License
36.75k stars 5.27k forks source link

[Question]: JinaEmbedding v3's Task definition for retrieval #16251

Open kun432 opened 1 month ago

kun432 commented 1 month ago

Question Validation

Question

As my understanding, using Jina Embedding v3 for RAG,

In codes, https://github.com/run-llama/llama_index/blob/05213ce9cacccc6b9509e4261c63faa66dbbba19/llama-index-integrations/embeddings/llama-index-embeddings-jinaai/llama_index/embeddings/jinaai/base.py

when the task parameter is set to "retrieval.passage", I think _get_query_embedding and _aget_query_embedding should use "retrieval.query", but seems they simpy use "retrieval.passage" passed from the constructor.

Is this correct behavior especially when using index.as_retriever()?

dosubot[bot] commented 1 month ago

Yes, it is correct behavior for the methods _get_query_embedding and _aget_query_embedding to use the task type "retrieval.passage" instead of "retrieval.query" when using index.as_retriever() in Jina Embedding v3 [1][2][3].

To continue talking to Dosu, mention @dosu.

kun432 commented 1 month ago

@dosu don't think so.

dosubot[bot] commented 1 month ago

The methods _get_query_embedding and _aget_query_embedding in the JinaEmbedding class are designed to use the task type specified during initialization, which can be "retrieval.passage". This is appropriate for encoding large documents in retrieval tasks at indexing time. The context provided in the documentation and codebase supports this usage [1][2][3].

To continue talking to Dosu, mention @dosu.

kun432 commented 1 month ago

@dosu I think for indexing time, _get_text_embeddings and _aget_text_embeddings are used. _get_query_embedding and _aget_query_embedding are used for querying time. those are different.

dosubot[bot] commented 1 month ago

Yes, you are correct. For indexing time, _get_text_embeddings and _aget_text_embeddings are used, while _get_query_embedding and _aget_query_embedding are used for querying time in JinaEmbedding v3 [1][2][3].

To continue talking to Dosu, mention @dosu.