Skip to content

Commit

Permalink
feat(dualEncoder): increase top_k parameter for improved search resul…
Browse files Browse the repository at this point in the history
…ts and enhance result processing output
  • Loading branch information
sumansaurabh committed Nov 13, 2024
1 parent 4314915 commit e52c3b9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
4 changes: 2 additions & 2 deletions dualEncoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def search(
query: str,
search_code: bool = True,
search_docs: bool = True,
top_k: int = 2,
top_k: int = 5,
min_similarity: float = 0.3
) -> List[CodeAnalysisResult]:
"""
Expand All @@ -213,7 +213,7 @@ def search(
code_query = code_query / (np.linalg.norm(code_query) + 1e-8)
doc_query = doc_query / (np.linalg.norm(doc_query) + 1e-8)

results = []
results: List[CodeAnalysisResult] = []

for func in self.functions:
code_sim = 0.0
Expand Down
28 changes: 27 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
repo = "/Users/sumansaurabh/Documents/singularityx/github/MoneyPrinterTurbo/app/"
repo = "/Users/sumansaurabh/Documents/singularityx/github/snorkell-backend/backend/"
repo = "/home/azureuser/localfiles/pokerogue"
repo = "/home/azureuser/localfiles/snorkell-backend"

encoder.index_repository(
repo_path=repo,
Expand All @@ -19,7 +20,7 @@
# Search with different focuses
# 1. Search everything

message = "Increment the turn in the battle scene"
message = "add try catch block to the site uploader so that it can retry the upload if it fails"
results = encoder.search(
message,
search_code=True,
Expand All @@ -40,6 +41,8 @@
search_docs=True
)

print("####### OVerall Reusltes ##########")

# Process results
for result in results:
print(f"Function: {result.function.name}")
Expand All @@ -49,7 +52,30 @@
print(f"Doc Similarity: {result.doc_similarity:.2f}")
print(f"Combined: {result.combined_similarity:.2f}")
print("\n\n")


print("####### DOC Reusltes ##########")

for result in doc_results:
print(f"Function: {result.function.name}")
print(f"File Path: {result.function.file_path}")
print(f"Docstring: {result.function.documentation}")
print(f"Code Similarity: {result.code_similarity:.2f}")
print(f"Doc Similarity: {result.doc_similarity:.2f}")
print(f"Combined: {result.combined_similarity:.2f}")
print("\n\n")


print("####### Code results##########")

for result in code_results:
print(f"Function: {result.function.name}")
print(f"File Path: {result.function.file_path}")
print(f"Docstring: {result.function.documentation}")
print(f"Code Similarity: {result.code_similarity:.2f}")
print(f"Doc Similarity: {result.doc_similarity:.2f}")
print(f"Combined: {result.combined_similarity:.2f}")
print("\n\n")


# # code results
Expand Down

0 comments on commit e52c3b9

Please sign in to comment.