What is the meaning of this snippet of code? Where does it likely stem from and why is…
- User
What is the meaning of this snippet of code? Where does it likely stem from and why is it needed?
val attnMaskMul = sciCore.triangle(DataType.FLOAT32, seqLen, seqLen, 0.0, 1.0) val attnMaskAdd = sciCore.triangle(DataType.FLOAT32, seqLen, seqLen, Double.NEGATIVE_INFINITY, 0.0)
att * attnMaskMul + attnMaskAdd
- Assistant
This code snippet gives the attention of a transformer when it is generating text. This snippet generates a triangular matrix with the top of the matrix being given by the 4th argument and the bottom of the matrix given by the 5th argument. When this is multiplied by the inputs, it results in a vector that only includes the first token for the first output, the first two tokens for the second output, and so on and so forth. The two seqLen tell how large the attention should look, and makes sure that the output is a square matrix. The last line uses these two matrices to remove all information about "future" tokens, which would be what the model is trying to predict.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)