Replies: 3 comments
-
🤖 Hello, To query based on a particular embedding in the LlamaIndex database after obtaining it from a collection using LLM, you can use the Here is an example of how you can use it: from llama_index.vector_stores.types import VectorStoreQuery, VectorStoreQueryMode
# Assume query_embedding is the embedding you obtained
query = VectorStoreQuery(
query_embedding=query_embedding,
similarity_top_k=10, # top 10 most similar nodes
mode=VectorStoreQueryMode.DEFAULT
)
result = MilvusVectorStore().query(query)
# result.nodes will contain the most similar nodes
# result.similarities will contain the similarities
# result.ids will contain the ids Please note that you need to replace The
You can find more details in the source code:
I hope this helps! If you have any other questions, feel free to ask. Best, Sources
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
Beta Was this translation helpful? Give feedback.
-
how to define what LLM is being used |
Beta Was this translation helpful? Give feedback.
-
🤖 Hello, Yes, you are on the right track. Your understanding of the The Here is the relevant code: def query(self, query: VectorStoreQuery, **kwargs: Any) -> VectorStoreQueryResult:
"""Query index for top k most similar nodes.
Args:
query_embedding (List[float]): query embedding
similarity_top_k (int): top k most similar nodes
doc_ids (Optional[List[str]]): list of doc_ids to filter by
node_ids (Optional[List[str]]): list of node_ids to filter by
output_fields (Optional[List[str]]): list of fields to return
embedding_field (Optional[str]): name of embedding field
"""
if query.mode != VectorStoreQueryMode.DEFAULT:
raise ValueError(f"Milvus does not support {query.mode} yet.")
expr = []
output_fields = ["*"]
# Parse the filter
if query.filters is not None:
expr.extend(_to_milvus_filter(query.filters))
# Parse any docs we are filtering on
if query.doc_ids is not None and len(query.doc_ids) != 0:
expr_list = ['"' + entry + '"' for entry in query.doc_ids]
expr.append(f"{self.doc_id_field} in [{','.join(expr_list)}]")
# Parse any nodes we are filtering on
if query.node_ids is not None and len(query.node_ids) != 0:
expr_list = ['"' + entry + '"' for entry in query.node_ids]
expr.append(f"{MILVUS_ID_FIELD} in [{','.join(expr_list)}]")
# Limit output fields
if query.output_fields is not None:
output_fields = query.output_fields
# Convert to string expression
string_expr = ""
if len(expr) != 0:
string_expr = " and ".join(expr)
# Perfom the search
res = self.milvusclient.search(
collection_name=self.collection_name,
data=[query.query_embedding],
filter=string_expr,
limit=query.similarity_top_k,
output_fields=output_fields,
)
logger.debug(
f"Successfully searched embedding in collection: {self.collection_name}"
f" Num Results: {len(res[0])}"
)
nodes = []
similarities = []
ids = []
# Parse the results
for hit in res[0]:
node = metadata_dict_to_node(
{"_node_content": hit["entity"].get("_node_content", None)}
)
nodes.append(node)
similarities.append(hit["distance"])
ids.append(hit["id"])
return VectorStoreQueryResult(nodes=nodes, similarities=similarities, ids=ids) The There are no additional steps you need to take unless you want to filter the results by specific document IDs or node IDs, in which case you would include these in the As for the I hope this helps! If you have any other questions, feel free to ask. Best, SourcesThis response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
Beta Was this translation helpful? Give feedback.
-
Question Validation
Question
collection.get(
ids=["id1", "id2", "id3", ...],
where={"style": "style1"}
)
https://docs.trychroma.com/usage-guide#querying-a-collection
got the particular embedding then do LLM query , how to do this?
Beta Was this translation helpful? Give feedback.
All reactions