marella / chatdocs

Chat with your documents offline using AI.
MIT License
683 stars 97 forks source link

Error on chatdocs download at Macos chip M1 pro #53

Closed lukenvn closed 1 year ago

lukenvn commented 1 year ago

Hi guys, As the title said, I try to run the chatdocs download command in my MacBook and got this error. Can somebody tell me how to fix it? I would like to try this cool tool in my localmchine

Thank you in advanced!

load INSTRUCTOR_Transformer max_seq_length 512 Fetching 0 files: 0it [00:00, ?it/s] Fetching 1 files: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 19239.93it/s] ╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮ │ /Users/-/Library/Python/3.9/lib/python/site-packages/chatdocs/main.py:26 in download │ │ │ │ 23 │ from .download import download │ │ 24 │ │ │ 25 │ config = get_config(config) │ │ ❱ 26 │ download(config=config) │ │ 27 │ │ 28 │ │ 29 @app.command() │ │ │ │ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │ │ │ config = { │ │ │ │ │ 'embeddings': {'model': 'hkunlp/instructor-large'}, │ │ │ │ │ 'llm': 'ctransformers', │ │ │ │ │ 'ctransformers': { │ │ │ │ │ │ 'model': 'TheBloke/Wizard-Vicuna-7B-Uncensored-GGML', │ │ │ │ │ │ 'model_file': 'Wizard-Vicuna-7B-Uncensored.ggmlv3.q4_0.bin', │ │ │ │ │ │ 'model_type': 'llama', │ │ │ │ │ │ 'config': {'context_length': 1024, 'local_files_only': False} │ │ │ │ │ }, │ │ │ │ │ 'huggingface': { │ │ │ │ │ │ 'model': 'TheBloke/Wizard-Vicuna-7B-Uncensored-HF', │ │ │ │ │ │ 'pipeline_kwargs': {'max_new_tokens': 256} │ │ │ │ │ }, │ │ │ │ │ 'gptq': { │ │ │ │ │ │ 'model': 'TheBloke/Wizard-Vicuna-7B-Uncensored-GPTQ', │ │ │ │ │ │ 'model_file': │ │ │ │ 'Wizard-Vicuna-7B-Uncensored-GPTQ-4bit-128g.no-act-order.safetensors', │ │ │ │ │ │ 'pipeline_kwargs': {'max_new_tokens': 256} │ │ │ │ │ }, │ │ │ │ │ 'download': False, │ │ │ │ │ 'host': 'localhost', │ │ │ │ │ 'port': 5000, │ │ │ │ │ 'auth': False, │ │ │ │ │ 'chroma': { │ │ │ │ │ │ 'persist_directory': 'db', │ │ │ │ │ │ 'chroma_db_impl': 'duckdb+parquet', │ │ │ │ │ │ 'anonymized_telemetry': False │ │ │ │ │ }, │ │ │ │ │ ... +1 │ │ │ │ } │ │ │ │ download = <function download at 0x105ea9d30> │ │ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │ │ │ │ /Users/-/Library/Python/3.9/lib/python/site-packages/chatdocs/download.py:10 in download │ │ │ │ 7 def download(config: Dict[str, Any]) -> None: │ │ 8 │ config = {config, "download": True} │ │ 9 │ get_embeddings(config) │ │ ❱ 10 │ get_llm(config) │ │ 11 │ │ │ │ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │ │ │ config = { │ │ │ │ │ 'embeddings': {'model': 'hkunlp/instructor-large'}, │ │ │ │ │ 'llm': 'ctransformers', │ │ │ │ │ 'ctransformers': { │ │ │ │ │ │ 'model': 'TheBloke/Wizard-Vicuna-7B-Uncensored-GGML', │ │ │ │ │ │ 'model_file': 'Wizard-Vicuna-7B-Uncensored.ggmlv3.q4_0.bin', │ │ │ │ │ │ 'model_type': 'llama', │ │ │ │ │ │ 'config': {'context_length': 1024, 'local_files_only': False} │ │ │ │ │ }, │ │ │ │ │ 'huggingface': { │ │ │ │ │ │ 'model': 'TheBloke/Wizard-Vicuna-7B-Uncensored-HF', │ │ │ │ │ │ 'pipeline_kwargs': {'max_new_tokens': 256} │ │ │ │ │ }, │ │ │ │ │ 'gptq': { │ │ │ │ │ │ 'model': 'TheBloke/Wizard-Vicuna-7B-Uncensored-GPTQ', │ │ │ │ │ │ 'model_file': │ │ │ │ 'Wizard-Vicuna-7B-Uncensored-GPTQ-4bit-128g.no-act-order.safetensors', │ │ │ │ │ │ 'pipeline_kwargs': {'max_new_tokens': 256} │ │ │ │ │ }, │ │ │ │ │ 'download': True, │ │ │ │ │ 'host': 'localhost', │ │ │ │ │ 'port': 5000, │ │ │ │ │ 'auth': False, │ │ │ │ │ 'chroma': { │ │ │ │ │ │ 'persist_directory': 'db', │ │ │ │ │ │ 'chroma_db_impl': 'duckdb+parquet', │ │ │ │ │ │ 'anonymized_telemetry': False │ │ │ │ │ }, │ │ │ │ │ ... +1 │ │ │ │ } │ │ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │ │ │ │ /Users/-/Library/Python/3.9/lib/python/site-packages/chatdocs/llms.py:73 in get_llm │ │ │ │ 70 │ if config["llm"] == "ctransformers": │ │ 71 │ │ config = {config["ctransformers"]} │ │ 72 │ │ config = merge(config, {"config": {"local_files_only": local_files_only}}) │ │ ❱ 73 │ │ llm = CTransformers(callbacks=callbacks, config) │ │ 74 │ elif config["llm"] == "gptq": │ │ 75 │ │ llm = get_gptq_llm(config) │ │ 76 │ else: │ │ │ │ ╭─────────────────────────────────────── locals ───────────────────────────────────────╮ │ │ │ callback = None │ │ │ │ CallbackHandler = <class 'chatdocs.llms.get_llm..CallbackHandler'> │ │ │ │ callbacks = None │ │ │ │ config = { │ │ │ │ │ 'model': 'TheBloke/Wizard-Vicuna-7B-Uncensored-GGML', │ │ │ │ │ 'model_file': 'Wizard-Vicuna-7B-Uncensored.ggmlv3.q4_0.bin', │ │ │ │ │ 'model_type': 'llama', │ │ │ │ │ 'config': { │ │ │ │ │ │ 'context_length': 1024, │ │ │ │ │ │ 'local_files_only': False │ │ │ │ │ } │ │ │ │ } │ │ │ │ local_files_only = False │ │ │ ╰──────────────────────────────────────────────────────────────────────────────────────╯ │ │ │ │ /Users/-/Library/Python/3.9/lib/python/site-packages/langchain/load/serializable.py:74 │ │ in init │ │ │ │ 71 │ _lc_kwargs = PrivateAttr(default_factory=dict) │ │ 72 │ │ │ 73 │ def init(self, kwargs: Any) -> None: │ │ ❱ 74 │ │ super().init(**kwargs) │ │ 75 │ │ self._lc_kwargs = kwargs │ │ 76 │ │ │ 77 │ def to_json(self) -> Union[SerializedConstructor, SerializedNotImplemented]: │ │ │ │ ╭─────────────────────────────────── locals ────────────────────────────────────╮ │ │ │ class = <class 'langchain.load.serializable.Serializable'> │ │ │ │ kwargs = { │ │ │ │ │ 'callbacks': None, │ │ │ │ │ 'model': 'TheBloke/Wizard-Vicuna-7B-Uncensored-GGML', │ │ │ │ │ 'model_file': 'Wizard-Vicuna-7B-Uncensored.ggmlv3.q4_0.bin', │ │ │ │ │ 'model_type': 'llama', │ │ │ │ │ 'config': { │ │ │ │ │ │ 'context_length': 1024, │ │ │ │ │ │ 'local_files_only': False │ │ │ │ │ } │ │ │ │ } │ │ │ │ self = CTransformers() │ │ │ ╰───────────────────────────────────────────────────────────────────────────────╯ │ │ │ │ /Users/-/Desktop/chatdocs/pydantic/main.py:339 in pydantic.main.BaseModel.init │ │ │ │ [Errno 2] No such file or directory: '/Users/-/Desktop/chatdocs/pydantic/main.py' │ │ │ │ /Users/-/Desktop/chatdocs/pydantic/main.py:1102 in pydantic.main.validate_model │ │ │ │ [Errno 2] No such file or directory: '/Users/-/Desktop/chatdocs/pydantic/main.py' │ │ │ │ /Users/-/Library/Python/3.9/lib/python/site-packages/langchain/llms/ctransformers.py:73 │ │ in validate_environment │ │ │ │ 70 │ │ │ ) │ │ 71 │ │ │ │ 72 │ │ config = values["config"] or {} │ │ ❱ 73 │ │ values["client"] = AutoModelForCausalLM.from_pretrained( │ │ 74 │ │ │ values["model"], │ │ 75 │ │ │ model_type=values["model_type"], │ │ 76 │ │ │ model_file=values["model_file"], │ │ │ │ ╭──────────────────────────────────────── locals ─────────────────────────────────────────╮ │ │ │ AutoModelForCausalLM = <class 'ctransformers.hub.AutoModelForCausalLM'> │ │ │ │ cls = <class 'langchain.llms.ctransformers.CTransformers'> │ │ │ │ config = {'context_length': 1024, 'local_files_only': False} │ │ │ │ values = { │ │ │ │ │ 'cache': None, │ │ │ │ │ 'verbose': False, │ │ │ │ │ 'callbacks': None, │ │ │ │ │ 'callback_manager': None, │ │ │ │ │ 'tags': None, │ │ │ │ │ 'metadata': None, │ │ │ │ │ 'client': None, │ │ │ │ │ 'model': 'TheBloke/Wizard-Vicuna-7B-Uncensored-GGML', │ │ │ │ │ 'model_type': 'llama', │ │ │ │ │ 'model_file': 'Wizard-Vicuna-7B-Uncensored.ggmlv3.q4_0.bin', │ │ │ │ │ ... +2 │ │ │ │ } │ │ │ ╰─────────────────────────────────────────────────────────────────────────────────────────╯ │ │ │ │ /Users/-/Library/Python/3.9/lib/python/site-packages/ctransformers/hub.py:157 in │ │ from_pretrained │ │ │ │ 154 │ │ │ │ local_files_only=local_files_only, │ │ 155 │ │ │ ) │ │ 156 │ │ │ │ ❱ 157 │ │ return LLM( │ │ 158 │ │ │ model_path=model_path, │ │ 159 │ │ │ model_type=model_type, │ │ 160 │ │ │ config=config.config, │ │ │ │ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │ │ │ cls = <class 'ctransformers.hub.AutoModelForCausalLM'> │ │ │ │ config = AutoConfig( │ │ │ │ │ config=Config( │ │ │ │ │ │ top_k=40, │ │ │ │ │ │ top_p=0.95, │ │ │ │ │ │ temperature=0.8, │ │ │ │ │ │ repetition_penalty=1.1, │ │ │ │ │ │ last_n_tokens=64, │ │ │ │ │ │ seed=-1, │ │ │ │ │ │ batch_size=8, │ │ │ │ │ │ threads=-1, │ │ │ │ │ │ max_new_tokens=256, │ │ │ │ │ │ stop=None, │ │ │ │ │ │ stream=False, │ │ │ │ │ │ reset=True, │ │ │ │ │ │ context_length=1024, │ │ │ │ │ │ gpu_layers=0 │ │ │ │ │ ), │ │ │ │ │ model_type=None │ │ │ │ ) │ │ │ │ kwargs = {'context_length': 1024} │ │ │ │ lib = None │ │ │ │ local_files_only = False │ │ │ │ model_file = 'Wizard-Vicuna-7B-Uncensored.ggmlv3.q4_0.bin' │ │ │ │ model_path = '/Users/-/.cache/huggingface/hub/models--TheBloke--Wizard-V… │ │ │ │ model_path_or_repo_id = 'TheBloke/Wizard-Vicuna-7B-Uncensored-GGML' │ │ │ │ model_type = 'llama' │ │ │ │ path_type = 'repo' │ │ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │ │ │ │ /Users/-/Library/Python/3.9/lib/python/site-packages/ctransformers/llm.py:206 in │ │ init │ │ │ │ 203 │ │ if not Path(model_path).is_file(): │ │ 204 │ │ │ raise ValueError(f"Model path '{model_path}' doesn't exist.") │ │ 205 │ │ │ │ ❱ 206 │ │ self._lib = load_library(lib, cuda=config.gpu_layers > 0) │ │ 207 │ │ self._llm = self._lib.ctransformers_llm_create( │ │ 208 │ │ │ model_path.encode(), │ │ 209 │ │ │ model_type.encode(), │ │ │ │ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │ │ │ config = Config( │ │ │ │ │ top_k=40, │ │ │ │ │ top_p=0.95, │ │ │ │ │ temperature=0.8, │ │ │ │ │ repetition_penalty=1.1, │ │ │ │ │ last_n_tokens=64, │ │ │ │ │ seed=-1, │ │ │ │ │ batch_size=8, │ │ │ │ │ threads=-1, │ │ │ │ │ max_new_tokens=256, │ │ │ │ │ stop=None, │ │ │ │ │ stream=False, │ │ │ │ │ reset=True, │ │ │ │ │ context_length=1024, │ │ │ │ │ gpu_layers=0 │ │ │ │ ) │ │ │ │ lib = None │ │ │ │ model_path = '/Users/-/.cache/huggingface/hub/models--TheBloke--Wizard-Vicuna-7B-Un… │ │ │ │ model_type = 'llama' │ │ │ │ self = <ctransformers.llm.LLM object at 0x287252d00> │ │ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │ │ │ │ /Users/-/Library/Python/3.9/lib/python/site-packages/ctransformers/llm.py:101 in │ │ load_library │ │ │ │ 98 │ if hasattr(os, "add_dll_directory") and "CUDA_PATH" in os.environ: │ │ 99 │ │ os.add_dll_directory(os.path.join(os.environ["CUDA_PATH"], "bin")) │ │ 100 │ │ │ ❱ 101 │ path = find_library(path, cuda=cuda) │ │ 102 │ lib = CDLL(path) │ │ 103 │ │ │ 104 │ lib.ctransformers_llm_create.argtypes = [ │ │ │ │ ╭─── locals ───╮ │ │ │ cuda = False │ │ │ │ path = None │ │ │ ╰──────────────╯ │ │ │ │ /Users/-/Library/Python/3.9/lib/python/site-packages/ctransformers/lib.py:23 in │ │ find_library │ │ │ │ 20 │ │ else: │ │ 21 │ │ │ from cpuinfo import get_cpu_info │ │ 22 │ │ │ │ │ ❱ 23 │ │ │ flags = get_cpu_info()["flags"] │ │ 24 │ │ │ │ │ 25 │ │ │ if "avx2" in flags: │ │ 26 │ │ │ │ path = "avx2" │ │ │ │ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │ │ │ cuda = False │ │ │ │ get_cpu_info = <function get_cpu_info at 0x287262670> │ │ │ │ lib_directory = PosixPath('/Users/-/Library/Python/3.9/lib/python/site-packages/ctr… │ │ │ │ path = None │ │ │ │ system = 'Darwin' │ │ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ KeyError: 'flags'

marella commented 1 year ago

This is fixed now. Please update ctransformers and try again:

pip install 'ctransformers>=0.2.17'