-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Description
Thank you so much for this interesting implementation. It helps me gain cleared insight in how GraphRAG works and can use it further in my explorations.
The CLI works smooth with OpenAI, but I get an error message when I use Ollama with llama3.2
The error message I get is "ValueError: max() arg is an empty sequence" (see full output below)
Did I make an error or simple oversight? Or does this require debugging from your end?
Thanks again!
Klaas
This is the full output:
(langchain-graphrag) kbals@MacBookPro langchain-graphrag % rye run simple-app-indexer --llm-type ollama --llm-model llama3.2 --embedding-type ollama --embedding-model llama3.2 --ollama-num-context 10000
╭──────────────────────────────┬──────────────────────────────╮
│ LangSmith │ False │
│ Input file │ examples/input-data/book.txt │
│ Cache directory │ tmp/cache │
│ Vector store directory │ tmp/vector_stores │
│ Artifacts directory │ tmp/artifacts-llama3.2 │
│ LLM Type │ ollama │
│ LLM Model │ llama3.2 │
│ Embedding Type │ ollama │
│ Embedding Model │ llama3.2 │
│ Chunk Size │ 1200 │
│ Chunk Overlap │ 100 │
│ OLLAMA_HOST │ http://localhost:11434 │
│ Ollama Num Context │ 10000 │
╰──────────────────────────────┴──────────────────────────────╯
WARNING:main:common:******* Note - Good idea to provide num_context for Ollama Model *******
WARNING:main:common:******* Note - Good idea to provide num_context for Ollama Model *******
WARNING:main:common:******* Note - Good idea to provide num_context for Ollama Model *******
Extracting text units ...: 100%|████████████████████████████████| 39/39 [00:00<00:00, 202197.60it/s]
Processing documents ...: 100%|███████████████████████████████████████| 1/1 [00:00<00:00, 48.16it/s]
Extracting entities and relationships ...: 100%|███████████████████| 39/39 [00:00<00:00, 154.27it/s]
Summarizing entities descriptions: 0it [00:00, ?it/s]
Summarizing relationship descriptions: 0it [00:00, ?it/s]
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /Users/kbals/Programming/external/langchain-graphrag/examples/simple-app/app/indexer.py:193 in │
│ index │
│ │
│ 190 │ │ communities_report_artifacts_generator=communities_report_artifacts_generator, │
│ 191 │ ) │
│ 192 │ │
│ ❱ 193 │ artifacts = indexer.run(documents) │
│ 194 │ │
│ 195 │ # save the artifacts │
│ 196 │ save_artifacts(artifacts, artifacts_dir) │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ artifacts_dir = PosixPath('tmp/artifacts-llama3.2') │ │
│ │ cache_dir = PosixPath('tmp/cache') │ │
│ │ chunk_overlap = 100 │ │
│ │ chunk_size = 1200 │ │
│ │ communities_report_artifacts_generator = <langchain_graphrag.indexing.artifacts_generation.… │ │
│ │ object at 0x3275c6ec0> │ │
│ │ community_detector = <langchain_graphrag.indexing.graph_clustering.leid… │ │
│ │ object at 0x32837e0e0> │ │
│ │ documents = [ │ │
│ │ │ Document( │ │
│ │ │ │ metadata={ │ │
│ │ │ │ │ 'source': │ │
│ │ 'examples/input-data/book.txt' │ │
│ │ │ │ }, │ │
│ │ │ │ page_content='\ufeff A CHRISTMAS CAROL\n\n │ │
│ │ [Illustration: _"How now?" said Scrooge, caustic │ │
│ │ and col'+161062 │ │
│ │ │ ) │ │
│ │ ] │ │
│ │ embedding_model = 'llama3.2' │ │
│ │ embedding_type = <EmbeddingModelType.ollama: 'ollama'> │ │
│ │ enable_langsmith = False │ │
│ │ entities_artifacts_generator = <langchain_graphrag.indexing.artifacts_generation.… │ │
│ │ object at 0x328267f40> │ │
│ │ entities_collection_name = 'entity-llama3.2' │ │
│ │ entities_vector_store = <langchain_chroma.vectorstores.Chroma object at │ │
│ │ 0x328266ef0> │ │
│ │ entity_extractor = <langchain_graphrag.indexing.graph_generation.enti… │ │
│ │ object at 0x32837e8f0> │ │
│ │ entity_summarizer = <langchain_graphrag.indexing.graph_generation.enti… │ │
│ │ object at 0x32837fa30> │ │
│ │ graph_generator = <langchain_graphrag.indexing.graph_generation.gene… │ │
│ │ object at 0x32837e530> │ │
│ │ indexer = <langchain_graphrag.indexing.simple_indexer.Simple… │ │
│ │ object at 0x3275c4370> │ │
│ │ input_file = PosixPath('examples/input-data/book.txt') │ │
│ │ llm_model = 'llama3.2' │ │
│ │ llm_type = <LLMType.ollama: 'ollama'> │ │
│ │ ollama_num_context = 10000 │ │
│ │ output_dir = PosixPath('tmp') │ │
│ │ relationships_artifacts_generator = <langchain_graphrag.indexing.artifacts_generation.… │ │
│ │ object at 0x3275c5120> │ │
│ │ report_gen_llm = OllamaLLM( │ │
│ │ │ cache=<langchain_community.cache.SQLiteCache │ │
│ │ object at 0x3275c48b0>, │ │
│ │ │ model='llama3.2', │ │
│ │ │ num_predict=-1, │ │
│ │ │ temperature=0.0, │ │
│ │ │ top_p=1.0 │ │
│ │ ) │ │
│ │ report_generator = <langchain_graphrag.indexing.report_generation.gen… │ │
│ │ object at 0x3275c55a0> │ │
│ │ report_writer = <langchain_graphrag.indexing.report_generation.wri… │ │
│ │ object at 0x3275c51e0> │ │
│ │ text_splitter = <langchain_text_splitters.base.TokenTextSplitter │ │
│ │ object at 0x165681420> │ │
│ │ text_unit_extractor = <langchain_graphrag.indexing.text_unit_extractor.T… │ │
│ │ object at 0x326f773d0> │ │
│ │ text_units_artifacts_generator = <langchain_graphrag.indexing.artifacts_generation.… │ │
│ │ object at 0x3275c6ce0> │ │
│ │ vector_store_dir = PosixPath('tmp/vector_stores') │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /Users/kbals/Programming/external/langchain-graphrag/src/langchain_graphrag/indexing/simple_inde │
│ xer.py:52 in run │
│ │
│ 49 │ │ merged_graph, summarized_graph = self._graph_generator.run(df_base_text_units) │
│ 50 │ │ │
│ 51 │ │ # Step 3 - Detect communities in Graph │
│ ❱ 52 │ │ community_detection_result = self._community_detector.run(summarized_graph) │
│ 53 │ │ │
│ 54 │ │ # Step 4 - Reports for detected Communities (depends on Step 2 & Step 3) │
│ 55 │ │ df_communities_reports = self._communities_report_artifacts_generator.run( │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ df_base_text_units = │ │ │ │ │ │ │ document_id ... │ │
│ │ text_unit │ │
│ │ 0 ebc27719-5ba4-431c-806c-2ad353f81bca ... A CHRISTMAS CAROL\n\n │ │
│ │ [Illustration: _"How... │ │
│ │ 1 ebc27719-5ba4-431c-806c-2ad353f81bca ... at the grindstone, │ │
│ │ Scrooge! a\nsqueezing, wre... │ │
│ │ 2 ebc27719-5ba4-431c-806c-2ad353f81bca ... dismal? What reason have │ │
│ │ you to be morose? You... │ │
│ │ 3 ebc27719-5ba4-431c-806c-2ad353f81bca ... in Scrooge's office. │ │
│ │ They had books and paper... │ │
│ │ 4 ebc27719-5ba4-431c-806c-2ad353f81bca ... mighty Mansion House, │ │
│ │ gave orders to his\nfif... │ │
│ │ 5 ebc27719-5ba4-431c-806c-2ad353f81bca ... Marley's face. It was │ │
│ │ not in impenetrable shad... │ │
│ │ 6 ebc27719-5ba4-431c-806c-2ad353f81bca ... ointed fragments of his │ │
│ │ thoughts, there would ... │ │
│ │ 7 ebc27719-5ba4-431c-806c-2ad353f81bca ... and keeping down │ │
│ │ his\nterror; for the spectre... │ │
│ │ 8 ebc27719-5ba4-431c-806c-2ad353f81bca ... ]\n\n'On the wings of │ │
│ │ the wind,' replied the G... │ │
│ │ 9 ebc27719-5ba4-431c-806c-2ad353f81bca ... ation and regret; │ │
│ │ wailings inexpressibly sorro... │ │
│ │ 10 ebc27719-5ba4-431c-806c-2ad353f81bca ... ear.\n\n'Ding, │ │
│ │ dong!'\n\n'A quarter past,' sa... │ │
│ │ 11 ebc27719-5ba4-431c-806c-2ad353f81bca ... long way below │ │
│ │ freezing; that he was clad but... │ │
│ │ 12 ebc27719-5ba4-431c-806c-2ad353f81bca ... in the\ndull yard │ │
│ │ behind, not a sigh among th... │ │
│ │ 13 ebc27719-5ba4-431c-806c-2ad353f81bca ... touch his head; │ │
│ │ but,\nbeing too little laughe... │ │
│ │ 14 ebc27719-5ba4-431c-806c-2ad353f81bca ... of room\nhere! │ │
│ │ Hilli-ho, Dick! Chirrup, Ebene... │ │
│ │ 15 ebc27719-5ba4-431c-806c-2ad353f81bca ... a counter\nin the │ │
│ │ back-shop.\n\nDuring the wh... │ │
│ │ 16 ebc27719-5ba4-431c-806c-2ad353f81bca ... end. In everything that │ │
│ │ made my love of\nany ... │ │
│ │ 17 ebc27719-5ba4-431c-806c-2ad353f81bca ... the baby had been taken │ │
│ │ in\nthe act of puttin... │ │
│ │ 18 ebc27719-5ba4-431c-806c-2ad353f81bca ... prepared for nothing; │ │
│ │ and consequently, when t... │ │
│ │ 19 ebc27719-5ba4-431c-806c-2ad353f81bca ... .'\n\n'Touch my │ │
│ │ robe!'\n\nScrooge did as he wa... │ │
│ │ 20 ebc27719-5ba4-431c-806c-2ad353f81bca ... in its Christmas dress; │ │
│ │ but the customers wer... │ │
│ │ 21 ebc27719-5ba4-431c-806c-2ad353f81bca ... and she laid the cloth, │ │
│ │ assisted by Belinda\n... │ │
│ │ 22 ebc27719-5ba4-431c-806c-2ad353f81bca ... vigour; Miss\nBelinda │ │
│ │ sweetened up the apple ... │ │
│ │ 23 ebc27719-5ba4-431c-806c-2ad353f81bca ... \nremain unaltered by │ │
│ │ the Future, the child wi... │ │
│ │ 24 ebc27719-5ba4-431c-806c-2ad353f81bca ... flickering of the blaze │ │
│ │ showed preparations f... │ │
│ │ 25 ebc27719-5ba4-431c-806c-2ad353f81bca ... , the officers who had │ │
│ │ the watch; dark, ghostl... │ │
│ │ 26 ebc27719-5ba4-431c-806c-2ad353f81bca ... on the subject. Whereat │ │
│ │ Scrooge's niece's\nsi... │ │
│ │ 27 ebc27719-5ba4-431c-806c-2ad353f81bca ... was made\ncomfortable │ │
│ │ with a large chair and ... │ │
│ │ 28 ebc27719-5ba4-431c-806c-2ad353f81bca ... , but never spoke of │ │
│ │ it\nuntil they left a chi... │ │
│ │ 29 ebc27719-5ba4-431c-806c-2ad353f81bca ... his condition, and │ │
│ │ giving him time to\nrecove... │ │
│ │ 30 ebc27719-5ba4-431c-806c-2ad353f81bca ... ge was at first inclined │ │
│ │ to be surprised that ... │ │
│ │ 31 ebc27719-5ba4-431c-806c-2ad353f81bca ... aunting manner on a │ │
│ │ stool, crossing her\nelbow... │ │
│ │ 32 ebc27719-5ba4-431c-806c-2ad353f81bca ... threadbare place. It's │ │
│ │ the best he had, and a... │ │
│ │ 33 ebc27719-5ba4-431c-806c-2ad353f81bca ... .\n\nShe was expecting │ │
│ │ some one, and with anxi... │ │
│ │ 34 ebc27719-5ba4-431c-806c-2ad353f81bca ... hob,\nand they all │ │
│ │ tried who should help him ... │ │
│ │ 35 ebc27719-5ba4-431c-806c-2ad353f81bca ... , save that they were in │ │
│ │ the Future--into the ... │ │
│ │ 36 ebc27719-5ba4-431c-806c-2ad353f81bca ... one of his │ │
│ │ bed-curtains\nin his arms, 'They a... │ │
│ │ 37 ebc27719-5ba4-431c-806c-2ad353f81bca ... it he did, somehow, and │ │
│ │ went downstairs to ope... │ │
│ │ 38 ebc27719-5ba4-431c-806c-2ad353f81bca ... with his hand already │ │
│ │ on the\ndining-room loc... │ │
│ │ │ │
│ │ [39 rows x 3 columns] │ │
│ │ documents = [ │ │
│ │ │ Document( │ │
│ │ │ │ metadata={'source': 'examples/input-data/book.txt'}, │ │
│ │ │ │ page_content='\ufeff A CHRISTMAS CAROL\n\n [Illustration: │ │
│ │ _"How now?" said Scrooge, caustic and col'+161062 │ │
│ │ │ ) │ │
│ │ ] │ │
│ │ merged_graph = <networkx.classes.graph.Graph object at 0x3275c63e0> │ │
│ │ self = <langchain_graphrag.indexing.simple_indexer.SimpleIndexer object at │ │
│ │ 0x3275c4370> │ │
│ │ summarized_graph = <networkx.classes.graph.Graph object at 0x3275c6980> │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /Users/kbals/Programming/external/langchain-graphrag/src/langchain_graphrag/indexing/graph_clust │
│ ering/leiden_community_detector.py:35 in run │
│ │
│ 32 │ │
│ 33 │ def run(self, graph: nx.Graph) -> CommunityDetectionResult: │
│ 34 │ │ if self._use_lcc: │
│ ❱ 35 │ │ │ graph = stable_largest_connected_component(graph) │
│ 36 │ │ │
│ 37 │ │ community_mapping: HierarchicalClusters = hierarchical_leiden( │
│ 38 │ │ │ graph, │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ graph = <networkx.classes.graph.Graph object at 0x3275c6980> │ │
│ │ self = <langchain_graphrag.indexing.graph_clustering.leiden_community_detector.Hierarchica… │ │
│ │ object at 0x32837e0e0> │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /Users/kbals/Programming/external/langchain-graphrag/src/langchain_graphrag/indexing/_graph_util │
│ s.py:63 in stable_largest_connected_component │
│ │
│ 60 │
│ 61 def stable_largest_connected_component(graph: nx.Graph) -> nx.Graph: │
│ 62 │ graph = graph.copy() │
│ ❱ 63 │ graph = cast(nx.Graph, largest_connected_component(graph)) │
│ 64 │ graph = normalize_node_names(graph) │
│ 65 │ return _stabilize_graph(graph) │
│ 66 │
│ │
│ ╭─────────────────────────── locals ───────────────────────────╮ │
│ │ graph = <networkx.classes.graph.Graph object at 0x3275c65c0> │ │
│ ╰──────────────────────────────────────────────────────────────╯ │
│ │
│ /Users/kbals/Programming/external/langchain-graphrag/.venv/lib/python3.10/site-packages/graspolo │
│ gic/utils/utils.py:586 in largest_connected_component │
│ │
│ 583 │ """ │
│ 584 │ │
│ 585 │ if isinstance(graph, (nx.Graph, nx.DiGraph, nx.MultiGraph, nx.MultiDiGraph)): │
│ ❱ 586 │ │ return _largest_connected_component_networkx(graph, return_inds=return_inds) │
│ 587 │ elif isinstance(graph, (np.ndarray, csr_array)): │
│ 588 │ │ return _largest_connected_component_adjacency(graph, return_inds=return_inds) │
│ 589 │ else: │
│ │
│ ╭────────────────────────────── locals ──────────────────────────────╮ │
│ │ graph = <networkx.classes.graph.Graph object at 0x3275c65c0> │ │
│ │ return_inds = False │ │
│ ╰────────────────────────────────────────────────────────────────────╯ │
│ │
│ /Users/kbals/Programming/external/langchain-graphrag/.venv/lib/python3.10/site-packages/graspolo │
│ gic/utils/utils.py:602 in _largest_connected_component_networkx │
│ │
│ 599 │ return_inds: bool = False, │
│ 600 ) -> Union[nx.Graph, Tuple[nx.Graph, np.ndarray]]: │
│ 601 │ if type(graph) in [nx.Graph, nx.MultiGraph]: │
│ ❱ 602 │ │ lcc_nodes = max(nx.connected_components(graph), key=len) │
│ 603 │ elif type(graph) in [nx.DiGraph, nx.MultiDiGraph]: │
│ 604 │ │ lcc_nodes = max(nx.weakly_connected_components(graph), key=len) │
│ 605 │ lcc = graph.subgraph(lcc_nodes).copy() │
│ │
│ ╭────────────────────────────── locals ──────────────────────────────╮ │
│ │ graph = <networkx.classes.graph.Graph object at 0x3275c65c0> │ │
│ │ return_inds = False │ │
│ ╰────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
ValueError: max() arg is an empty sequence
(langchain-graphrag) kbals@MacBookPro langchain-graphrag %
Metadata
Metadata
Assignees
Labels
No labels