-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
94 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import os | ||
|
||
from lightrag import LightRAG, QueryParam | ||
from lightrag.llm import ollama_model_complete, ollama_embedding | ||
from lightrag.utils import EmbeddingFunc | ||
|
||
WORKING_DIR = "./dickens" | ||
|
||
if not os.path.exists(WORKING_DIR): | ||
os.mkdir(WORKING_DIR) | ||
|
||
rag = LightRAG( | ||
working_dir=WORKING_DIR, | ||
llm_model_func=ollama_model_complete, | ||
llm_model_name='your_model_name', | ||
embedding_func=EmbeddingFunc( | ||
embedding_dim=768, | ||
max_token_size=8192, | ||
func=lambda texts: ollama_embedding( | ||
texts, | ||
embed_model="nomic-embed-text" | ||
) | ||
), | ||
) | ||
|
||
|
||
with open("./book.txt") as f: | ||
rag.insert(f.read()) | ||
|
||
# Perform naive search | ||
print(rag.query("What are the top themes in this story?", param=QueryParam(mode="naive"))) | ||
|
||
# Perform local search | ||
print(rag.query("What are the top themes in this story?", param=QueryParam(mode="local"))) | ||
|
||
# Perform global search | ||
print(rag.query("What are the top themes in this story?", param=QueryParam(mode="global"))) | ||
|
||
# Perform hybrid search | ||
print(rag.query("What are the top themes in this story?", param=QueryParam(mode="hybrid"))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
from .lightrag import LightRAG, QueryParam | ||
|
||
__version__ = "0.0.5" | ||
__version__ = "0.0.6" | ||
__author__ = "Zirui Guo" | ||
__url__ = "https://github.com/HKUDS/LightRAG" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,6 @@ nano-vectordb | |
hnswlib | ||
xxhash | ||
tenacity | ||
transformers | ||
torch | ||
ollama |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters