Skip to content
DeepForgeby svx
All problems

Language-Conditioned Reward

Problem

Compute a language-conditioned reward as the cosine similarity between the language embedding and the state embedding. A zero-norm vector gives 0.0.

Hint

Cosine similarity makes the reward scale-free with respect to embedding magnitude.

Test cases

case 1
in: [[1,0],[1,0]]
expected: 1
case 2
in: [[1,0],[0,1]]
expected: 0
case 3
in: [[1,1],[2,2]]
expected: 0.9999999999999998
case 4
in: [[0,0],[1,0]]
expected: 0
Starter codePython
import math
def language_conditioned_reward(language_embedding, state_embedding):
    # Your code here
    pass

4 test cases · run your code against them in the editor