Skip to content

Commit f050fa4

Browse files
committed
fix: bug
1 parent 9b01397 commit f050fa4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/evaluator/LlamaContext/LlamaContext.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {UnsupportedError} from "../../utils/UnsupportedError.js";
1212
import {ThreadsSplitterConsumer} from "../../utils/ThreadsSplitter.js";
1313
import {pushAll} from "../../utils/pushAll.js";
1414
import {safeEventCallback} from "../../utils/safeEventCallback.js";
15+
import {GgufArchitectureType} from "../../gguf/types/GgufMetadataTypes.js";
1516
import {
1617
BatchingOptions, BatchItem, ContextShiftOptions, ContextTokensDeleteRange, ControlledEvaluateIndexOutput, ControlledEvaluateInputItem,
1718
EvaluationPriority, LlamaContextOptions, LlamaContextSequenceRepeatPenalty, PrioritizedBatchItem, SequenceEvaluateOptions
@@ -1079,7 +1080,10 @@ export class LlamaContextSequence {
10791080
* which incurs token evaluation of the shifted tokens.
10801081
*/
10811082
public async adaptStateToTokens(tokens: Token[], allowShift: boolean = true) {
1082-
if (this.model.fileInsights.isRecurrent || !allowShift) {
1083+
const modelSupportsShifting = !this.model.fileInsights.isRecurrent &&
1084+
this.model.fileInfo.metadata?.general?.architecture !== GgufArchitectureType.deepseek2;
1085+
1086+
if (!modelSupportsShifting || !allowShift) {
10831087
const {firstDifferentIndex} = this.compareContextTokens(tokens);
10841088
if (firstDifferentIndex < this.nextTokenIndex)
10851089
await this._eraseContextTokenRanges([{

0 commit comments

Comments
 (0)