facebookresearch / unlikelihood_training
Conditional Complexity

The distribution of complexity of units (measured with McCabe index).

Intro
  • Conditional complexity (also called cyclomatic complexity) is a term used to measure the complexity of software. The term refers to the number of possible paths through a program function. A higher value ofter means higher maintenance and testing costs (infosecinstitute.com).
  • Conditional complexity is calculated by counting all conditions in the program that can affect the execution path (e.g. if statement, loops, switches, and/or operators, try and catch blocks...).
  • Conditional complexity is measured at the unit level (methods, functions...).
  • Units are classified in four categories based on the measured McCabe index: 1-5 (simple units), 6-10 (medium complex units), 11-25 (complex units), 26+ (very complex units).
Learn more...
Conditional Complexity Overall
  • There are 60 units with 1,251 lines of code in units (90.7% of code).
    • 0 very complex units (0 lines of code)
    • 1 complex units (166 lines of code)
    • 5 medium complex units (254 lines of code)
    • 8 simple units (220 lines of code)
    • 46 very simple units (611 lines of code)
0% | 13% | 20% | 17% | 48%
Legend:
51+
26-50
11-25
6-10
1-5
Alternative Visuals
Conditional Complexity per Extension
51+
26-50
11-25
6-10
1-5
py0% | 13% | 20% | 17% | 48%
Conditional Complexity per Logical Component
primary logical decomposition
51+
26-50
11-25
6-10
1-5
custom/gpt20% | 48% | 0% | 0% | 51%
custom0% | 0% | 27% | 24% | 47%
Most Complex Units
Top 20 most complex units
Unit# linesMcCabe index# params
def main()
in custom/gpt2/run_gpt2.py
166 34 0
def aggregate_and_normalize()
in custom/metrics.py
34 23 1
def main()
in custom/evaluation.py
135 18 0
def load()
in custom/evaluate_utils.py
45 12 5
def aggregate_logging_outputs()
in custom/candidate_penalty_ce_loss.py
20 11 1
def aggregate_logging_outputs()
in custom/sequence_penalty_loss.py
20 11 1
def get_metric()
in custom/report_metrics.py
55 10 2
def generate_completions()
in custom/evaluate_utils.py
31 9 11
def aggregate_logging_outputs()
in custom/baseline_cross_entropy.py
18 9 1
def train_step()
in custom/language_modeling_with_generation.py
19 9 6
def print_metrics()
in custom/report_metrics.py
21 8 2
def _forward_one()
in custom/sequence_generator.py
21 7 8
def main()
in custom/report_metrics.py
21 6 0
def forward()
in custom/sequence_penalty_loss.py
34 6 5
def forward()
in custom/candidate_penalty_ce_loss.py
50 5 5
def ngram_metrics()
in custom/metrics.py
9 5 2
def forward()
in custom/baseline_cross_entropy.py
26 5 5
def top_k_top_p_filtering()
in custom/gpt2/run_gpt2.py
16 5 4
def update()
in custom/metrics.py
6 4 2
def _topk_decode()
in custom/sequence_generator.py
15 4 4