diff --git a/python/llm/src/bigdl/llm/ggml/model/bloom/bloom.py b/python/llm/src/bigdl/llm/ggml/model/bloom/bloom.py index 0eea6528..ec33ddaa 100644 --- a/python/llm/src/bigdl/llm/ggml/model/bloom/bloom.py +++ b/python/llm/src/bigdl/llm/ggml/model/bloom/bloom.py @@ -313,9 +313,6 @@ class Bloom(GenerationMixin): } } - def free(self): - bloom_free(self.ctx) - def _tokenize(self, text: bytes, add_bos: bool = False) -> List[int]: """Tokenize a string. @@ -427,3 +424,8 @@ class Bloom(GenerationMixin): seed=self.seed, n_threads=self.n_threads, n_batch=self.n_batch) + + def __del__(self): + if self.ctx is not None: + bloom_free(self.ctx) + self.ctx = None diff --git a/python/llm/src/bigdl/llm/ggml/model/starcoder/starcoder.py b/python/llm/src/bigdl/llm/ggml/model/starcoder/starcoder.py index e40fc991..e54392d7 100644 --- a/python/llm/src/bigdl/llm/ggml/model/starcoder/starcoder.py +++ b/python/llm/src/bigdl/llm/ggml/model/starcoder/starcoder.py @@ -315,9 +315,6 @@ class Starcoder(GenerationMixin): } } - def free(self): - starcoder_free(self.ctx) - def _tokenize(self, text: bytes, add_bos: bool = False) -> List[int]: """Tokenize a string. @@ -433,3 +430,8 @@ class Starcoder(GenerationMixin): seed=self.seed, n_threads=self.n_threads, n_batch=self.n_batch) + + def __del__(self): + if self.ctx is not None: + starcoder_free(self.ctx) + self.ctx = None