From 50225f86af9d58c4745a9aa78de3ec23380a248b Mon Sep 17 00:00:00 2001 From: Aman Karmani Date: Fri, 4 Oct 2024 21:53:48 -0700 Subject: [PATCH] fix memory leak in BPE --- src/tokenizers.js | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/tokenizers.js b/src/tokenizers.js index 234eef15e..a125ed4b2 100644 --- a/src/tokenizers.js +++ b/src/tokenizers.js @@ -668,9 +668,6 @@ class BPE extends TokenizerModel { } this.ignore_merges = this.config.ignore_merges ?? false; - - /** @type {Map} */ - this.cache = new Map(); } /** @@ -684,11 +681,6 @@ class BPE extends TokenizerModel { return []; } - const cached = this.cache.get(token); - if (cached !== undefined) { - return cached; - } - const word = Array.from(token); if (this.end_of_word_suffix) { word[word.length - 1] += this.end_of_word_suffix; @@ -797,9 +789,6 @@ class BPE extends TokenizerModel { } } - // Save the result to the cache - this.cache.set(token, result); - return result; }