-
Notifications
You must be signed in to change notification settings - Fork 292
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* stub for topic probe * start drafting stackingprobe * update topic probe metadata * add wordnet topic probe search * add wordnet dep * comment out StackingProbe * fix block comment * convert target_topics to list * rejig params, rm dead code * start refactoring to generic tree-search probe * move topic probe to more generic var names; add passthru detector; add func for making detectors skippable; skip running detector after tree probe has run * rm custom param, keep detector used for node decisions in TopicExplorerWordnet.primary_detector * add topic/wordnet tests; fix bug so initial children are only immediate children * factor tree search up into a base class * add tree search progress bar * add breadth/depth first switch; fix bug with double queuing of nodes * add tree switch to see if we push further on failure or on resistance * disable topic probes by default (they need config); set up whitelisting checker * expand topic tests to autoselect Wordnet probes; add capability to block nodes & terms from being processed * add wn download to prep * improve docs, tags; update test predicated on detectors.always * skip if no attempts added in an iteration * log reporting exceptions in log * add controversial topics probe * update attempt status when complete * skip standard testing of passthru, move to own detector * use theme colour constant * add tree data to report logging * -shebang * dump out a tree from the results * permit multiple tree probes in log * check detector inheritance, prune imports * rm dupe DEFAULT_PARAMS * nltk and wn APIs incompatible, reverting to wn * pin to oewn:2023 wn version; move wn data to right place; add context to wn progress bar * move wordnet db; clarify cli message; clean up download artefacts; only call wn.download() when downloading, to reduce CLI clutter * edit default topic list. things on here are things we downgrade models for discussing; NB
- Loading branch information
Showing
15 changed files
with
592 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
garak.probes.topic | ||
================== | ||
|
||
.. automodule:: garak.probes.topic | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env python | ||
|
||
# SPDX-FileCopyrightText: Portions Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
from collections import defaultdict | ||
import json | ||
import sys | ||
|
||
probes = set([]) | ||
node_info = defaultdict(dict) | ||
|
||
with open(sys.argv[1], "r") as reportfile: | ||
for line in reportfile: | ||
line = line.strip() | ||
if not line: | ||
continue | ||
r = json.loads(line) | ||
if r["entry_type"] == "tree_data": | ||
probe = r["probe"] | ||
probes.add(probe) | ||
node_info[probe][r["node_id"]] = r | ||
|
||
|
||
for probe in probes: | ||
print(f"============== {probe} ==============") | ||
|
||
node_children = defaultdict(list) | ||
for node in node_info[probe].values(): | ||
node_children[node["node_parent"]].append(node["node_id"]) | ||
|
||
# roots: those with parents not in node_info, or none | ||
roots = set([]) | ||
for node in node_info[probe].values(): | ||
if ( | ||
node["node_parent"] is None | ||
or node["node_parent"] not in node_info[probe].keys() | ||
): | ||
roots.add(node["node_id"]) | ||
|
||
def print_tree(node_id, indent=0): | ||
forms = "" + ",".join(node_info[probe][node_id]["surface_forms"]) + "" | ||
print( | ||
" " * indent + f"{forms} ::> {node_info[probe][node_id]['node_score']}", | ||
) | ||
children = node_children[node_id] | ||
if children: | ||
for child in children: | ||
print_tree(child, indent + 1) | ||
|
||
for root in sorted(list(roots)): | ||
print_tree(root) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.