You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hugegraph.apache.org by "vichayturen (via GitHub)" <gi...@apache.org> on 2024/11/05 17:47:32 UTC

[PR] feat(llm): added the process of intelligent generated gremlin for retrieval before subgraph retrieval [incubator-hugegraph-ai]

vichayturen opened a new pull request, #105:
URL: https://github.com/apache/incubator-hugegraph-ai/pull/105

   (no comment)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org


Re: [PR] feat(llm): added the process of intelligent generated gremlin for retrieval before subgraph retrieval [incubator-hugegraph-ai]

Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin commented on code in PR #105:
URL: https://github.com/apache/incubator-hugegraph-ai/pull/105#discussion_r1856470801


##########
hugegraph-llm/src/hugegraph_llm/operators/index_op/gremlin_example_index_query.py:
##########
@@ -19,21 +19,43 @@
 import os
 from typing import Dict, Any
 
+from tqdm import tqdm
+import pandas as pd
 from hugegraph_llm.config import resource_path
 from hugegraph_llm.models.embeddings.base import BaseEmbedding
 from hugegraph_llm.indices.vector_index import VectorIndex
+from hugegraph_llm.models.embeddings.init_embedding import Embeddings
+from hugegraph_llm.utils.log import log
 
 
 class GremlinExampleIndexQuery:
-    def __init__(self, query: str, embedding: BaseEmbedding, num_examples: int = 1):
-        self.query = query
-        self.embedding = embedding
+    def __init__(self, embedding: BaseEmbedding = None, num_examples: int = 1):
+        self.embedding = embedding or Embeddings().get_embedding()
         self.num_examples = num_examples
         self.index_dir = os.path.join(resource_path, "gremlin_examples")
+        if not (os.path.exists(os.path.join(self.index_dir, "index.faiss"))
+                and os.path.exists(os.path.join(self.index_dir, "properties.pkl"))):
+            log.warning("No gremlin example index found, will generate one.")
+            self._build_default_example_index()
         self.vector_index = VectorIndex.from_index_file(self.index_dir)
 
     def run(self, context: Dict[str, Any]) -> Dict[str, Any]:
-        context["query"] = self.query
-        query_embedding = self.embedding.get_text_embedding(self.query)
-        context["match_result"] = self.vector_index.search(query_embedding, self.num_examples)
+        query = context.get("query")
+        assert query, "query is required"
+        if self.num_examples == 0:
+            context["match_result"] = []
+        else:
+            if "query_embedding" in context and isinstance(context["query_embedding"], list):
+                query_embedding = context["query_embedding"]
+            else:
+                query_embedding = self.embedding.get_text_embedding(query)
+            context["match_result"] = self.vector_index.search(query_embedding, self.num_examples, dis_threshold=2)

Review Comment:
   why we set `dis_threshold` to 2? (means always match topK?)
   
   Seems not reasonable 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org


Re: [PR] feat(llm): added the process of text2gql in graphrag V1.0 [incubator-hugegraph-ai]

Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin merged PR #105:
URL: https://github.com/apache/incubator-hugegraph-ai/pull/105


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org


Re: [PR] feat(llm): added the process of intelligent generated gremlin for retrieval before subgraph retrieval [incubator-hugegraph-ai]

Posted by "vichayturen (via GitHub)" <gi...@apache.org>.
vichayturen commented on PR #105:
URL: https://github.com/apache/incubator-hugegraph-ai/pull/105#issuecomment-2475898913

   > After implementing `text2gremlin` here, can [gremlin_generate_web_demo.py ](https://github.com/apache/incubator-hugegraph-ai/blob/main/hugegraph-llm/src/hugegraph_llm/demo/gremlin_generate_web_demo.py) be removed? 
   
   Yes, and it has been removed in new commit.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org


Re: [PR] feat(llm): added the process of intelligent generated gremlin for retrieval before subgraph retrieval [incubator-hugegraph-ai]

Posted by "simon824 (via GitHub)" <gi...@apache.org>.
simon824 commented on PR #105:
URL: https://github.com/apache/incubator-hugegraph-ai/pull/105#issuecomment-2470319162

   After implementing `text2gremlin` here, can [gremlin_generate_web_demo.py ](https://github.com/apache/incubator-hugegraph-ai/blob/main/hugegraph-llm/src/hugegraph_llm/demo/gremlin_generate_web_demo.py) be removed? 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org


Re: [PR] feat(llm): added the process of intelligent generated gremlin for retrieval before subgraph retrieval [incubator-hugegraph-ai]

Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin commented on PR #105:
URL: https://github.com/apache/incubator-hugegraph-ai/pull/105#issuecomment-2490255049

   We should add a `flag` value under the interface of graph query rag/graph: 
   - `1` represents text2gql accurate matching success
   - `0` represents generalization matching success
   - `-1` represents no relevant information


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org