LightRAG跑Ollama的例子没有正确输出的解决方法
摘要:在使用LightRAG时发现qwen2.5:32b模型无法正确输出结果,表现为无法识别输入内容。通过调整num_ctx参数或改用llama3.1:8b模型后,系统能正确分析《圣诞颂歌》的主题(如救赎、成长、社会阶层等)。但发现代码存在多个低级bug,质疑开发者是否进行充分测试。建议在使用时注意模型选择和参数配置,特别是上下文长度设置对结果的影响很大。
在上一篇博客中,介绍了LightRAG的基本安装和使用方法,但是如果用Ollama上的模型使用qwen2.5:32b的话,就没办法得到正确的输出,大概是这样的结果:
=====================
Query mode: naive
=====================
INFO: Naive query: 10 chunks (chunk_top_k: 10)
WARNING: Rerank is enabled but no rerank model is configured. Please set up a rerank model or set enable_rerank=False in query parameters.
INFO: Final context: 10 chunks
INFO: limit_async: 4 new workers initialized
I'm sorry, but you haven't provided a specific story for me to analyze. Could you please provide more details or context so I can assist you better?
=====================
Query mode: local
=====================
WARNING: low_level_keywords is empty, switching from local mode to global mode
INFO: Process 283479 building query context...
INFO: Query edges: Themes, Story analysis, top_k: 40, cosine: 0.2
INFO: Global query: 41 entites, 40 relations
INFO: Truncated KG query results: 41 entities, 40 relations
INFO: KG related chunks: 41 from entitys, 19 from relations
WARNING: Rerank is enabled but no rerank model is configured. Please set up a rerank model or set enable_rerank=False in query parameters.
INFO: Final context: 41 entities, 40 relations, 10 chunks
I'm sorry, but you didn't provide a specific story for me to analyze. Could you please share more details or name the story you're referring to? That way, I can help identify its main themes accurately.
=====================
Query mode: global
=====================
INFO: Process 283479 building query context...
INFO: Query edges: Themes, Story analysis, top_k: 40, cosine: 0.2
INFO: Global query: 41 entites, 40 relations
INFO: Truncated KG query results: 41 entities, 40 relations
INFO: KG related chunks: 41 from entitys, 19 from relations
WARNING: Rerank is enabled but no rerank model is configured. Please set up a rerank model or set enable_rerank=False in query parameters.
INFO: Final context: 41 entities, 40 relations, 10 chunks
I'm sorry, but you haven't provided a specific story for me to identify its themes. Could you please provide more details or specify which story you're referring to?
=====================
Query mode: hybrid
=====================
WARNING: low_level_keywords is empty, switching from hybrid mode to global mode
INFO: Process 283479 building query context...
INFO: Query edges: Themes, Story analysis, top_k: 40, cosine: 0.2
INFO: Global query: 41 entites, 40 relations
INFO: Truncated KG query results: 41 entities, 40 relations
INFO: KG related chunks: 41 from entitys, 19 from relations
WARNING: Rerank is enabled but no rerank model is configured. Please set up a rerank model or set enable_rerank=False in query parameters.
INFO: Final context: 41 entities, 40 relations, 10 chunks
I'm sorry, but you haven't provided a specific story for me to identify the themes. Could you please provide more details or context about the story you're referring to?INFO: Successfully finalized 10 storagesDone!
用的是默认设置,不知道到底有没有好好测试代码啊!!
让小伙伴分析了一下,发现把num_ctx增大一些,输出会有些改变:
llm_model_name=os.getenv("LLM_MODEL", "qwen2.5:32b"),
summary_max_tokens=8192,
llm_model_kwargs={
"host": os.getenv("LLM_BINDING_HOST", "http://localhost:10001"),
"options": {"num_ctx": 16000},
"timeout": int(os.getenv("TIMEOUT", "300")),
},
这时候输出结果是这样:

可以看到naive模式有输出了,呵呵呵呵。可以试着换一个上下文长度长一点的模型:
llm_model_name=os.getenv("LLM_MODEL", "llama3.1:8b"),
summary_max_tokens=8192,
llm_model_kwargs={
"host": os.getenv("LLM_BINDING_HOST", "http://localhost:10001"),
"options": {"num_ctx": 50000},
"timeout": int(os.getenv("TIMEOUT", "300")),
},
输出就变成这样了:
=====================
Query mode: naive
=====================
INFO: Naive query: 10 chunks (chunk_top_k: 10)
WARNING: Rerank is enabled but no rerank model is configured. Please set up a rerank model or set enable_rerank=False in query parameters.
INFO: Final context: 10 chunks
INFO: limit_async: 4 new workers initialized
**Themes of Christmas Past**The story revolves around Ebenezer Scrooge's journey through three spirits, each representing a different aspect of his life. The top themes that emerge from this narrative are:
1. **Redemption and Personal Growth**: Through his experiences with the Ghosts of Christmas Past, Present, and Yet to Come, Scrooge undergoes significant personal growth, recognizing the error of his ways and vowing to change for the better.
2. **The True Meaning of Christmas**: The story highlights the importance of kindness, generosity, and compassion during the holiday season. It emphasizes that Christmas is not just about material gifts but also about human connections and relationships.
3. **Avarice and Materialism vs. Human Connection**: Scrooge's excessive focus on wealth and material possessions serves as a stark contrast to the joy and connection he experiences through his interactions with others during the holiday season.
4. **The Impact of One's Actions on Others**: The story illustrates how Scrooge's actions, both positive and negative, affect those around him, demonstrating the importance of considering the consequences of one's behavior.
5. **Forgiveness and Letting Go**: Through his experiences, Scrooge comes to understand the value of forgiveness and letting go of past mistakes, allowing him to move forward with a newfound sense of purpose.These themes are central to the narrative, weaving together to create a rich tapestry that explores the complexities of human nature and the importance of empathy, compassion, and personal growth during the holiday season.
**References**
* [DC 1] "A Christmas Carol" by Charles Dickens (file_path: unknown_source)
* [DC 2] "A Christmas Carol" by Charles Dickens (file_path: unknown_source)
* [DC 3] "A Christmas Carol" by Charles Dickens (file_path: unknown_source)
* [DC 4] "A Christmas Carol" by Charles Dickens (file_path: unknown_source)
* [DC 5] "A Christmas Carol" by Charles Dickens (file_path: unknown_source)
=====================
Query mode: local
=====================
WARNING: low_level_keywords is empty, switching from local mode to global mode
INFO: Process 297957 building query context...
INFO: Query edges: Themes, Story analysis, top_k: 40, cosine: 0.2
INFO: Global query: 41 entites, 40 relations
INFO: Truncated KG query results: 41 entities, 40 relations
INFO: KG related chunks: 41 from entitys, 19 from relations
WARNING: Rerank is enabled but no rerank model is configured. Please set up a rerank model or set enable_rerank=False in query parameters.
INFO: Final context: 41 entities, 40 relations, 10 chunks
**Themes of Redemption and Personal Growth**The story revolves around Ebenezer Scrooge, a miserly old man who undergoes a profound transformation after being visited by three ghosts on Christmas Eve. The primary themes that emerge from the narrative are those of redemption and personal growth.
* **Redemption**: Throughout the story, Scrooge's past actions are revealed, showcasing his cruel treatment of others and his obsessive focus on wealth. However, as he encounters each ghost, he begins to confront his mistakes and develop a newfound sense of empathy. The Ghost of Christmas Past helps him understand the consequences of his actions and shows him memories from his childhood that highlight his potential for kindness. Similarly, the Ghost of Christmas Present reveals the impact of Scrooge's behavior on those around him, while the Ghost of Christmas Yet to Come depicts a grim future if he continues down his current path.
* **Personal Growth**: As Scrooge confronts his past and is shown possible futures, he begins to question his values and priorities. He starts to see the error of his ways and develops a deeper understanding of the importance of kindness, generosity, and compassion. This newfound awareness leads him to make amends for his past mistakes and attempt to change his behavior in the present.**Other Significant Themes**
* **Social Class**: The story highlights the stark contrast between the wealthy and the poor during this time period. Scrooge's character serves as a representation of the excesses of capitalism, while the Cratchit family embodies the struggles faced by those living in poverty.
* **The Importance of Human Connection**: Throughout the narrative, it becomes clear that Scrooge's isolation and focus on wealth have led to his emotional numbness. As he begins to form connections with others, such as Bob Cratchit and Tiny Tim, he starts to develop a sense of belonging and empathy.
* **Mortality and the Afterlife**: The story touches upon themes of mortality and the afterlife through Scrooge's encounters with the ghosts. The Ghost of Christmas Yet to Come serves as a reminder that our actions have consequences in this life and beyond.**References**
* [KG] "Scrooge" (entity) - "Character description: Ebenezer Scrooge, a miserly old man who undergoes a profound transformation after being visited by three ghosts on Christmas Eve."
* file_path: unknown_source
* [DC] "Marley's Ghost" (content)
* file_path: unknown_source
* [KG] "Ghost of Christmas Past" (entity) - "A ghostly figure who appears to Scrooge and guides him through memories from his past, highlighting the consequences of his actions."
* file_path: unknown_source
* [DC] "The school is not quite deserted, A solitary child, neglected by his friends, is left there still." (content)
* file_path: unknown_source
* [KG] "Spirit of Christmas Yet to Come" (entity) - "A ghostly figure who appears to Scrooge and depicts a grim future if he continues down his current path."
* file_path: unknown_source
=====================
Query mode: global
=====================
INFO: Process 297957 building query context...
INFO: Query edges: Themes, Story analysis, top_k: 40, cosine: 0.2
INFO: Global query: 41 entites, 40 relations
INFO: Truncated KG query results: 41 entities, 40 relations
INFO: KG related chunks: 41 from entitys, 19 from relations
WARNING: Rerank is enabled but no rerank model is configured. Please set up a rerank model or set enable_rerank=False in query parameters.
INFO: Final context: 41 entities, 40 relations, 10 chunks
Based on the Knowledge Graph and Document Chunks provided, we can identify several major themes present in this story.**Theme 1: Redemption and Personal Growth**
The story revolves around Ebenezer Scrooge's transformation from a miserly and bitter individual to one who is kind, generous, and compassionate. His experiences with the three spirits guide him towards redemption and personal growth, as he begins to understand the value of kindness, generosity, and empathy.**Theme 2: Social Class and Economic Inequality**
The story highlights the stark contrast between Scrooge's wealth and his treatment of others, particularly those in poverty. The Ghosts of Christmas Past, Present, and Yet to Come illustrate the consequences of Scrooge's actions on those around him, emphasizing the importance of considering the well-being of others.**Theme 3: Morality and Ethics**
The story raises questions about morality and ethics, encouraging readers to reflect on their own values and behaviors. The character of Jacob Marley serves as a warning about the consequences of living a life devoid of kindness and compassion.**Theme 4: Human Connection and Love**
Throughout the story, we see Scrooge's relationships with those around him, including his clerk Bob Cratchit, his nephew, and Tiny Tim. These interactions highlight the importance of human connection, love, and empathy in our lives.These themes are intertwined throughout the narrative, creating a rich and thought-provoking tale that continues to resonate with readers today.
**References:**
* [KG] "Scrooge" entity description
* [DC] File path: "unknown_source"
* [KG] "Marley's Ghost" entity description
* [DC] File path: "unknown_source"
* [KG] "Ebenezer Scrooge" entity description
=====================
Query mode: hybrid
=====================
WARNING: low_level_keywords is empty, switching from hybrid mode to global mode
INFO: Process 297957 building query context...
INFO: Query edges: Themes, Story analysis, top_k: 40, cosine: 0.2
INFO: Global query: 41 entites, 40 relations
INFO: Truncated KG query results: 41 entities, 40 relations
INFO: KG related chunks: 41 from entitys, 19 from relations
WARNING: Rerank is enabled but no rerank model is configured. Please set up a rerank model or set enable_rerank=False in query parameters.
INFO: Final context: 41 entities, 40 relations, 10 chunks
**Themes of Christmas Past**The story revolves around three main themes that Scrooge encounters through his supernatural experiences. These themes are closely intertwined and serve as a catalyst for Scrooge's transformation.
1. **Redemption and Personal Growth**: The story emphasizes the importance of personal growth, redemption, and self-improvement. Scrooge is given a second chance to alter his life's course and become a better person. This theme is particularly evident in the character development of Scrooge, who undergoes significant changes throughout the narrative.
2. **Compassion and Empathy**: The story highlights the significance of compassion, empathy, and kindness towards others. Scrooge's encounters with various characters, including his former clerk Bob Cratchit and his family, illustrate the importance of treating others with respect and dignity.
3. **Forgiveness and Second Chances**: The narrative explores the concept of forgiveness and second chances. Through his experiences, Scrooge comes to realize that it is never too late to change one's ways and make amends for past mistakes.**References**
* [KG] "Scrooge" entity description (file_path: unknown_source)
* [DC] "STAVE ONE: Marley's Ghost" (file_path: unknown_source)
* [KG] Relationship between Scrooge and the three spirits (file_path: unknown_source)
* [DC] "The Spirit of Christmas Past" section (file_path: unknown_source)
* [KG] Character description of Jacob Marley (file_path: unknown_source)INFO: Successfully finalized 10 storagesDone!
就简单总结这么多。想知道这些开源代码的学生有没有仔细测试过?为啥这么多低级的bug。
火山引擎开发者社区是火山引擎打造的AI技术生态平台,聚焦Agent与大模型开发,提供豆包系列模型(图像/视频/视觉)、智能分析与会话工具,并配套评测集、动手实验室及行业案例库。社区通过技术沙龙、挑战赛等活动促进开发者成长,新用户可领50万Tokens权益,助力构建智能应用。
更多推荐
所有评论(0)