dleemiller / WordLlama

Things you can do with the token embeddings of an LLM
MIT License
1.39k stars 47 forks source link

ModuleNotFoundError: No module named 'wordllama.algorithms.kmeans_helpers' #13

Closed chapmanjacobd closed 2 months ago

chapmanjacobd commented 2 months ago
pip install --force-reinstall wordllama
...
Successfully installed wordllama-0.2.6.post0
>>> from wordllama import WordLlama
>>> wl = WordLlama.load(trunc_dim=64)

ModuleNotFoundError                       Traceback (most recent call last)
Cell In[1], line 1
----> 1 from wordllama import WordLlama
      3 # Load pre-trained embeddings
      4 # truncate dimension to 64
      5 wl = WordLlama.load(trunc_dim=64)

File ~/github/o/WordLlama/wordllama/__init__.py:13
     10 import logging
     11 from typing import Union, Optional
---> 13 from .wordllama import WordLlama
     14 from .config import Config, WordLlamaConfig
     15 from ._version import __version__

File ~/github/o/WordLlama/wordllama/wordllama.py:10
      7 from tokenizers import Tokenizer
      8 from safetensors import safe_open
---> 10 from .inference import WordLlamaInference
     11 from .config import Config, WordLlamaConfig
     12 from .tokenizers import tokenizer_from_file

File ~/github/o/WordLlama/wordllama/inference.py:6
      3 from typing import Union, List, Tuple, Optional
      4 import logging
----> 6 from .algorithms import (
      7     kmeans_clustering,
      8     hamming_distance,
      9     binarize_and_packbits,
     10     process_batches_cy,
     11 )
     12 from .config import WordLlamaConfig
     14 # Set up logging

File ~/github/o/WordLlama/wordllama/algorithms/__init__.py:1
----> 1 from .kmeans import kmeans_clustering
      2 from .hamming_distance import hamming_distance, binarize_and_packbits
      3 from .deduplicate_helpers import process_batches_cy

File ~/github/o/WordLlama/wordllama/algorithms/kmeans.py:3
      1 import numpy as np
      2 from typing import List, Tuple
----> 3 from .kmeans_helpers import compute_distances, update_centroids
      6 def kmeans_plusplus_initialization(
      7     embeddings: np.ndarray, k: int, random_state: np.random.RandomState
      8 ) -> np.ndarray:
      9     """
     10     Initialize centroids using the K-Means++ algorithm.
     11
   (...)
     18     np.ndarray: The initialized centroids.
     19     """

ModuleNotFoundError: No module named 'wordllama.algorithms.kmeans_helpers'
> /home/xk/github/o/WordLlama/wordllama/algorithms/kmeans.py(3)<module>()
      1 import numpy as np
      2 from typing import List, Tuple
----> 3 from .kmeans_helpers import compute_distances, update_centroids
      4
      5

ipdb> q
dleemiller commented 2 months ago

Hey @chapmanjacobd - if you are using python 3.8, can you try re-installing? I found a mismatch between my pyproject and my CI build versions and had to add them back in. If not, can you tell me what your python version is? I think this could only come from missing wheels.

chapmanjacobd commented 2 months ago

This is python3.12

but whatever you did, wordllama-0.2.6.post2 works so far

thx