Views
No views yet
1%pip install llama-index-embeddings-huggingface
2%pip install llama-index-llms-llama-cpp
3!pip install llama-index325
4
5from llama_index.core import SimpleDirectoryReader, VectorStoreIndex
6from llama_index.llms.llama_cpp import LlamaCPP
7from llama_index.llms.llama_cpp.llama_utils import (
8 messages_to_prompt,
9 completion_to_prompt,
10)
11
12model_url = "https://huggingface.co/LeroyDyer/Mixtral_BaseModel-gguf/resolve/main/mixtral_basemodel.q8_0.gguf"
13
14llm = LlamaCPP(
15 # You can pass in the URL to a GGML model to download it automatically
16 model_url=model_url,
17 # optionally, you can set the path to a pre-downloaded model instead of model_url
18 model_path=None,
19 temperature=0.1,
20 max_new_tokens=256,
21 # llama2 has a context window of 4096 tokens, but we set it lower to allow for some wiggle room
22 context_window=3900,
23 # kwargs to pass to __call__()
24 generate_kwargs={},
25 # kwargs to pass to __init__()
26 # set to at least 1 to use GPU
27 model_kwargs={"n_gpu_layers": 1},
28 # transform inputs into Llama2 format
29 messages_to_prompt=messages_to_prompt,
30 completion_to_prompt=completion_to_prompt,
31 verbose=True,
32)
33
34prompt = input("Enter your prompt: ")
35response = llm.complete(prompt)
36print(response.text)