Skip to content
Discussion options

You must be logged in to vote

On the question of why position_ids are not explicitly needed and can be internally handled by the model — taking ChatGLM4-6B as an example:

ChatGLM uses Rotary Position Embedding (RoPE) for positional encoding. Since RoPE is a form of relative position embedding, as long as tokens are fed into the model in a continuous manner (i.e., positions follow a natural order like 0, 1, 2, ..., n), the model can compute positional information internally using the RoPE formulation — no need to explicitly supply position_ids.

Regarding how position_ids are generated when needed, you can refer to the prepare_inputs_for_generation function in the official implementation. The position IDs are constructe…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ciaoyizhen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants