Spaces:
Sleeping
Sleeping
switched to hf_hub_download
Browse files- .gitignore +2 -1
- backend.py +23 -1
- requirements.txt +3 -1
.gitignore
CHANGED
@@ -1 +1,2 @@
|
|
1 |
-
/myenv
|
|
|
|
1 |
+
/myenv
|
2 |
+
__pycache__/
|
backend.py
CHANGED
@@ -8,6 +8,27 @@ import gradio as gr
|
|
8 |
from llama_index.core import ChatPromptTemplate
|
9 |
from llama_index.core import Settings, VectorStoreIndex, SimpleDirectoryReader, PromptTemplate, load_index_from_storage
|
10 |
from llama_index.core.node_parser import SentenceSplitter
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
|
13 |
model_id = "google/gemma-2-2b-it"
|
@@ -19,7 +40,8 @@ model = AutoModelForCausalLM.from_pretrained(
|
|
19 |
)
|
20 |
# what models will be used by LlamaIndex:
|
21 |
Settings.embed_model = InstructorEmbedding(model_name="hkunlp/instructor-base")
|
22 |
-
Settings.llm = GemmaLLMInterface(model=model, tokenizer=tokenizer)
|
|
|
23 |
|
24 |
|
25 |
############################---------------------------------
|
|
|
8 |
from llama_index.core import ChatPromptTemplate
|
9 |
from llama_index.core import Settings, VectorStoreIndex, SimpleDirectoryReader, PromptTemplate, load_index_from_storage
|
10 |
from llama_index.core.node_parser import SentenceSplitter
|
11 |
+
from huggingface_hub import hf_hub_download
|
12 |
+
from llama_cpp import Llama
|
13 |
+
|
14 |
+
|
15 |
+
huggingface_token = os.getenv("HUGGINGFACE_TOKEN")
|
16 |
+
|
17 |
+
|
18 |
+
hf_hub_download(
|
19 |
+
repo_id="google/gemma-2-2b-it-GGUF",
|
20 |
+
filename="2b_it_v2.gguf",
|
21 |
+
local_dir="./models",
|
22 |
+
token=huggingface_token
|
23 |
+
)
|
24 |
+
|
25 |
+
llm = Llama(
|
26 |
+
model_path=f"models/{"2b_it_v2.gguf"}",
|
27 |
+
#flash_attn=True,
|
28 |
+
#_gpu_layers=81,
|
29 |
+
n_batch=1024,
|
30 |
+
n_ctx=8192,
|
31 |
+
)
|
32 |
|
33 |
|
34 |
model_id = "google/gemma-2-2b-it"
|
|
|
40 |
)
|
41 |
# what models will be used by LlamaIndex:
|
42 |
Settings.embed_model = InstructorEmbedding(model_name="hkunlp/instructor-base")
|
43 |
+
#Settings.llm = GemmaLLMInterface(model=model, tokenizer=tokenizer)
|
44 |
+
Settings.llm = llm
|
45 |
|
46 |
|
47 |
############################---------------------------------
|
requirements.txt
CHANGED
@@ -7,4 +7,6 @@ sentence-transformers==2.2.2
|
|
7 |
llama-index-readers-web
|
8 |
llama-index-readers-file
|
9 |
gradio
|
10 |
-
transformers
|
|
|
|
|
|
7 |
llama-index-readers-web
|
8 |
llama-index-readers-file
|
9 |
gradio
|
10 |
+
transformers
|
11 |
+
llama-cpp-agent>=0.2.25
|
12 |
+
setuptools
|