Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -5,7 +5,7 @@ import time
|
|
5 |
from langchain import PromptTemplate
|
6 |
from langchain.llms import OpenAI
|
7 |
from langchain.chat_models import ChatOpenAI
|
8 |
-
from langchain.embeddings import HuggingFaceEmbeddings
|
9 |
from langchain.vectorstores import Pinecone
|
10 |
from langchain.chains import LLMChain
|
11 |
from langchain.chains.question_answering import load_qa_chain
|
@@ -27,10 +27,11 @@ PINECONE_INDEX = os.environ.get("PINECONE_INDEX", '3gpp-r16')
|
|
27 |
PINECONE_LINK = "[Pinecone](https://www.pinecone.io)"
|
28 |
LANGCHAIN_LINK = "[LangChain](https://python.langchain.com/en/latest/index.html)"
|
29 |
|
30 |
-
EMBEDDING_MODEL = os.environ.get("
|
|
|
31 |
|
32 |
# return top-k text chunks from vector store
|
33 |
-
TOP_K_DEFAULT =
|
34 |
TOP_K_MAX = 30
|
35 |
SCORE_DEFAULT = 0.3
|
36 |
|
@@ -122,11 +123,11 @@ Question:
|
|
122 |
{question}
|
123 |
|
124 |
Optinal:
|
125 |
-
|
126 |
|
127 |
Desired format:
|
128 |
Clause/figure name: <dot_separated_numbers>
|
129 |
-
TS name: [\w\.]
|
130 |
|
131 |
Answer:"""
|
132 |
)
|
@@ -171,7 +172,7 @@ def init_model(api_key, emb_name, db_api_key, db_env, db_index):
|
|
171 |
if not (emb_name and db_api_key and db_env and db_index):
|
172 |
return api_key,MODEL_DONE+DOCS_NULL,llm_dict,None,None,None
|
173 |
|
174 |
-
embeddings =
|
175 |
|
176 |
pinecone.init(api_key = db_api_key,
|
177 |
environment = db_env)
|
|
|
5 |
from langchain import PromptTemplate
|
6 |
from langchain.llms import OpenAI
|
7 |
from langchain.chat_models import ChatOpenAI
|
8 |
+
from langchain.embeddings import HuggingFaceEmbeddings, HuggingFaceInstructEmbeddings
|
9 |
from langchain.vectorstores import Pinecone
|
10 |
from langchain.chains import LLMChain
|
11 |
from langchain.chains.question_answering import load_qa_chain
|
|
|
27 |
PINECONE_LINK = "[Pinecone](https://www.pinecone.io)"
|
28 |
LANGCHAIN_LINK = "[LangChain](https://python.langchain.com/en/latest/index.html)"
|
29 |
|
30 |
+
EMBEDDING_MODEL = os.environ.get("EMBEDDING_MODEL", "hkunlp/instructor-large")
|
31 |
+
EMBEDDING_LOADER = HuggingFaceInstructEmbeddings
|
32 |
|
33 |
# return top-k text chunks from vector store
|
34 |
+
TOP_K_DEFAULT = 7
|
35 |
TOP_K_MAX = 30
|
36 |
SCORE_DEFAULT = 0.3
|
37 |
|
|
|
123 |
{question}
|
124 |
|
125 |
Optinal:
|
126 |
+
Expand clause/figure name with corresponding metadata TS name in the answer.
|
127 |
|
128 |
Desired format:
|
129 |
Clause/figure name: <dot_separated_numbers>
|
130 |
+
TS name: ^[\w\.]$
|
131 |
|
132 |
Answer:"""
|
133 |
)
|
|
|
172 |
if not (emb_name and db_api_key and db_env and db_index):
|
173 |
return api_key,MODEL_DONE+DOCS_NULL,llm_dict,None,None,None
|
174 |
|
175 |
+
embeddings = EMBEDDING_LOADER(model_name=emb_name)
|
176 |
|
177 |
pinecone.init(api_key = db_api_key,
|
178 |
environment = db_env)
|