hegelai / prompttools

Open-source tools for prompt testing and experimentation, with support for both LLMs (e.g. OpenAI, LLaMA) and vector databases (e.g. Chroma, Weaviate, LanceDB).
http://prompttools.readthedocs.io
Apache License 2.0
2.55k stars 216 forks source link

ModuleNotFoundError: Package `llama-cpp-python` is required to be installed to use this experiment #109

Closed shrijayan closed 7 months ago

shrijayan commented 7 months ago

⁉️ Discussion/Question

Suggested : Please use pip install llama-cpp-python to install the package

I am encountering difficulties installing the llama-cpp-python package in Google Colab using the command pip install llama-cpp-python. Despite following the installation instructions, the package does not seem to be recognized. This issue is hindering my ability to proceed with the experiment.

ModuleNotFoundError                       Traceback (most recent call last)
.ipynb Cell 3 line 1
      9 temperatures = [0.0, 1.0]
     11 call_params = dict(temperature=temperatures)
---> 13 experiment = LlamaCppExperiment(model_paths, prompts, call_params=call_params)

File ~/anaconda3/envs/llm_testing/lib/python3.10/site-packages/prompttools/experiment/experiments/llama_cpp_experiment.py:107, in LlamaCppExperiment.__init__(self, model_path, prompt, model_params, call_params)
     99 def __init__(
    100     self,
    101     model_path: List[str],
   (...)
    104     call_params: Dict[str, list[object]] = {},
    105 ):
    106     if Llama is None:
--> 107         raise ModuleNotFoundError(
    108             "Package `llama-cpp-python` is required to be installed to use this experiment."
    109             "Please use `pip install llama-cpp-python` to install the package"
    110         )
    111     self.completion_fn = self.llama_completion_fn
    112     self.model_params = model_params
NivekT commented 7 months ago

Can you run ! pip list | grep llama to make sure llama-cpp-python is installed?

shrijayan commented 7 months ago

Can you run ! pip list | grep llama to make sure llama-cpp-python is installed?

287717793-f8f313ca-bb6a-45e2-8fc7-6a981b26aa96
NivekT commented 7 months ago

Can you run from llama_cpp import Llama and see if that executes?

Do you have multiple llama_cpp in your namespace?

NivekT commented 7 months ago

I just created a fresh Colab notebook/environment, and running the following works:

! pip install prompttools
! pip install llama-cpp-python

Then,

from prompttools.experiment import LlamaCppExperiment

exp = LlamaCppExperiment(["/path"], ["How are you?"]) 

Are you able to re-produce this in a fresh environment?

shrijayan commented 7 months ago

Can you run from llama_cpp import Llama and see if that executes?

Do you have multiple llama_cpp in your namespace?

This is working

shrijayan commented 7 months ago

I just created a fresh Colab notebook/environment, and running the following works:

! pip install prompttools
! pip install llama-cpp-python

Then,

from prompttools.experiment import LlamaCppExperiment

exp = LlamaCppExperiment(["/path"], ["How are you?"]) 

Are you able to re-produce this in a fresh environment?

This is working

I think I tried to install prompttools from the command from the docs # !pip install --quiet --force-reinstall prompttools from the link https://github.com/hegelai/prompttools/blob/main/examples/notebooks/LlamaHeadToHead.ipynb

but I think we need to install like

! pip install prompttools ! pip install llama-cpp-python

After this it started working

image

but the next step experiment.run() gives error

NivekT commented 7 months ago

Your model paths may be wrong. Can you verify the path in the system and your string are identical?

shrijayan commented 7 months ago

Your model paths may be wrong. Can you verify the path in the system and your string are identical?

Your solution is perfect my model file name was llama-2-7b.ggmlv.q4_0.bin?download=true after changing that to llama-2-7b.ggmlv.q4_0.bin there was no issue

NivekT commented 7 months ago

Glad to hear it. I will close this issue. Feel free to re-open if other things come up.

shrijayan commented 7 months ago

FOR PUBLIC

ISSUE 1 :

⁉️ Discussion/Question

Suggested : Please use pip install llama-cpp-python to install the package

I am encountering difficulties installing the llama-cpp-python package in Google Colab using the command pip install llama-cpp-python. Despite following the installation instructions, the package does not seem to be recognized. This issue is hindering my ability to proceed with the experiment.

ModuleNotFoundError                       Traceback (most recent call last)
.ipynb Cell 3 line 1
      9 temperatures = [0.0, 1.0]
     11 call_params = dict(temperature=temperatures)
---> 13 experiment = LlamaCppExperiment(model_paths, prompts, call_params=call_params)

File ~/anaconda3/envs/llm_testing/lib/python3.10/site-packages/prompttools/experiment/experiments/llama_cpp_experiment.py:107, in LlamaCppExperiment.__init__(self, model_path, prompt, model_params, call_params)
     99 def __init__(
    100     self,
    101     model_path: List[str],
   (...)
    104     call_params: Dict[str, list[object]] = {},
    105 ):
    106     if Llama is None:
--> 107         raise ModuleNotFoundError(
    108             "Package `llama-cpp-python` is required to be installed to use this experiment."
    109             "Please use `pip install llama-cpp-python` to install the package"
    110         )
    111     self.completion_fn = self.llama_completion_fn
    112     self.model_params = model_params

SOLUTION :

For this issue don't use notebook's code !pip install --quiet --force-reinstall prompttools USE !pip install prompttools

ISSUE 2 :

I just created a fresh Colab notebook/environment, and running the following works:

! pip install prompttools
! pip install llama-cpp-python

Then,

from prompttools.experiment import LlamaCppExperiment

exp = LlamaCppExperiment(["/path"], ["How are you?"]) 

Are you able to re-produce this in a fresh environment?

This is working

I think I tried to install prompttools from the command from the docs # !pip install --quiet --force-reinstall prompttools from the link https://github.com/hegelai/prompttools/blob/main/examples/notebooks/LlamaHeadToHead.ipynb

but I think we need to install like

! pip install prompttools ! pip install llama-cpp-python

After this it started working image

but the next step experiment.run() gives error

SOLUTION :

We need to check the model name and save the model name correctly.