Spaces:
Sleeping
Sleeping
hf llm
Browse files- backend.py +12 -7
- requirements.txt +1 -0
backend.py
CHANGED
@@ -17,7 +17,7 @@ from IPython.display import Markdown, display
|
|
17 |
from langchain_huggingface import HuggingFaceEmbeddings
|
18 |
|
19 |
#from llama_index import LangchainEmbedding, ServiceContext
|
20 |
-
from llama_index.embeddings.huggingface import HuggingFaceEmbedding
|
21 |
from llama_index.llms.huggingface import HuggingFaceInferenceAPI, HuggingFaceLLM
|
22 |
from dotenv import load_dotenv
|
23 |
|
@@ -71,13 +71,18 @@ llm = HuggingFaceLLM(
|
|
71 |
|
72 |
embed_model= HuggingFaceEmbeddings(model_name="sentence-transformers/all-mpnet-base-v2")
|
73 |
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
|
|
|
|
79 |
documents = SimpleDirectoryReader('data/blockchainprova.txt').load_data()
|
80 |
-
|
|
|
|
|
|
|
81 |
|
82 |
|
83 |
|
|
|
17 |
from langchain_huggingface import HuggingFaceEmbeddings
|
18 |
|
19 |
#from llama_index import LangchainEmbedding, ServiceContext
|
20 |
+
#from llama_index.embeddings.huggingface import HuggingFaceEmbedding
|
21 |
from llama_index.llms.huggingface import HuggingFaceInferenceAPI, HuggingFaceLLM
|
22 |
from dotenv import load_dotenv
|
23 |
|
|
|
71 |
|
72 |
embed_model= HuggingFaceEmbeddings(model_name="sentence-transformers/all-mpnet-base-v2")
|
73 |
|
74 |
+
Settings.llm = llm
|
75 |
+
Settings.embed_model = embed_model
|
76 |
+
#Settings.node_parser = SentenceSplitter(chunk_size=512, chunk_overlap=20, paragraph_separator="\n\n")
|
77 |
+
Settings.num_output = 512
|
78 |
+
Settings.context_window = 3900
|
79 |
+
|
80 |
+
|
81 |
documents = SimpleDirectoryReader('data/blockchainprova.txt').load_data()
|
82 |
+
|
83 |
+
nodes = SentenceSplitter(chunk_size=512, chunk_overlap=20, paragraph_separator="\n\n").get_nodes_from_documents(documents)
|
84 |
+
# Build the vector store index from the nodes
|
85 |
+
index = VectorStoreIndex(nodes)
|
86 |
|
87 |
|
88 |
|
requirements.txt
CHANGED
@@ -9,6 +9,7 @@ sentence_transformers
|
|
9 |
llama-index-readers-web
|
10 |
llama-index-readers-file
|
11 |
llama-index-embeddings-langchain
|
|
|
12 |
pypdf
|
13 |
langchain>=0.2.3
|
14 |
langchain-community
|
|
|
9 |
llama-index-readers-web
|
10 |
llama-index-readers-file
|
11 |
llama-index-embeddings-langchain
|
12 |
+
|
13 |
pypdf
|
14 |
langchain>=0.2.3
|
15 |
langchain-community
|