Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

json format do not return all the results #94

Open
jojogh opened this issue Mar 20, 2024 · 2 comments
Open

json format do not return all the results #94

jojogh opened this issue Mar 20, 2024 · 2 comments

Comments

@jojogh
Copy link

jojogh commented Mar 20, 2024

The code is below and problem i met is below:

code = """

package org.demo.codesmell.config;

public class AppConfig {

public static final String APP_PASSWORD = "appPassword";

public static final String Password = "password";
}

"""
prompt = f"""
Please review the following code, and you must find all the issues in the code:{code}"""

import ollama #ollama run codellama:34b-instruct-q5_K_M
from ollama import Options

response = ollama.chat(model='codellama:34b-instruct-q5_K_M',
messages=[
{
'role': 'user',
'content': prompt,
},

],
#format="json",
#stream=True,
options=Options(
temperature=0,
#top_p=0.9,
#max_tokens=1024,
num_ctx=8192,
num_predict=-1)
)
print(response['message']["content"])

It will return the following informations, 5 issues
The code you provided is a Java class that defines some constants for an application configuration. Here are the issues I found:

  1. The naming convention for constants is not consistent. Some constants are in all caps, while others are camelCase. It's best to use a consistent naming convention throughout the code.
  2. The Password constant is misspelled. It should be APP_PASSWORD.
  3. The APP_PASSWORD constant is not used anywhere in the code. If it's not being used, it can be removed.
  4. There are no getters or setters for the constants. It's best to provide getters and setters for each constant so that they can be accessed and modified from outside the class.
  5. The class is not final, which means it can be extended. However, there is no need to extend this class as it only contains constants. It would be better to make the class final to prevent unintended inheritance.

But, as I just use the option, format="json", it just return 2 issues in json format, is that a bug?

@gautam-fairpe
Copy link

No, It is not a bug. When you force model to return in specified json format, result will not be as good as normal generation.

@gautam-fairpe
Copy link

I faced similar issue while using llama cpp python with lm-format-enforcer.

https://github.com/noamgat/lm-format-enforcer#:~:text=Diagnostics%20%2D%20Will%20I%20always%20get%20good%20results%3F

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants