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

Fixing Exception Cause By Type Error When Scanning LLMs Via Replicate #401

Merged
merged 2 commits into from
Jan 17, 2024

Conversation

DavidLee528
Copy link
Contributor

Hi professor,

Recently I launched a garak scan using debug mode of vscode with the following configuration:

    {
        "name": "replicate+meta/llama-2-70b-chat",
        "type": "python",
        "request": "launch",
        "program": "${workspaceFolder}/garak/__main__.py",
        "console": "integratedTerminal",
        "args": [
            "--model_type",
            "replicate",
            "--model_name",
            "meta/llama-2-70b-chat",
            "--probes",
            "malwaregen"
        ],
        "justMyCode": false,
        "env": {
            "REPLICATE_API_TOKEN": "****************************************************************" 
        }
    },

But I got exception raised by ....../python3.11/site-packages/backoff/_sync.py:106:

input.seed: Invalid type. Expected: integer, given: null

Finally I found the reason of the exception:

The value assignment operation of self.seed = 9 in garak/generators/replicate.py:38 has been proved invalid according to the collision described below:

  1. garak/resources/garak.core.yaml:9: the attribute seed has a default value "empty", which is regarded as None in Python syntax;
  2. The above None value could assign to self.seed of class ReplicateGenerator by self.seed = _config.run.seed in garak/generators/replicate.py:40 and generator.seed = _config.run.seed in
    garak/cli.py:445;
  3. garak/generators/replicate.py:63 needs self.seed to be int type but it is None type.

To address this problem, I made some modifications to avoid value assignment operation when self.seed appears to None type. I believe those modifications could enhance the robustness of the framework.

Please review the code comparison for detail. Any problems, feel free to point it out. 😊

@leondz
Copy link
Owner

leondz commented Jan 17, 2024

Thanks. This is a fine workaround - I'm sure we'll see this in more than one place. The ultimate fix is to use a better data structure for _config, but this fix looks good to me.

@leondz leondz merged commit 2fcc4e8 into leondz:main Jan 17, 2024
1 check passed
@github-actions github-actions bot locked and limited conversation to collaborators Jan 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants