Loading...
Loading...
You are given an integer t, a 2d list of integers embedding with v rows and d columns, a 2d list of integers linear with d rows and d columns, and a 2d list of integers outputEmbedding with v rows and d columns. Token t is scored as follows:
a is row t of embedding, a vector of length d.b is the vector of length d where b[j] is the sum of linear[j][i] * a[i] over every i from 0 to d - 1.c is the vector of length d where c[j] is b[j] when b[j] is positive, and 0 otherwise.s is the vector of length v where s[m] is the sum of outputEmbedding[m][j] * c[j] over every j from 0 to d - 1.Return the list of integers s. You can assume 0 <= t < v and the result fits in a 32-bit signed integer.
v ≤100d ≤100t < vembedding has v rows and d columns.linear has d rows and d columns.outputEmbedding has v rows and d columns.embedding[i][j] ≤10linear[i][j] ≤10outputEmbedding[i][j] ≤10With d = 1, a = [3] scales to b = [6], and 6 is positive so c = [6]. The single output row then gives s = [30].
a = [1, -1] gives b = [1, -1]; only the positive entry remains, so c = [1, 0]. Multiplying by the output row [2, 3] gives s = [2].
Row 1 of embedding is [0, 1], which gives b = [-1, 1] and c = [0, 1]. The two output rows then produce s = [1, -1].