Skip to content

Commit

Permalink
Merge branch 'project-BasicRAG' into project-RAG-GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
arjbingly committed Mar 25, 2024
2 parents 58be4d8 + ee884c7 commit 47b6e44
Show file tree
Hide file tree
Showing 30 changed files with 1,822 additions and 271 deletions.
661 changes: 661 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions llm_quantize/quantize.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import subprocess
import sys
import os


def execute_commands(model_dir_path, quantization=None):
Expand All @@ -13,7 +13,7 @@ def execute_commands(model_dir_path, quantization=None):
if quantization:
model_file = f"llama.cpp/models/{model_dir_path}/ggml-model-f16.gguf"
quantized_model_file = f"llama.cpp/models/{model_dir_path.split('/')[-1]}/ggml-model-{quantization}.gguf"
subprocess.run(["llama.cpp/llm_quantize", model_file, quantized_model_file, quantization], check=True)
subprocess.run(["llama.cpp/quantize", model_file, quantized_model_file, quantization], check=True)

else:
print("llama.cpp doesn't exist, check readme how to clone.")
Expand Down
2 changes: 1 addition & 1 deletion projects/Basic-RAG/BasciRAG_CustomPrompt.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from grag.components.prompt import Prompt
from grag.rag.basic_rag import BasicRAG
from grap.components.prompt import Prompt

custom_prompt = Prompt(
input_keys={"context", "question"},
Expand Down
87 changes: 0 additions & 87 deletions projects/Basic-RAG/BasicRAG-ingest_data.py

This file was deleted.

2 changes: 1 addition & 1 deletion projects/Basic-RAG/BasicRAG_FewShotPrompt.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from grag.components.prompt import FewShotPrompt
from grag.rag.basic_rag import BasicRAG
from grap.components.prompt import FewShotPrompt

custom_few_shot_prompt = FewShotPrompt(
input_keys={"context", "question"},
Expand Down
14 changes: 14 additions & 0 deletions projects/Basic-RAG/BasicRAG_ingest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from pathlib import Path

from grag.components.multivec_retriever import Retriever
from grag.components.vectordb.deeplake_client import DeepLakeClient

# from grag.rag.basic_rag import BasicRAG

client = DeepLakeClient(collection_name="test")
retriever = Retriever(vectordb=client)

dir_path = Path(__file__).parent / 'some_dir'

retriever.ingest(dir_path)
# rag = BasicRAG(doc_chain="refine")
6 changes: 5 additions & 1 deletion projects/Basic-RAG/BasicRAG_refine.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
from grag.grag.rag import BasicRAG
from grag.components.multivec_retriever import Retriever
from grag.components.vectordb.deeplake_client import DeepLakeClient
from grag.rag.basic_rag import BasicRAG

client = DeepLakeClient(collection_name="test")
retriever = Retriever(vectordb=client)
rag = BasicRAG(doc_chain="refine")

if __name__ == "__main__":
Expand Down
8 changes: 6 additions & 2 deletions projects/Basic-RAG/BasicRAG_stuff.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from grag.grag.rag import BasicRAG
from grag.components.multivec_retriever import Retriever
from grag.components.vectordb.deeplake_client import DeepLakeClient
from grag.rag.basic_rag import BasicRAG

rag = BasicRAG(doc_chain="stuff")
client = DeepLakeClient(collection_name="test")
retriever = Retriever(vectordb=client)
rag = BasicRAG(doc_chain="stuff", retriever=retriever)

if __name__ == "__main__":
while True:
Expand Down
42 changes: 0 additions & 42 deletions projects/Basic-RAG/BasicRAG_v1_depricated.py

This file was deleted.

52 changes: 0 additions & 52 deletions projects/Basic-RAG/BasicRAG_v2_depricated.py

This file was deleted.

14 changes: 7 additions & 7 deletions projects/Retriver-GUI/retriever_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def render_search_results(self):
st.write(result.metadata)

def check_connection(self):
response = self.app.retriever.client.test_connection()
response = self.app.retriever.vectordb.test_connection()
if response:
return True
else:
Expand All @@ -55,14 +55,14 @@ def check_connection(self):
def render_stats(self):
st.write(f'''
**Chroma Client Details:** \n
Host Address : {self.app.retriever.client.host}:{self.app.retriever.client.port} \n
Collection Name : {self.app.retriever.client.collection_name} \n
Embeddings Type : {self.app.retriever.client.embedding_type} \n
Embeddings Model: {self.app.retriever.client.embedding_model} \n
Number of docs : {self.app.retriever.client.collection.count()} \n
Host Address : {self.app.retriever.vectordb.host}:{self.app.retriever.vectordb.port} \n
Collection Name : {self.app.retriever.vectordb.collection_name} \n
Embeddings Type : {self.app.retriever.vectordb.embedding_type} \n
Embeddings Model: {self.app.retriever.vectordb.embedding_model} \n
Number of docs : {self.app.retriever.vectordb.collection.count()} \n
''')
if st.button('Check Connection'):
response = self.app.retriever.client.test_connection()
response = self.app.retriever.vectordb.test_connection()
if response:
st.write(':green[Connection Active]')
else:
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ dependencies = [
"huggingface_hub>=0.20.2",
"pydantic>=2.5.0",
"rouge-score>=0.1.2",
"deeplake>=3.8.27"
]

[project.urls]
Expand Down
11 changes: 10 additions & 1 deletion src/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ n_gpu_layers_cpp : -1
std_out : True
base_dir : ${root:root_path}/models

[deeplake]
collection_name : arxiv
embedding_type : instructor-embedding
embedding_model : hkunlp/instructor-xl
store_path : ${data:data_path}/vectordb

[chroma]
host : localhost
port : 8000
Expand Down Expand Up @@ -59,4 +65,7 @@ table_as_html : True
data_path : ${root:root_path}/data

[root]
root_path : /home/ubuntu/CapStone/Capstone_5
root_path : /home/ubuntu/volume_2k/Capstone_5

[quantize]
llama_cpp_path : ${root:root_path}
Loading

0 comments on commit 47b6e44

Please sign in to comment.