Sure, here's the text translated into simplified Chinese while keeping the HTML structure intact: ```html GraphRAG 使用 LangChain ``` In this example, `` tags are used to encapsulate the translated text, maintaining the HTML structure as requested.

Sure, here's how you could write "codes explained with example, Generative AI" in simplified Chinese, while keeping the HTML structure intact: ```html 代码通过示例解释,生成式人工智能 ``` In this HTML snippet: - `` and `` tags would encapsulate the content. - `
` or other tags could be used for structuring the content further if needed. Let me know if you need more help with this!
Photo by Nastya Dulhiier on Unsplash

```html

GraphRAG 自从微软发布他们的 GraphRAG Git 仓库以来,成为了城中的热门话题,该仓库在 Git 上迅速走红。

```

Sure, here's the translated text in simplified Chinese, keeping the HTML structure intact: ```html

图形RAG是标准RAG的先进版本,其使用知识库而非向量相似度和向量数据库来从外部文档中检索信息,使检索更为全面和完整。

``` This HTML snippet preserves the structure while presenting the translated text in simplified Chinese.

Sure! Here’s the translation while keeping the HTML structure: ```html 我已经在下面的帖子中详细介绍了 GraphRAG: ```

Sure, here's how you can write "What is GraphRAG?" in simplified Chinese while keeping the HTML structure intact: ```html 什么是GraphRAG? ```

Sure, here's the translation in simplified Chinese while keeping the HTML structure: ```html

GraphRAG如何工作?

```

Certainly! Here's the translation in simplified Chinese, keeping the HTML structure intact: ```html

以上两篇文章是继续前进的先决条件。

```

Sure! Here’s the translation of the text into Simplified Chinese, while keeping the HTML structure intact: ```html In this post, I would run through a basic example on how to setup GraphRAG using LangChain and use it to improve your RAG systems (using any LLM model or API) 在这篇文章中,我将通过一个基本示例来介绍如何使用 LangChain 设置 GraphRAG,并利用它来改进你的 RAG 系统(使用任何 LLM 模型或 API) ``` Here’s a breakdown of the translation: - **In this post** — 在这篇文章中 - **I would run through a basic example** — 我将通过一个基本示例来介绍 - **on how to setup GraphRAG using LangChain** — 如何使用 LangChain 设置 GraphRAG - **and use it to improve your RAG systems** — 并利用它来改进你的 RAG 系统 - **(using any LLM model or API)** — (使用任何 LLM 模型或 API) If you need any further adjustments or have additional text to translate, feel free to let me know!

Here’s the translation while keeping the HTML structure: ```html My debut book: LangChain in your Pocket is out now !! 我的处女作:口袋里的LangChain 现在发布啦!! ```

```html

我们将讨论两种方法

```

Sure, here is the translation of "LLMGraphTransformer" into simplified Chinese while keeping the HTML structure intact: ```html LLMGraphTransformer ``` In Chinese characters, it would be represented as "LLM图转换器".

  1. Sure, here's how you can express "You 1st need to pip install a few essential libraries" in simplified Chinese while maintaining HTML structure: ```html 你首先需要通过 pip 安装几个必要的库 ``` This translation keeps the sentence clear and concise, suitable for an HTML context.
  2. pip install --upgrade --quiet  json-repair networkx langchain-core langchain-google-vertexai langchain-experimental langchain-community

    #versions used
    langchain==0.2.8
    langchain-community==0.2.7
    langchain-core==0.2.19
    langchain-experimental==0.0.62
    langchain-google-vertexai==1.0.3

Sure, here's the translation in simplified Chinese, keeping the HTML structure intact: ```html 注意:您可以跳过谷歌VertexAI,也可以使用任何其他LLM。 ``` This HTML snippet now contains the translated text "注意:您可以跳过谷歌VertexAI,也可以使用任何其他LLM。"

下面是将您提供的英文文本翻译成简体中文的版本,保留了 HTML 结构: ```html 2. 导入所需的函数。初始化您的 LLM 对象并引用文本。使用任何最先进的 LLM 以获得最佳结果,因为知识图谱的创建是一个复杂的任务。 ``` ### 中文翻译说明 - **Import required functions.** 翻译为 **导入所需的函数。** - **Initialize your LLM object & reference text.** 翻译为 **初始化您的 LLM 对象并引用文本。** - **Use any SOTA LLM for best results as Knowledge Graph creation is a complicated task.** 翻译为 **使用任何最先进的 LLM 以获得最佳结果,因为知识图谱的创建是一个复杂的任务。** ### 完整的翻译文本 ```html 2. 导入所需的函数。初始化您的 LLM 对象并引用文本。使用任何最先进的 LLM 以获得最佳结果,因为知识图谱的创建是一个复杂的任务。 ``` 如果有其他文本或不同的需求,请随时告诉我!

import os
from langchain_experimental.graph_transformers import LLMGraphTransformer
from langchain_google_vertexai import VertexAI
import networkx as nx
from langchain.chains import GraphQAChain
from langchain_core.documents import Document
from langchain_community.graphs.networkx_graph import NetworkxEntityGraph

llm = VertexAI(max_output_tokens=4000,model_name='text-bison-32k')

text = """
Marie Curie, born in 1867, was a Polish and naturalised-French physicist and chemist who conducted pioneering research on radioactivity.
She was the first woman to win a Nobel Prize, the first person to win a Nobel Prize twice, and the only person to win a Nobel Prize in two scientific fields.
Her husband, Pierre Curie, was a co-winner of her first Nobel Prize, making them the first-ever married couple to win the Nobel Prize and launching the Curie family legacy of five Nobel Prizes.
She was, in 1906, the first woman to become a professor at the University of Paris.
"""

Certainly! Here's the translated text in Simplified Chinese while keeping the HTML structure: ```html 3. 接下来,我们需要将这些文本加载为 GraphDocuments,并使用已加载的 LLM 创建一个 GraphTransformer 对象。 ``` Feel free to let me know if you need any more translations or modifications!

documents = [Document(page_content=text)]
llm_transformer = LLMGraphTransformer(llm=llm)
graph_documents = llm_transformer.convert_to_graph_documents(documents)

Sure, here's the translated text in simplified Chinese while keeping the HTML structure intact: ```html

4. 是时候创建知识图谱了。为此,最好提供一个您希望提取的实体和关系列表,否则LLM可能会将一切都识别为实体或关系。

``` This HTML snippet retains the structure and translates the English text to simplified Chinese accurately.
llm_transformer_filtered = LLMGraphTransformer(
llm=llm,
allowed_nodes=["Person", "Country", "Organization"],
allowed_relationships=["NATIONALITY", "LOCATED_IN", "WORKED_AT", "SPOUSE"],
)
graph_documents_filtered = llm_transformer_filtered.convert_to_graph_documents(
documents
)

Sure, here's the HTML structure with the translated text in simplified Chinese: ```html

正如你可能已经猜到的那样,上述片段创建了

``` This HTML code will display the translated text "正如你可能已经猜到的那样,上述片段创建了" in a paragraph (`

`) element.

Certainly! Here's how you could structure your HTML while displaying the text in simplified Chinese: ```html

Translate Text to Chinese

Node = “Person”, “Country”, “Organization”

节点 = “个人”, “国家”, “组织”

``` In the above HTML: - The language is set to simplified Chinese (`lang="zh-CN"`). - The text "Node = “Person”, “Country”, “Organization”" is translated into simplified Chinese as "节点 = “个人”, “国家”, “组织”". - Each paragraph `

` contains the original English text and its corresponding Chinese translation.

Sure, here's how you could structure the HTML while incorporating the translation: ```html

Translate English to Chinese

Translate English to Chinese

关系 = ["国籍", "位于", "工作于", "配偶"]

``` In this HTML structure: - `` specifies the language of the document as Simplified Chinese. - The `` tag ensures proper encoding for Chinese characters. - The translated text is placed within a `

` tag for paragraph content. This HTML structure keeps the document valid while presenting the translated content clearly.

Sure, here is the translated text in simplified Chinese while maintaining the HTML structure: ```html

注意:任何其他可能的节点或关系将被丢弃。如果不确定,您可以将LLM对象粘贴过来,让LLM决定。

``` This HTML snippet contains the translated text: ```html

注意:任何其他可能的节点或关系将被丢弃。如果不确定,您可以将LLM对象粘贴过来,让LLM决定。

```

graph = NetworkxEntityGraph()

# Add nodes to the graph
for node in graph_documents_filtered[0].nodes:
graph.add_node(node.id)

# Add edges to the graph
for edge in graph_documents_filtered[0].relationships:
graph._graph.add_edge(
edge.source.id,
edge.target.id,
relation=edge.type,
)

Sure, here's the translated text in simplified Chinese, keeping the HTML structure intact: ```html 6. 现在让我们创建一个GraphQAChain,这将帮助我们与知识库进行交互。 ```

chain = GraphQAChain.from_llm(
llm=llm,
graph=graph,
verbose=True
)

Sure, here's how you could structure that in HTML with the translation: ```html

7. 使用您的查询调用链对象。

``` This HTML snippet keeps the structure while incorporating the translated text into simplified Chinese.
question = """Who is Marie Curie?"""
chain.run(question)

Sure, here's how you would write "Output" in simplified Chinese within an HTML structure: ```html 输出 ``` In Chinese, "Output" is typically translated as "输出" (pronounced "shūchū"). The `` tag is used here to maintain the HTML structure, enclosing the Chinese text for styling or other purposes.

Sure, here's how you could structure that in HTML while keeping the translation in simplified Chinese: ```html

我们甚至可以使用GraphIndexCreator来实现GraphRAG。

``` This HTML snippet embeds the Chinese translation within a paragraph (`

`) tag, preserving the original structure.

Sure, here's the translation of "2. GraphIndexCreator" into simplified Chinese while keeping the HTML structure: ```html 2. 图索引创建器 ``` In this HTML snippet: - `` is used to indicate that the text inside is in simplified Chinese. - `图索引创建器` is the translation of "GraphIndexCreator".

Sure, here's the translation of the phrase "Another approach is to use GraphIndexCreator in LangChain which is very similar to the above approach" in simplified Chinese while keeping the HTML structure: ```html 另一种方法是在LangChain中使用GraphIndexCreator,这与上述方法非常相似。 ``` This translation maintains the structure of the sentence within an HTML context.

from langchain.indexes import GraphIndexCreator
from langchain.chains import GraphQAChain

index_creator = GraphIndexCreator(llm=llm)

with open("/home/cdsw/sample.txt") as f:
all_text = f.read()

text = "\n".join(all_text.split("\n\n"))
graph = index_creator.from_text(text)

chain = GraphQAChain.from_llm(llm, graph=graph, verbose=True)
chain.run("What did Pierre Curie won?")

Certainly! Here's the translation of "As must have understood" into simplified Chinese while keeping the HTML structure intact: ```html 必须已经理解 ```

Certainly! Here's how you can write "Reads text from a .txt file" in simplified Chinese, keeping the HTML structure intact: ```html 读取 .txt 文件中的文本 ``` In this HTML snippet, the Chinese text "读取 .txt 文件中的文本" replaces the original English phrase while maintaining the structure around it.

Certainly! Here's the translation of "Creates graph using the index creator" in simplified Chinese, while keeping the HTML structure: ```html 使用索引创建器创建图表 ```

```html 在图上运行与上述方法类似的 GraphQA 链 ```

Sure, here's how you would write "Output" in simplified Chinese within an HTML structure: ```html 输出 ``` In this example, `` is used to denote inline text, and "输出" directly translates to "Output" in simplified Chinese.

> Entering new GraphQAChain chain...

Entities Extracted:
Pierre Curie
Full Context:
Pierre Curie was a co-winner of Marie Curie's first Nobel Prize

> Finished chain.
' Pierre Curie won the Nobel Prize in Physics in 1903, together with his wife Marie Curie and Henri Becquerel, for their research on radioactivity.'

Sure, here is the HTML structure with the translated text in simplified Chinese: ```html

在我的实验中,LLMGraphTransformer 方法在响应方面看起来比 GraphIndexCreator 更好,但两者都很容易实现。请记住,这些示例使用的是非常小的数据集。如果你正在使用大型数据集和付费 API,请小心,因为知识图谱的创建可能会导致大量的请求,给你带来昂贵的费用。

``` This HTML structure includes a paragraph (`

`) tag to contain the translated text.

Sure, here's the translated text in simplified Chinese while keeping the HTML structure: ```html 现在就到这里吧。很快再见! ``` This HTML snippet translates to "With this, it’s a wrap. See you soon!"

2024-07-18 04:17:50 AI中文站翻译自原文