Skip to content

Commit cdfc2bb

Browse files
authored
Merge branch 'NVIDIA:main' into main
2 parents afe4e33 + d967961 commit cdfc2bb

File tree

15 files changed

+2028
-242
lines changed

15 files changed

+2028
-242
lines changed

README.md

Lines changed: 0 additions & 217 deletions
This file was deleted.

community/log_analysis_multi_agent_rag/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ This repository provides a sample code to demonstrate how you can use the log an
4848

4949
# Software Components
5050
NVIDIA NIM Microservices
51-
- NIM of meta/llama-3.1-70b-instruct
51+
- NIM of nvidia/llama-3.3-nemotron-super-49b-v1.5
5252
- Retriever Models
5353
- NIM of nvidia/llama-3_2-nv-embedqa-1b-v2
5454
- NIM of nvidia/llama-3_2-nv-rerankqa-1b-v2

community/log_analysis_multi_agent_rag/graphedges.py

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ def decide_to_generate(state):
1111
print("ASSESS GRADED DOCUMENTS")
1212
state["question"]
1313
filtered_documents = state["documents"]
14+
transform_count = state.get("transform_count", 0)
15+
16+
# If we've transformed too many times, force generation
17+
if transform_count >= 2:
18+
print("DECISION: MAX TRANSFORMS REACHED, FORCING GENERATION")
19+
return "generate"
1420

1521
if not filtered_documents:
1622
print(
@@ -33,10 +39,21 @@ def grade_generation_vs_documents_and_question(state):
3339
generation = state["generation"]
3440

3541
print("GRADE GENERATED vs QUESTION")
36-
score = automation.answer_grader.invoke({"question": question, "generation": generation})
37-
grade = score.binary_score
38-
if grade == "yes":
39-
print("DECISION: GENERATION ADDRESSES QUESTION")
40-
return "useful"
41-
print("DECISION: GENERATION DOES NOT ADDRESS QUESTION")
42-
return "not useful"
42+
try:
43+
score_text = automation.answer_grader.invoke({"question": question, "generation": generation})
44+
if "yes" in score_text.lower():
45+
print("DECISION: GENERATION ADDRESSES QUESTION")
46+
return "useful"
47+
else:
48+
# Check if we've transformed too many times
49+
transform_count = state.get("transform_count", 0)
50+
if transform_count >= 2:
51+
print("DECISION: MAX TRANSFORMS REACHED, ACCEPTING GENERATION")
52+
return "useful"
53+
else:
54+
print("DECISION: GENERATION DOES NOT ADDRESS QUESTION")
55+
return "not useful"
56+
except:
57+
# If grading fails, assume generation is useful to avoid infinite loops
58+
print("DECISION: GRADING FAILED, ACCEPTING GENERATION")
59+
return "useful"

community/log_analysis_multi_agent_rag/multiagent.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ def __init__(self, file_path, api_key):
1818
self.hybrid_retriever = self.create_hybrid_retriever()
1919

2020
def initialize_nvidia_components(self):
21-
embeddings =NVIDIAEmbeddings(model="nvidia/llama-3.2-nv-embedqa-1b-v2", truncate="NONE")
21+
embeddings =NVIDIAEmbeddings(model="nvidia/llama-3.2-nv-embedqa-1b-v2", truncate="END")
2222
return embeddings
2323

2424
def load_and_split_documents(self):
2525
loader = TextLoader(self.file_path)
2626
docs = loader.load()
27-
text_splitter = RecursiveCharacterTextSplitter(chunk_size=5000, chunk_overlap=600)
27+
text_splitter = RecursiveCharacterTextSplitter(chunk_size=20000, chunk_overlap=10000)
2828
doc_splits = text_splitter.split_documents(docs)
2929
return doc_splits
3030

@@ -35,7 +35,7 @@ def create_retrievers(self):
3535
return bm25_retriever, faiss_retriever
3636

3737
def create_hybrid_retriever(self):
38-
hybrid_retriever = EnsembleRetriever(retrievers=[self.bm25_retriever, self.faiss_retriever], weights=[0.7, 0.3])
38+
hybrid_retriever = EnsembleRetriever(retrievers=[self.bm25_retriever, self.faiss_retriever], weights=[0.5, 0.5])
3939
return hybrid_retriever
4040

4141
def get_retriever(self):

0 commit comments

Comments
 (0)