mirror of
https://github.com/microsoft/graphrag.git
synced 2026-02-06 19:22:35 +08:00
Deploying to gh-pages from @ microsoft/graphrag@60a197fbd1 🚀
This commit is contained in:
parent
31786563e3
commit
7b767f8035
Binary file not shown.
@ -217,6 +217,9 @@ a {
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="/posts/config/init">Init command</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/posts/config/env_vars">Using Env Vars</a>
|
||||
</li>
|
||||
<li>
|
||||
@ -287,6 +290,7 @@ a {
|
||||
<main>
|
||||
<h1>Welcome to GraphRAG</h1>
|
||||
<p>👉 <a href="https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/">Microsoft Research Blog Post</a> <br>
|
||||
👉 <a href="https://github.com/Azure-Samples/graphrag-accelerator">GraphRAG Accelerator</a> <br>
|
||||
👉 <a href="https://github.com/microsoft/graphrag">GitHub Repository</a></p>
|
||||
<p align="center">
|
||||
<img src="img/GraphRag-Figure1.jpg" alt="Figure 1: LLM-generated knowledge graph built from a private dataset using GPT-4 Turbo." width="450" align="center">
|
||||
|
||||
@ -217,6 +217,9 @@ a {
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="/posts/config/init">Init command</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/posts/config/env_vars">Using Env Vars</a>
|
||||
</li>
|
||||
<li>
|
||||
|
||||
@ -217,6 +217,9 @@ a {
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="/posts/config/init">Init command</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/posts/config/env_vars">Using Env Vars</a>
|
||||
</li>
|
||||
<li>
|
||||
|
||||
344
posts/config/init/index.html
Normal file
344
posts/config/init/index.html
Normal file
@ -0,0 +1,344 @@
|
||||
|
||||
|
||||
|
||||
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Configuring GraphRAG Indexing</title>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.4/css/bulma.min.css">
|
||||
<link href="https://unpkg.com/prismjs@1.20.0/themes/prism-okaidia.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Primer/19.1.1/tooltips.min.css" crossorigin="anonymous" referrerpolicy="no-referrer">
|
||||
<style>
|
||||
html {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
body{
|
||||
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
footer{
|
||||
width: 100%;
|
||||
height: 32px;
|
||||
font-size: 12px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
gap: 18px;
|
||||
align-items: center;
|
||||
color: #5d5d5d;
|
||||
background: #e9eaeb;
|
||||
border-top: 1px solid #c4c5c6;
|
||||
}
|
||||
|
||||
#cookiesManager{
|
||||
cursor: pointer;
|
||||
color: #485fc7;
|
||||
}
|
||||
|
||||
.page-content {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
overflow: scroll;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
header {
|
||||
background-color: lightgrey;
|
||||
height: 2%;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
nav {
|
||||
padding: 1em;
|
||||
min-width: 200px;
|
||||
}
|
||||
|
||||
main {
|
||||
flex: 1;
|
||||
padding: 0 5em 0 5em;
|
||||
}
|
||||
|
||||
.logotitle {
|
||||
font-size: 1.5em;
|
||||
font-weight: bold;
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
.number {
|
||||
all: unset;
|
||||
}
|
||||
|
||||
.tag.token {
|
||||
all: unset;
|
||||
}
|
||||
|
||||
main ul {
|
||||
list-style-type: disc;
|
||||
padding-left: 30px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 2rem;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 1.5rem;
|
||||
margin-top: 10px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 1rem;
|
||||
margin-top: 10px;
|
||||
font-weight: 500;
|
||||
}
|
||||
p {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
/* Accessibility styling */
|
||||
|
||||
a {
|
||||
color: #485fc7;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.menu-list a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
|
||||
.token.comment, .token.prolog, .token.doctype, .token.cdata {
|
||||
color: #8093a5;
|
||||
}
|
||||
|
||||
.token.property, .token.tag, .token.constant, .token.symbol, .token.deleted {
|
||||
color: #ff36ab;
|
||||
}
|
||||
</style>
|
||||
<script type="module" async="">import mermaid from "https://unpkg.com/mermaid@10/dist/mermaid.esm.min.mjs";document.addEventListener('DOMContentLoaded', mermaid.initialize({"loadOnSave":true}));</script>
|
||||
<script>function showTooltip(o,e){o.trigger.className.includes("tooltipped")||(o.trigger.children[0].className="tooltipped tooltipped-s",o.trigger.children[0].ariaLabel=e)}window.addEventListener("load",()=>{var o=new ClipboardJS(".code-copy");o.on("success",o=>showTooltip(o,"Copied!")),o.on("error",o=>showTooltip(o,"Failed..."))});</script>
|
||||
<script async="" src="https://cdn.jsdelivr.net/npm/clipboard@2.0.11/dist/clipboard.min.js"></script>
|
||||
|
||||
|
||||
<script src="https://wcpstatic.microsoft.com/mscc/lib/v2/wcp-consent.js" type="text/javascript"></script>
|
||||
<script>
|
||||
function onConsentChanged(categoryPreferences) {
|
||||
console.log("onConsentChanged", categoryPreferences);
|
||||
}
|
||||
|
||||
var siteConsent
|
||||
|
||||
function initialize(){
|
||||
var currentYear = new Date().getFullYear()
|
||||
document.getElementById("copyright").innerHTML = `©️ ${currentYear} Microsoft`;
|
||||
window.WcpConsent && WcpConsent.init("en-US", "cookie-banner", function (err, _siteConsent) {
|
||||
if (!err) {
|
||||
siteConsent = _siteConsent; //siteConsent is used to get the current consent
|
||||
} else {
|
||||
console.log("Error initializing WcpConsent: "+ err);
|
||||
}
|
||||
}, onConsentChanged, WcpConsent.themes.light);
|
||||
}
|
||||
|
||||
addEventListener("DOMContentLoaded", initialize)
|
||||
addEventListener("DOMContentLoaded", checkCookieManager)
|
||||
|
||||
function checkCookieManager(){
|
||||
if(siteConsent.isConsentRequired){
|
||||
document.getElementById("cookiesManager").style.display = 'block';
|
||||
document.getElementById("divider").style.display = 'block';
|
||||
}
|
||||
else{
|
||||
document.getElementById("cookiesManager").style.display = 'none';
|
||||
document.getElementById("divider").style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
function manageConsent() {
|
||||
if(siteConsent.isConsentRequired){
|
||||
siteConsent.manageConsent();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<div id="cookie-banner"></div>
|
||||
<a href="/"><span class="logotitle">GraphRAG</span></a>
|
||||
</header>
|
||||
<div class="page-content">
|
||||
<!-- Sidebar -->
|
||||
<aside class="menu">
|
||||
<ul class="menu-list">
|
||||
<li>
|
||||
|
||||
<a href="/">Welcome</a>
|
||||
|
||||
</li>
|
||||
|
||||
<!-- Get Started Links -->
|
||||
<li>
|
||||
|
||||
<a href="/posts/get_started/">Get Started</a>
|
||||
|
||||
|
||||
<a href="/posts/developing/">Developing</a>
|
||||
|
||||
</li>
|
||||
|
||||
<!-- Indexing Links -->
|
||||
<li>
|
||||
|
||||
<a href="/posts/index/overview/">Indexing</a>
|
||||
|
||||
<ul><li>
|
||||
<a href="/posts/index/0-architecture/">Architecture</a>
|
||||
</li><li>
|
||||
<a href="/posts/index/1-default_dataflow/">Dataflow</a>
|
||||
</li><li>
|
||||
<a href="/posts/index/2-cli/">CLI</a>
|
||||
</li><li>
|
||||
|
||||
<a href="/posts/config/overview/">Configuration</a>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="/posts/config/init">Init command</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/posts/config/env_vars">Using Env Vars</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/posts/config/json_yaml">Using JSON or YAML</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/posts/config/custom">Fully Custom</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/posts/config/template">Template</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
|
||||
<a href="/posts/prompt_tuning/overview/">Prompt Tuning</a>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
<a href="/posts/prompt_tuning/auto_prompt_tuning/">Automatic Templating</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
|
||||
<a href="/posts/prompt_tuning/manual_prompt_tuning/">Manual Prompt Tuning</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
|
||||
<!-- Query Links -->
|
||||
<li>
|
||||
|
||||
<a href="/posts/query/overview/">Query</a>
|
||||
|
||||
<ul><li>
|
||||
<a href="/posts/query/1-local_search/">Local Search</a>
|
||||
</li><li>
|
||||
<a href="/posts/query/2-question_generation/">Question Generation</a>
|
||||
</li><li>
|
||||
<a href="/posts/query/0-global_search/">Global Search</a>
|
||||
</li><li>
|
||||
<a href="/posts/query/3-cli/">CLI</a>
|
||||
</li><li>
|
||||
|
||||
<a href="/posts/query/notebooks/overview/">Notebooks</a>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="/posts/query/notebooks/global_search_nb">Global Search</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/posts/query/notebooks/local_search_nb">Local Search</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</aside>
|
||||
|
||||
<!-- Main Content -->
|
||||
<main>
|
||||
<h1>Configuring GraphRAG Indexing</h1>
|
||||
<p>To start using GraphRAG, you need to configure the system. The <code>init</code> command is the easiest way to get started. It will create a <code>.env</code> and <code>settings.yaml</code> files in the specified directory with the necessary configuration settings. It will also output the default LLM prompts used by GraphRAG.</p>
|
||||
<h2>Usage</h2>
|
||||
|
||||
<div style="position: relative">
|
||||
<pre class="language-sh"><code id="code-6" class="language-sh">python <span class="token parameter variable">-m</span> graphrag.index <span class="token punctuation">[</span>--init<span class="token punctuation">]</span> <span class="token punctuation">[</span>--root <span class="token environment constant">PATH</span><span class="token punctuation">]</span></code></pre>
|
||||
|
||||
<button class="code-copy " data-clipboard-target="#code-6" style="position: absolute; top: 7.5px; right: 6px; padding-top: 3px; cursor: pointer; outline: none; opacity: 0.8;" title="Copy">
|
||||
<span style="display:inline-block;background:url(https://api.iconify.design/mdi/content-copy.svg) no-repeat center center / contain;width: 16px; height: 16px;" class=""></span>
|
||||
</button>
|
||||
</div>
|
||||
<h2>Options</h2>
|
||||
<ul>
|
||||
<li><code>--init</code> - Initialize the directory with the necessary configuration files.</li>
|
||||
<li><code>--root PATH</code> - The root directory to initialize. Default is the current directory.</li>
|
||||
</ul>
|
||||
<h2>Example</h2>
|
||||
|
||||
<div style="position: relative">
|
||||
<pre class="language-sh"><code id="code-25" class="language-sh">python <span class="token parameter variable">-m</span> graphrag.index <span class="token parameter variable">--init</span> <span class="token parameter variable">--root</span> ./ragtest</code></pre>
|
||||
|
||||
<button class="code-copy " data-clipboard-target="#code-25" style="position: absolute; top: 7.5px; right: 6px; padding-top: 3px; cursor: pointer; outline: none; opacity: 0.8;" title="Copy">
|
||||
<span style="display:inline-block;background:url(https://api.iconify.design/mdi/content-copy.svg) no-repeat center center / contain;width: 16px; height: 16px;" class=""></span>
|
||||
</button>
|
||||
</div>
|
||||
<h2>Output</h2>
|
||||
<p>The <code>init</code> command will create the following files in the specified directory:</p>
|
||||
<ul>
|
||||
<li><code>settings.yaml</code> - The configuration settings file. This file contains the configuration settings for GraphRAG.</li>
|
||||
<li><code>.env</code> - The environment variables file. These are referenced in the <code>settings.yaml</code> file.</li>
|
||||
<li><code>prompts/</code> - The LLM prompts folder. This contains the default prompts used by GraphRAG, you can modify them or run the <a href="/posts/prompt_tuning/auto_prompt_tuning">Auto Prompt Tuning</a> command to generate new prompts adapted to your data.</li>
|
||||
</ul>
|
||||
<h2>Next Steps</h2>
|
||||
<p>After initializing your workspace, you can either run the <a href="/posts/prompt_tuning/auto_prompt_tuning">Prompt Tuning</a> command to adapt the prompts to your data or even start running the <a href="/posts/index/overview">Indexing Pipeline</a> to index your data. For more information on configuring GraphRAG, see the <a href="/posts/config/overview">Configuration</a> documentation.</p>
|
||||
|
||||
</main>
|
||||
</div>
|
||||
<footer>
|
||||
<a href="https://go.microsoft.com/fwlink/?LinkId=521839">Privacy</a>
|
||||
|
|
||||
<a href="https://go.microsoft.com/fwlink/?LinkId=2259814">Consumer Health Privacy</a>
|
||||
|
|
||||
<span id="cookiesManager" onClick="manageConsent();">Cookies</span>
|
||||
<span id="divider">|</span>
|
||||
<a href="https://go.microsoft.com/fwlink/?LinkID=206977">Terms of Use</a>
|
||||
|
|
||||
<a href="https://www.microsoft.com/trademarks">Trademarks</a>
|
||||
|
|
||||
<a href="https://www.microsoft.com" id="copyright"></a>
|
||||
|
|
||||
<a href="https://github.com/microsoft/graphrag">GitHub</a>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
@ -217,6 +217,9 @@ a {
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="/posts/config/init">Init command</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/posts/config/env_vars">Using Env Vars</a>
|
||||
</li>
|
||||
<li>
|
||||
|
||||
@ -217,6 +217,9 @@ a {
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="/posts/config/init">Init command</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/posts/config/env_vars">Using Env Vars</a>
|
||||
</li>
|
||||
<li>
|
||||
@ -290,6 +293,7 @@ a {
|
||||
<h2>Default Configuration Mode</h2>
|
||||
<p>The default configuration mode is the simplest way to get started with the GraphRAG system. It is designed to work out-of-the-box with minimal configuration. The primary configuration sections for the Indexing Engine pipelines are described below. The main ways to set up GraphRAG in Default Configuration mode are via:</p>
|
||||
<ul>
|
||||
<li><a href="/posts/config/init">Init command</a> (recommended)</li>
|
||||
<li><a href="/posts/config/env_vars">Purely using environment variables</a></li>
|
||||
<li><a href="/posts/config/json_yaml">Using JSON or YAML for deeper control</a></li>
|
||||
</ul>
|
||||
|
||||
@ -217,6 +217,9 @@ a {
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="/posts/config/init">Init command</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/posts/config/env_vars">Using Env Vars</a>
|
||||
</li>
|
||||
<li>
|
||||
|
||||
@ -217,6 +217,9 @@ a {
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="/posts/config/init">Init command</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/posts/config/env_vars">Using Env Vars</a>
|
||||
</li>
|
||||
<li>
|
||||
|
||||
@ -217,6 +217,9 @@ a {
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="/posts/config/init">Init command</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/posts/config/env_vars">Using Env Vars</a>
|
||||
</li>
|
||||
<li>
|
||||
@ -289,7 +292,8 @@ a {
|
||||
<h2>Requirements</h2>
|
||||
<p><a href="https://www.python.org/downloads/">Python 3.10-3.12</a></p>
|
||||
<p>To get started with the GraphRAG system, you have a few options:</p>
|
||||
<p>👉 <a href="https://pypi.org/project/graphrag/">Install from pypi</a>. <br>
|
||||
<p>👉 <a href="https://github.com/Azure-Samples/graphrag-accelerator">Use the GraphRAG Accelerator solution</a> <br>
|
||||
👉 <a href="https://pypi.org/project/graphrag/">Install from pypi</a>. <br>
|
||||
👉 <a href="/posts/developing">Use it from source</a><br></p>
|
||||
<h1>Top-Level Packages</h1>
|
||||
<p><a href="/posts/index/overview">Indexing Pipeline Overview</a><br>
|
||||
@ -307,7 +311,7 @@ It shows how to use the system to index some text, and then use the indexed data
|
||||
</button>
|
||||
</div>
|
||||
<h1>Running the Indexer</h1>
|
||||
<p>Now we need to set up a data project and some initial configuration. Let's set that up. We're using the <a href="/posts/config/overview/">default configuration mode</a>, which you can customize as needed using <a href="/posts/config/env_vars/">environment variables</a> or using a <a href="/posts/config/json_yaml/">config file</a>.</p>
|
||||
<p>Now we need to set up a data project and some initial configuration. Let's set that up. We're using the <a href="/posts/config/overview/">default configuration mode</a>, which you can customize as needed using a <a href="/posts/config/json_yaml/">config file</a>, which we recommend, or <a href="/posts/config/env_vars/">environment variables</a>.</p>
|
||||
<p>First let's get a sample dataset ready:</p>
|
||||
|
||||
<div style="position: relative">
|
||||
@ -327,51 +331,52 @@ It shows how to use the system to index some text, and then use the indexed data
|
||||
</button>
|
||||
</div>
|
||||
<p>Next we'll inject some required config variables:</p>
|
||||
<h2>Set Up Environment Variables</h2>
|
||||
<p>First let's make sure to setup the required environment variables. For details on these environment variables, and what environment variables are available, see the <a href="/posts/config/env_vars/">environment variables documentation</a>.</p>
|
||||
<h2>Set Up Your Workspace Variables</h2>
|
||||
<p>First let's make sure to setup the required environment variables. For details on these environment variables, and what environment variables are available, see the <a href="/posts/config/overview/">variables documentation</a>.</p>
|
||||
<p>To initialize your workspace, let's first run the <code>graphrag.index --init</code> command.
|
||||
Since we have already configured a directory named .ragtest` in the previous step, we can run the following command:</p>
|
||||
|
||||
<div style="position: relative">
|
||||
<pre class="language-sh"><code id="code-54" class="language-sh">python <span class="token parameter variable">-m</span> graphrag.index <span class="token parameter variable">--init</span> <span class="token parameter variable">--root</span> ./ragtest</code></pre>
|
||||
|
||||
<button class="code-copy " data-clipboard-target="#code-54" style="position: absolute; top: 7.5px; right: 6px; padding-top: 3px; cursor: pointer; outline: none; opacity: 0.8;" title="Copy">
|
||||
<span style="display:inline-block;background:url(https://api.iconify.design/mdi/content-copy.svg) no-repeat center center / contain;width: 16px; height: 16px;" class=""></span>
|
||||
</button>
|
||||
</div>
|
||||
<p>This will create two files: <code>.env</code> and <code>settings.yaml</code> in the <code>./ragtest</code> directory.</p>
|
||||
<ul>
|
||||
<li><code>.env</code> contains the environment variables required to run the GraphRAG pipeline. If you inspect the file, you'll see a single environment variable defined,
|
||||
<code>GRAPHRAG_API_KEY=<API_KEY></code>. This is the API key for the OpenAI API or Azure OpenAI endpoint. You can replace this with your own API key.</li>
|
||||
<li><code>settings.yaml</code> contains the settings for the pipeline. You can modify this file to change the settings for the pipeline.
|
||||
<br></li>
|
||||
</ul>
|
||||
<h4><ins>OpenAI and Azure OpenAI</ins></h4>
|
||||
<p>Let's set the base environment variables.</p>
|
||||
|
||||
<div style="position: relative">
|
||||
<pre class="language-sh"><code id="code-57" class="language-sh"><span class="token builtin class-name">export</span> <span class="token assign-left variable">GRAPHRAG_API_KEY</span><span class="token operator">=</span><span class="token string">"<api_key>"</span> <span class="token operator">&&</span> <span class="token punctuation">\</span>
|
||||
<span class="token builtin class-name">export</span> <span class="token assign-left variable">GRAPHRAG_INPUT_TYPE</span><span class="token operator">=</span><span class="token string">"text"</span>
|
||||
|
||||
<span class="token comment"># Recommended, but not required. </span>
|
||||
<span class="token comment"># JSON output mode is only available with some completion models.</span>
|
||||
<span class="token comment"># export GRAPHRAG_LLM_MODEL_SUPPORTS_JSON="True"</span>
|
||||
|
||||
<span class="token comment"># You may use these env vars to specify which model to use.</span>
|
||||
<span class="token comment"># export GRAPHRAG_LLM_MODEL="<chat_completions_model>"</span>
|
||||
<span class="token comment"># export GRAPHRAG_EMBEDDING_MODEL="<embeddings_model>"</span></code></pre>
|
||||
|
||||
<button class="code-copy " data-clipboard-target="#code-57" style="position: absolute; top: 7.5px; right: 6px; padding-top: 3px; cursor: pointer; outline: none; opacity: 0.8;" title="Copy">
|
||||
<span style="display:inline-block;background:url(https://api.iconify.design/mdi/content-copy.svg) no-repeat center center / contain;width: 16px; height: 16px;" class=""></span>
|
||||
</button>
|
||||
</div>
|
||||
<p>To run in OpenAI mode, just make sure to update the value of <code>GRAPHRAG_API_KEY</code> in the <code>.env</code> file with your OpenAI API key.</p>
|
||||
<h4><ins>Azure OpenAI</ins></h4>
|
||||
<p>In addition, Azure OpenAI users should set the following env-vars.</p>
|
||||
<p>In addition, Azure OpenAI users should set the following variables in the settings.yaml file. To find the appropriate sections, just search for the <code>llm:</code> configuration, you should see two sections, one for the chat endpoint and one for the embeddings endpoint. Here is an example of how to configure the chat endpoint:</p>
|
||||
|
||||
<div style="position: relative">
|
||||
<pre class="language-sh"><code id="code-64" class="language-sh"><span class="token builtin class-name">export</span> <span class="token assign-left variable">GRAPHRAG_API_BASE</span><span class="token operator">=</span><span class="token string">"https://<domain>.openai.azure.com"</span> <span class="token operator">&&</span> <span class="token punctuation">\</span>
|
||||
<span class="token builtin class-name">export</span> <span class="token assign-left variable">GRAPHRAG_API_VERSION</span><span class="token operator">=</span><span class="token string">"2024-02-15-preview"</span> <span class="token operator">&&</span> <span class="token punctuation">\</span>
|
||||
<span class="token builtin class-name">export</span> GRAPHRAG_LLM_TYPE <span class="token operator">=</span> <span class="token string">"azure_openai_chat"</span> <span class="token operator">&&</span> <span class="token punctuation">\</span>
|
||||
<span class="token builtin class-name">export</span> <span class="token assign-left variable">GRAPHRAG_LLM_DEPLOYMENT_NAME</span><span class="token operator">=</span><span class="token string">"<chat_completions_deployment_name>"</span> <span class="token operator">&&</span> <span class="token punctuation">\</span>
|
||||
<span class="token builtin class-name">export</span> GRAPHRAG_EMBEDDING_API_TYPE <span class="token operator">=</span> <span class="token string">"azure_openai_embedding"</span> <span class="token operator">&&</span> <span class="token punctuation">\</span>
|
||||
<span class="token builtin class-name">export</span> <span class="token assign-left variable">GRAPHRAG_EMBEDDING_DEPLOYMENT_NAME</span><span class="token operator">=</span><span class="token string">"<embeddings_deployment_name>"</span></code></pre>
|
||||
<pre class="language-yaml"><code id="code-82" class="language-yaml"><span class="token key atrule">type</span><span class="token punctuation">:</span> azure_openai_chat <span class="token comment"># Or azure_openai_embedding for embeddings</span>
|
||||
<span class="token key atrule">api_base</span><span class="token punctuation">:</span> https<span class="token punctuation">:</span>//<instance<span class="token punctuation">></span>.openai.azure.com
|
||||
<span class="token key atrule">api_version</span><span class="token punctuation">:</span> 2024<span class="token punctuation">-</span>02<span class="token punctuation">-</span>15<span class="token punctuation">-</span>preview <span class="token comment"># You can customize this for other versions</span>
|
||||
<span class="token key atrule">deployment_name</span><span class="token punctuation">:</span> <azure_model_deployment_name<span class="token punctuation">></span></code></pre>
|
||||
|
||||
<button class="code-copy " data-clipboard-target="#code-64" style="position: absolute; top: 7.5px; right: 6px; padding-top: 3px; cursor: pointer; outline: none; opacity: 0.8;" title="Copy">
|
||||
<button class="code-copy " data-clipboard-target="#code-82" style="position: absolute; top: 7.5px; right: 6px; padding-top: 3px; cursor: pointer; outline: none; opacity: 0.8;" title="Copy">
|
||||
<span style="display:inline-block;background:url(https://api.iconify.design/mdi/content-copy.svg) no-repeat center center / contain;width: 16px; height: 16px;" class=""></span>
|
||||
</button>
|
||||
</div>
|
||||
<p>For more details about configuring GraphRAG, see the <a href="/posts/config/overview/">configuration documentation</a>.
|
||||
For more details about using the CLI, refer to the <a href="/posts/query/3-cli/">CLI documentation</a>.</p>
|
||||
<ul>
|
||||
<li>For more details about configuring GraphRAG, see the <a href="/posts/config/overview/">configuration documentation</a>.</li>
|
||||
<li>To learn more about Initialization, refer to the <a href="/posts/config/init/">Initialization documentation</a>.</li>
|
||||
<li>For more details about using the CLI, refer to the <a href="/posts/query/3-cli/">CLI documentation</a>.</li>
|
||||
</ul>
|
||||
<h2>Running the Indexing pipeline</h2>
|
||||
<p>Finally we'll run the pipeline!</p>
|
||||
|
||||
<div style="position: relative">
|
||||
<pre class="language-sh"><code id="code-74" class="language-sh">python <span class="token parameter variable">-m</span> graphrag.index <span class="token parameter variable">--root</span> ./ragtest</code></pre>
|
||||
<pre class="language-sh"><code id="code-106" class="language-sh">python <span class="token parameter variable">-m</span> graphrag.index <span class="token parameter variable">--root</span> ./ragtest</code></pre>
|
||||
|
||||
<button class="code-copy " data-clipboard-target="#code-74" style="position: absolute; top: 7.5px; right: 6px; padding-top: 3px; cursor: pointer; outline: none; opacity: 0.8;" title="Copy">
|
||||
<button class="code-copy " data-clipboard-target="#code-106" style="position: absolute; top: 7.5px; right: 6px; padding-top: 3px; cursor: pointer; outline: none; opacity: 0.8;" title="Copy">
|
||||
<span style="display:inline-block;background:url(https://api.iconify.design/mdi/content-copy.svg) no-repeat center center / contain;width: 16px; height: 16px;" class=""></span>
|
||||
</button>
|
||||
</div>
|
||||
@ -384,24 +389,24 @@ Once the pipeline is complete, you should see a new folder called <code>./ragtes
|
||||
<p>Here is an example using Global search to ask a high-level question:</p>
|
||||
|
||||
<div style="position: relative">
|
||||
<pre class="language-sh"><code id="code-93" class="language-sh">python <span class="token parameter variable">-m</span> graphrag.query <span class="token punctuation">\</span>
|
||||
<pre class="language-sh"><code id="code-125" class="language-sh">python <span class="token parameter variable">-m</span> graphrag.query <span class="token punctuation">\</span>
|
||||
<span class="token parameter variable">--root</span> ./ragtest <span class="token punctuation">\</span>
|
||||
<span class="token parameter variable">--method</span> global <span class="token punctuation">\</span>
|
||||
<span class="token string">"What are the top themes in this story?"</span></code></pre>
|
||||
|
||||
<button class="code-copy " data-clipboard-target="#code-93" style="position: absolute; top: 7.5px; right: 6px; padding-top: 3px; cursor: pointer; outline: none; opacity: 0.8;" title="Copy">
|
||||
<button class="code-copy " data-clipboard-target="#code-125" style="position: absolute; top: 7.5px; right: 6px; padding-top: 3px; cursor: pointer; outline: none; opacity: 0.8;" title="Copy">
|
||||
<span style="display:inline-block;background:url(https://api.iconify.design/mdi/content-copy.svg) no-repeat center center / contain;width: 16px; height: 16px;" class=""></span>
|
||||
</button>
|
||||
</div>
|
||||
<p>Here is an example using Local search to ask a more specific question about a particular character:</p>
|
||||
|
||||
<div style="position: relative">
|
||||
<pre class="language-sh"><code id="code-97" class="language-sh">python <span class="token parameter variable">-m</span> graphrag.query <span class="token punctuation">\</span>
|
||||
<pre class="language-sh"><code id="code-129" class="language-sh">python <span class="token parameter variable">-m</span> graphrag.query <span class="token punctuation">\</span>
|
||||
<span class="token parameter variable">--root</span> ./ragtest <span class="token punctuation">\</span>
|
||||
<span class="token parameter variable">--method</span> <span class="token builtin class-name">local</span> <span class="token punctuation">\</span>
|
||||
<span class="token string">"Who is Scrooge, and what are his main relationships?"</span></code></pre>
|
||||
|
||||
<button class="code-copy " data-clipboard-target="#code-97" style="position: absolute; top: 7.5px; right: 6px; padding-top: 3px; cursor: pointer; outline: none; opacity: 0.8;" title="Copy">
|
||||
<button class="code-copy " data-clipboard-target="#code-129" style="position: absolute; top: 7.5px; right: 6px; padding-top: 3px; cursor: pointer; outline: none; opacity: 0.8;" title="Copy">
|
||||
<span style="display:inline-block;background:url(https://api.iconify.design/mdi/content-copy.svg) no-repeat center center / contain;width: 16px; height: 16px;" class=""></span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@ -217,6 +217,9 @@ a {
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="/posts/config/init">Init command</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/posts/config/env_vars">Using Env Vars</a>
|
||||
</li>
|
||||
<li>
|
||||
|
||||
@ -217,6 +217,9 @@ a {
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="/posts/config/init">Init command</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/posts/config/env_vars">Using Env Vars</a>
|
||||
</li>
|
||||
<li>
|
||||
|
||||
@ -217,6 +217,9 @@ a {
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="/posts/config/init">Init command</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/posts/config/env_vars">Using Env Vars</a>
|
||||
</li>
|
||||
<li>
|
||||
|
||||
@ -217,6 +217,9 @@ a {
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="/posts/config/init">Init command</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/posts/config/env_vars">Using Env Vars</a>
|
||||
</li>
|
||||
<li>
|
||||
|
||||
@ -217,6 +217,9 @@ a {
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="/posts/config/init">Init command</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/posts/config/env_vars">Using Env Vars</a>
|
||||
</li>
|
||||
<li>
|
||||
@ -288,13 +291,15 @@ a {
|
||||
<h1>Prompt Tuning ⚙️</h1>
|
||||
<p>GraphRAG provides the ability to create domain adaptive templates for the generation of the knowledge graph. This step is optional, though is is highly encouraged to run it as it will yield better results when executing an Index Run.</p>
|
||||
<p>The templates are generated by loading the inputs, splitting them into chunks (text units) and then running a series of LLM invocations and template substitutions to generate the final prompts. We suggest using the default values provided by the script, but in this page you'll find the detail of each in case you want to further explore and tweak the template generation algorithm.</p>
|
||||
<h2>Prerequisites</h2>
|
||||
<p>Before running the automatic template generation make sure you have already initialized your workspace with the <code>graphrag.index --init</code> command. This will create the necessary configuration files and the default prompts. Refer to the <a href="/posts/config/init">Init Documentation</a> for more information about the initialization process.</p>
|
||||
<h2>Usage</h2>
|
||||
<p>You can run the main script from the command line with various options:</p>
|
||||
|
||||
<div style="position: relative">
|
||||
<pre class="language-bash"><code id="code-12" class="language-bash">python <span class="token parameter variable">-m</span> graphrag.prompt_tune <span class="token punctuation">[</span>--root ROOT<span class="token punctuation">]</span> <span class="token punctuation">[</span>--domain DOMAIN<span class="token punctuation">]</span> <span class="token punctuation">[</span>--method METHOD<span class="token punctuation">]</span> <span class="token punctuation">[</span>--limit LIMIT<span class="token punctuation">]</span> <span class="token punctuation">[</span>--max-tokens MAX_TOKENS<span class="token punctuation">]</span> <span class="token punctuation">[</span>--chunk-size CHUNK_SIZE<span class="token punctuation">]</span> <span class="token punctuation">[</span>--no-entity-types<span class="token punctuation">]</span> <span class="token punctuation">[</span>--output OUTPUT<span class="token punctuation">]</span></code></pre>
|
||||
<pre class="language-bash"><code id="code-18" class="language-bash">python <span class="token parameter variable">-m</span> graphrag.prompt_tune <span class="token punctuation">[</span>--root ROOT<span class="token punctuation">]</span> <span class="token punctuation">[</span>--domain DOMAIN<span class="token punctuation">]</span> <span class="token punctuation">[</span>--method METHOD<span class="token punctuation">]</span> <span class="token punctuation">[</span>--limit LIMIT<span class="token punctuation">]</span> <span class="token punctuation">[</span>--max-tokens MAX_TOKENS<span class="token punctuation">]</span> <span class="token punctuation">[</span>--chunk-size CHUNK_SIZE<span class="token punctuation">]</span> <span class="token punctuation">[</span>--no-entity-types<span class="token punctuation">]</span> <span class="token punctuation">[</span>--output OUTPUT<span class="token punctuation">]</span></code></pre>
|
||||
|
||||
<button class="code-copy " data-clipboard-target="#code-12" style="position: absolute; top: 7.5px; right: 6px; padding-top: 3px; cursor: pointer; outline: none; opacity: 0.8;" title="Copy">
|
||||
<button class="code-copy " data-clipboard-target="#code-18" style="position: absolute; top: 7.5px; right: 6px; padding-top: 3px; cursor: pointer; outline: none; opacity: 0.8;" title="Copy">
|
||||
<span style="display:inline-block;background:url(https://api.iconify.design/mdi/content-copy.svg) no-repeat center center / contain;width: 16px; height: 16px;" class=""></span>
|
||||
</button>
|
||||
</div>
|
||||
@ -328,18 +333,18 @@ a {
|
||||
<h2>Example Usage</h2>
|
||||
|
||||
<div style="position: relative">
|
||||
<pre class="language-bash"><code id="code-61" class="language-bash">python <span class="token parameter variable">-m</span> graphrag.prompt_tune <span class="token parameter variable">--root</span> /path/to/project <span class="token parameter variable">--domain</span> <span class="token string">"environmental news"</span> <span class="token parameter variable">--method</span> random <span class="token parameter variable">--limit</span> <span class="token number">10</span> --max-tokens <span class="token number">2048</span> --chunk-size <span class="token number">256</span> --no-entity-types <span class="token parameter variable">--output</span> /path/to/output</code></pre>
|
||||
<pre class="language-bash"><code id="code-67" class="language-bash">python <span class="token parameter variable">-m</span> graphrag.prompt_tune <span class="token parameter variable">--root</span> /path/to/project <span class="token parameter variable">--domain</span> <span class="token string">"environmental news"</span> <span class="token parameter variable">--method</span> random <span class="token parameter variable">--limit</span> <span class="token number">10</span> --max-tokens <span class="token number">2048</span> --chunk-size <span class="token number">256</span> --no-entity-types <span class="token parameter variable">--output</span> /path/to/output</code></pre>
|
||||
|
||||
<button class="code-copy " data-clipboard-target="#code-61" style="position: absolute; top: 7.5px; right: 6px; padding-top: 3px; cursor: pointer; outline: none; opacity: 0.8;" title="Copy">
|
||||
<button class="code-copy " data-clipboard-target="#code-67" style="position: absolute; top: 7.5px; right: 6px; padding-top: 3px; cursor: pointer; outline: none; opacity: 0.8;" title="Copy">
|
||||
<span style="display:inline-block;background:url(https://api.iconify.design/mdi/content-copy.svg) no-repeat center center / contain;width: 16px; height: 16px;" class=""></span>
|
||||
</button>
|
||||
</div>
|
||||
<p>or, with minimal configuration (suggested):</p>
|
||||
|
||||
<div style="position: relative">
|
||||
<pre class="language-bash"><code id="code-65" class="language-bash">python <span class="token parameter variable">-m</span> graphrag.prompt_tune <span class="token parameter variable">--root</span> /path/to/project --no-entity-types</code></pre>
|
||||
<pre class="language-bash"><code id="code-71" class="language-bash">python <span class="token parameter variable">-m</span> graphrag.prompt_tune <span class="token parameter variable">--root</span> /path/to/project --no-entity-types</code></pre>
|
||||
|
||||
<button class="code-copy " data-clipboard-target="#code-65" style="position: absolute; top: 7.5px; right: 6px; padding-top: 3px; cursor: pointer; outline: none; opacity: 0.8;" title="Copy">
|
||||
<button class="code-copy " data-clipboard-target="#code-71" style="position: absolute; top: 7.5px; right: 6px; padding-top: 3px; cursor: pointer; outline: none; opacity: 0.8;" title="Copy">
|
||||
<span style="display:inline-block;background:url(https://api.iconify.design/mdi/content-copy.svg) no-repeat center center / contain;width: 16px; height: 16px;" class=""></span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@ -217,6 +217,9 @@ a {
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="/posts/config/init">Init command</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/posts/config/env_vars">Using Env Vars</a>
|
||||
</li>
|
||||
<li>
|
||||
|
||||
@ -217,6 +217,9 @@ a {
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="/posts/config/init">Init command</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/posts/config/env_vars">Using Env Vars</a>
|
||||
</li>
|
||||
<li>
|
||||
|
||||
@ -217,6 +217,9 @@ a {
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="/posts/config/init">Init command</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/posts/config/env_vars">Using Env Vars</a>
|
||||
</li>
|
||||
<li>
|
||||
|
||||
@ -217,6 +217,9 @@ a {
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="/posts/config/init">Init command</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/posts/config/env_vars">Using Env Vars</a>
|
||||
</li>
|
||||
<li>
|
||||
|
||||
@ -217,6 +217,9 @@ a {
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="/posts/config/init">Init command</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/posts/config/env_vars">Using Env Vars</a>
|
||||
</li>
|
||||
<li>
|
||||
|
||||
@ -217,6 +217,9 @@ a {
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="/posts/config/init">Init command</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/posts/config/env_vars">Using Env Vars</a>
|
||||
</li>
|
||||
<li>
|
||||
|
||||
@ -217,6 +217,9 @@ a {
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="/posts/config/init">Init command</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/posts/config/env_vars">Using Env Vars</a>
|
||||
</li>
|
||||
<li>
|
||||
|
||||
@ -217,6 +217,9 @@ a {
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="/posts/config/init">Init command</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/posts/config/env_vars">Using Env Vars</a>
|
||||
</li>
|
||||
<li>
|
||||
|
||||
@ -217,6 +217,9 @@ a {
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="/posts/config/init">Init command</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/posts/config/env_vars">Using Env Vars</a>
|
||||
</li>
|
||||
<li>
|
||||
|
||||
@ -217,6 +217,9 @@ a {
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="/posts/config/init">Init command</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/posts/config/env_vars">Using Env Vars</a>
|
||||
</li>
|
||||
<li>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user