pvs-hd-tea / 23ws-LLMcoder

LLMcoder - Practical in winter semester 2023/2024
MIT License
2 stars 2 forks source link

Hallucination analyzer #72

Closed psaegert closed 9 months ago

psaegert commented 10 months ago

Adds an analyzer that checks if non-existent attributes are used in the completion.

Example level_0/6 without HallucinationAnalyzer

[LLMcoder] SYSTEM: You are AutocompleteGPT, a useful AI autocomplete tool that provides code completions based on the user's code.
You are a precision-focused tool for code autocompletion, adept in languages like Python, JavaScript, C++, and SQL.
Precisely continue the code from the point of interruption and do not repeat or modify the original code, even if it is incorrect or the code interrupts in the middle of a line.
Your code is well documented with comments and annotations, and you should provide a clear explanation of the code's purpose in your code completion.
Your unique capability is to provide completions without altering, repeating, or commenting on the original code.
You offer only the necessary code to complete the snippet, ensuring the response is exclusively code, with no additional comments, explanations, or annotations.
This approach makes you an ideal assistant for users seeking straightforward and efficient code extensions, enhancing their work with accurate, logic-driven completions while maintaining the integrity and simplicity of the original input.
Your response begins with the next characters of the line if the last line of the user's code is incomplete, or the next line if the last line of the user's code is complete.
Your application is a VSCode extension like GitHub Copilot, which provides seamless code completions based on the user's code at the point of interruption.
[LLMcoder] Creating first completion...
[LLMcoder] USER: import json
import os
import numpy as np
import tiktoken

enc = tiktoken.
[LLMcoder] Analyzing completion...
[LLMcoder] Analyzing code in coworker mode...
[LLMcoder] Running mypy_analyzer_v1...
[Mypy] No missing stubs found.
[Mypy] /tmp/tmprc7nnqgq.py:6: error: Module has no attribute "TikTok"  [attr-defined]
[Mypy] Found 1 error in 1 file (checked 1 source file)
[LLMcoder] Running signature_analyzer_v1...
[Signatures] Using context from previous analyzers: ['mypy_analyzer_v1']
[Signatures] No problematic functions or classes found in the context.
[LLMcoder] ASSISTANT: TikTok()
[LLMcoder] 0 / 1 analyzers passed
[LLMcoder] Starting feedback loop...
[LLMcoder] Starting feedback iteration 1...
[LLMcoder] USER: [INST]
The completion you provided resulted in the following errors:
your completion:6: error: Module has no attribute "TikTok"  [attr-defined]
Found 1 error in 1 file (checked 1 source file)
All functions and classes in your completion are called correctly (their signatures match with the documentation).

Fix, improve and rewrite your completion for the following code:
[/INST]
import json
import os
import numpy as np
import tiktoken

enc = tiktoken.
[LLMcoder] Analyzing completion...
[LLMcoder] Analyzing code in coworker mode...
[LLMcoder] Running mypy_analyzer_v1...
[Mypy] No missing stubs found.
[Mypy] /tmp/tmpm972m79v.py:6: error: Module has no attribute "TikTok"  [attr-defined]
[Mypy] Found 1 error in 1 file (checked 1 source file)
[LLMcoder] Running signature_analyzer_v1...
[Signatures] Using context from previous analyzers: ['mypy_analyzer_v1']
[Signatures] No problematic functions or classes found in the context.
[LLMcoder] ASSISTANT: TikTok()
[LLMcoder] 0 / 1 analyzers passed
[LLMcoder] Starting feedback iteration 2...
[LLMcoder] USER: [INST]
The completion you provided resulted in the following errors:
your completion:6: error: Module has no attribute "TikTok"  [attr-defined]
Found 1 error in 1 file (checked 1 source file)
All functions and classes in your completion are called correctly (their signatures match with the documentation).

Fix, improve and rewrite your completion for the following code:
[/INST]
import json
import os
import numpy as np
import tiktoken

enc = tiktoken.
[LLMcoder] Analyzing completion...
[LLMcoder] Analyzing code in coworker mode...
[LLMcoder] Running mypy_analyzer_v1...
[Mypy] No missing stubs found.
[Mypy] /tmp/tmpq4m3w1at.py:6: error: Module has no attribute "TikTok"  [attr-defined]
[Mypy] Found 1 error in 1 file (checked 1 source file)
[LLMcoder] Running signature_analyzer_v1...
[Signatures] Using context from previous analyzers: ['mypy_analyzer_v1']
[Signatures] No problematic functions or classes found in the context.
[LLMcoder] ASSISTANT: TikTok()
[LLMcoder] 0 / 1 analyzers passed
[LLMcoder] Starting feedback iteration 3...
[LLMcoder] USER: [INST]
The completion you provided resulted in the following errors:
your completion:6: error: Module has no attribute "TikTok"  [attr-defined]
Found 1 error in 1 file (checked 1 source file)
All functions and classes in your completion are called correctly (their signatures match with the documentation).

Fix, improve and rewrite your completion for the following code:
[/INST]
import json
import os
import numpy as np
import tiktoken

enc = tiktoken.
[LLMcoder] Analyzing completion...
[LLMcoder] Analyzing code in coworker mode...
[LLMcoder] Running mypy_analyzer_v1...
[Mypy] No missing stubs found.
[Mypy] /tmp/tmpv112gfhn.py:6: error: Module has no attribute "TikTok"  [attr-defined]
[Mypy] Found 1 error in 1 file (checked 1 source file)
[LLMcoder] Running signature_analyzer_v1...
[Signatures] Using context from previous analyzers: ['mypy_analyzer_v1']
[Signatures] No problematic functions or classes found in the context.
[LLMcoder] ASSISTANT: TikTok()
[LLMcoder] 0 / 1 analyzers passed
[LLMcoder] Starting feedback iteration 4...
[LLMcoder] USER: [INST]
The completion you provided resulted in the following errors:
your completion:6: error: Module has no attribute "TikTok"  [attr-defined]
Found 1 error in 1 file (checked 1 source file)
All functions and classes in your completion are called correctly (their signatures match with the documentation).

Fix, improve and rewrite your completion for the following code:
[/INST]
import json
import os
import numpy as np
import tiktoken

enc = tiktoken.
[LLMcoder] Analyzing completion...
[LLMcoder] Analyzing code in coworker mode...
[LLMcoder] Running mypy_analyzer_v1...
[Mypy] No missing stubs found.
[Mypy] /tmp/tmpbs6o3nya.py:6: error: Module has no attribute "TikTok"  [attr-defined]
[Mypy] Found 1 error in 1 file (checked 1 source file)
[LLMcoder] Running signature_analyzer_v1...
[Signatures] Using context from previous analyzers: ['mypy_analyzer_v1']
[Signatures] No problematic functions or classes found in the context.
[LLMcoder] ASSISTANT: TikTok()
[LLMcoder] 0 / 1 analyzers passed
[LLMcoder] Starting feedback iteration 5...
[LLMcoder] USER: [INST]
The completion you provided resulted in the following errors:
your completion:6: error: Module has no attribute "TikTok"  [attr-defined]
Found 1 error in 1 file (checked 1 source file)
All functions and classes in your completion are called correctly (their signatures match with the documentation).

Fix, improve and rewrite your completion for the following code:
[/INST]
import json
import os
import numpy as np
import tiktoken

enc = tiktoken.
[LLMcoder] Analyzing completion...
[LLMcoder] Analyzing code in coworker mode...
[LLMcoder] Running mypy_analyzer_v1...
[Mypy] No missing stubs found.
[Mypy] /tmp/tmppuotpx67.py:6: error: Module has no attribute "TikTok"  [attr-defined]
[Mypy] Found 1 error in 1 file (checked 1 source file)
[LLMcoder] Running signature_analyzer_v1...
[Signatures] Using context from previous analyzers: ['mypy_analyzer_v1']
[Signatures] No problematic functions or classes found in the context.
[LLMcoder] ASSISTANT: TikTok()
[LLMcoder] 0 / 1 analyzers passed

Example level_0/6 with HallucinationAnalyzer

[LLMcoder] SYSTEM: You are AutocompleteGPT, a useful AI autocomplete tool that provides code completions based on the user's code.
You are a precision-focused tool for code autocompletion, adept in languages like Python, JavaScript, C++, and SQL.
Precisely continue the code from the point of interruption and do not repeat or modify the original code, even if it is incorrect or the code interrupts in the middle of a line.
Your code is well documented with comments and annotations, and you should provide a clear explanation of the code's purpose in your code completion.
Your unique capability is to provide completions without altering, repeating, or commenting on the original code.
You offer only the necessary code to complete the snippet, ensuring the response is exclusively code, with no additional comments, explanations, or annotations.
This approach makes you an ideal assistant for users seeking straightforward and efficient code extensions, enhancing their work with accurate, logic-driven completions while maintaining the integrity and simplicity of the original input.
Your response begins with the next characters of the line if the last line of the user's code is incomplete, or the next line if the last line of the user's code is complete.
Your application is a VSCode extension like GitHub Copilot, which provides seamless code completions based on the user's code at the point of interruption.
[LLMcoder] Creating first completion...
[LLMcoder] USER: import json
import os
import numpy as np
import tiktoken

enc = tiktoken.
[LLMcoder] Analyzing completion...
[LLMcoder] Analyzing code in coworker mode...
[LLMcoder] Running mypy_analyzer_v1...
[Mypy] No missing stubs found.
[Mypy] /tmp/tmp1ql9926d.py:6: error: Module has no attribute "TikToken"  [attr-defined]
[Mypy] Found 1 error in 1 file (checked 1 source file)
[LLMcoder] Running signature_analyzer_v1...
[Signatures] Using context from previous analyzers: ['mypy_analyzer_v1']
[Signatures] No problematic functions or classes found in the context.
[LLMcoder] Running hallucination_analyzer_v1...
[Hallucinations] Using context from previous analyzers: ['mypy_analyzer_v1', 'signature_analyzer_v1']
[Hallucinations] Found problematic function or class: TikToken
[Hallucinations] Found 1 hallucinations: ['TikToken']
[LLMcoder] ASSISTANT: TikToken()
[LLMcoder] 0 / 1 analyzers passed
[LLMcoder] Starting feedback loop...
[LLMcoder] Starting feedback iteration 1...
[LLMcoder] USER: [INST]
The completion you provided resulted in the following errors:
your completion:6: error: Module has no attribute "TikToken"  [attr-defined]
Found 1 error in 1 file (checked 1 source file)

You used the following non-existent functions or classes:
- TikToken

In your next completion, do not use these functions or classes.

Fix, improve and rewrite your completion for the following code:
[/INST]
import json
import os
import numpy as np
import tiktoken

enc = tiktoken.
[LLMcoder] Analyzing completion...
[LLMcoder] Analyzing code in coworker mode...
[LLMcoder] Running mypy_analyzer_v1...
[Mypy] No missing stubs found.
[Mypy] /tmp/tmp5u16h23z.py:6: error: Module has no attribute "TikTokToken"  [attr-defined]
[Mypy] Found 1 error in 1 file (checked 1 source file)
[LLMcoder] Running signature_analyzer_v1...
[Signatures] Using context from previous analyzers: ['mypy_analyzer_v1']
[Signatures] No problematic functions or classes found in the context.
[LLMcoder] Running hallucination_analyzer_v1...
[Hallucinations] Using context from previous analyzers: ['mypy_analyzer_v1', 'signature_analyzer_v1']
[Hallucinations] Found problematic function or class: TikTokToken
[Hallucinations] Found 1 hallucinations: ['TikTokToken']
[LLMcoder] ASSISTANT: TikTokToken()
[LLMcoder] 0 / 1 analyzers passed
[LLMcoder] Starting feedback iteration 2...
[LLMcoder] USER: [INST]
The completion you provided resulted in the following errors:
your completion:6: error: Module has no attribute "TikTokToken"  [attr-defined]
Found 1 error in 1 file (checked 1 source file)

You used the following non-existent functions or classes:
- TikTokToken

In your next completion, do not use these functions or classes.

Fix, improve and rewrite your completion for the following code:
[/INST]
import json
import os
import numpy as np
import tiktoken

enc = tiktoken.
[LLMcoder] Analyzing completion...
[LLMcoder] Analyzing code in coworker mode...
[LLMcoder] Running mypy_analyzer_v1...
[Mypy] No missing stubs found.
[Mypy] /tmp/tmpg4aw8w55.py:6: error: Module has no attribute "tiktoken"  [attr-defined]
[Mypy] Found 1 error in 1 file (checked 1 source file)
[LLMcoder] Running signature_analyzer_v1...
[Signatures] Using context from previous analyzers: ['mypy_analyzer_v1']
[Signatures] No problematic functions or classes found in the context.
[LLMcoder] Running hallucination_analyzer_v1...
[Hallucinations] Using context from previous analyzers: ['mypy_analyzer_v1', 'signature_analyzer_v1']
[Hallucinations] Found problematic function or class: tiktoken
[Hallucinations] Found 1 hallucinations: ['tiktoken']
[LLMcoder] ASSISTANT: tiktoken()
[LLMcoder] 0 / 1 analyzers passed
[LLMcoder] Starting feedback iteration 3...
[LLMcoder] USER: [INST]
The completion you provided resulted in the following errors:
your completion:6: error: Module has no attribute "tiktoken"  [attr-defined]
Found 1 error in 1 file (checked 1 source file)

You used the following non-existent functions or classes:
- tiktoken

In your next completion, do not use these functions or classes.

Fix, improve and rewrite your completion for the following code:
[/INST]
import json
import os
import numpy as np
import tiktoken

enc = tiktoken.
[LLMcoder] Analyzing completion...
[LLMcoder] Analyzing code in coworker mode...
[LLMcoder] Running mypy_analyzer_v1...
[Mypy] No missing stubs found.
[Mypy] /tmp/tmpms1urctu.py:6: error: Module has no attribute "tiktok_token"  [attr-defined]
[Mypy] Found 1 error in 1 file (checked 1 source file)
[LLMcoder] Running signature_analyzer_v1...
[Signatures] Using context from previous analyzers: ['mypy_analyzer_v1']
[Signatures] No problematic functions or classes found in the context.
[LLMcoder] Running hallucination_analyzer_v1...
[Hallucinations] Using context from previous analyzers: ['mypy_analyzer_v1', 'signature_analyzer_v1']
[Hallucinations] Found problematic function or class: tiktok_token
[Hallucinations] Found 1 hallucinations: ['tiktok_token']
[LLMcoder] ASSISTANT: tiktok_token()
[LLMcoder] 0 / 1 analyzers passed
[LLMcoder] Starting feedback iteration 4...
[LLMcoder] USER: [INST]
The completion you provided resulted in the following errors:
your completion:6: error: Module has no attribute "tiktok_token"  [attr-defined]
Found 1 error in 1 file (checked 1 source file)

You used the following non-existent functions or classes:
- tiktok_token

In your next completion, do not use these functions or classes.

Fix, improve and rewrite your completion for the following code:
[/INST]
import json
import os
import numpy as np
import tiktoken

enc = tiktoken.
[LLMcoder] Analyzing completion...
[LLMcoder] Analyzing code in coworker mode...
[LLMcoder] Running mypy_analyzer_v1...
[Mypy] No missing stubs found.
[Mypy] /tmp/tmpz2lljai2.py:6: error: Module has no attribute "tiktok_token"  [attr-defined]
[Mypy] Found 1 error in 1 file (checked 1 source file)
[LLMcoder] Running signature_analyzer_v1...
[Signatures] Using context from previous analyzers: ['mypy_analyzer_v1']
[Signatures] No problematic functions or classes found in the context.
[LLMcoder] Running hallucination_analyzer_v1...
[Hallucinations] Using context from previous analyzers: ['mypy_analyzer_v1', 'signature_analyzer_v1']
[Hallucinations] Found problematic function or class: tiktok_token
[Hallucinations] Found 1 hallucinations: ['tiktok_token']
[LLMcoder] ASSISTANT: tiktok_token
[LLMcoder] 0 / 1 analyzers passed
[LLMcoder] Starting feedback iteration 5...
[LLMcoder] USER: [INST]
The completion you provided resulted in the following errors:
your completion:6: error: Module has no attribute "tiktok_token"  [attr-defined]
Found 1 error in 1 file (checked 1 source file)

You used the following non-existent functions or classes:
- tiktok_token

In your next completion, do not use these functions or classes.

Fix, improve and rewrite your completion for the following code:
[/INST]
import json
import os
import numpy as np
import tiktoken

enc = tiktoken.
[LLMcoder] Analyzing completion...
[LLMcoder] Analyzing code in coworker mode...
[LLMcoder] Running mypy_analyzer_v1...
[Mypy] No missing stubs found.
[Mypy] /tmp/tmpbd8yyato.py:6: error: Module has no attribute "tik"  [attr-defined]
[Mypy] Found 1 error in 1 file (checked 1 source file)
[LLMcoder] Running signature_analyzer_v1...
[Signatures] Using context from previous analyzers: ['mypy_analyzer_v1']
[Signatures] No problematic functions or classes found in the context.
[LLMcoder] Running hallucination_analyzer_v1...
[Hallucinations] Using context from previous analyzers: ['mypy_analyzer_v1', 'signature_analyzer_v1']
[Hallucinations] Found problematic function or class: tik
[Hallucinations] Found 1 hallucinations: ['tik']
[LLMcoder] ASSISTANT: tik()
[LLMcoder] 0 / 1 analyzers passed
psaegert commented 10 months ago

Continued in #73