All problems
Context Quadratic Cost Multiplier
Problem
Compute how much the quadratic attention cost grows when the context length increases from base_len to new_len: (new_len / base_len)^2.
The signature is context_cost_multiplier(base_len, new_len). Return a float multiplier.
Hint
Doubling the context quadruples the quadratic attention work.
Test cases
case 1
in: [2048,4096]
expected: 4
case 2
in: [1024,3072]
expected: 9
case 3
in: [512,512]
expected: 1
case 4
in: [100,150]
expected: 2.25
Starter codePython
def context_cost_multiplier(base_len, new_len):
# Your code here
pass4 test cases · run your code against them in the editor