Ritesh-hf commited on
Commit
300a0db
1 Parent(s): b1184c5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -13
app.py CHANGED
@@ -58,16 +58,14 @@ def initialize_pinecone(index_name: str):
58
  ##################################################
59
 
60
  # Initialize Pinecone index and BM25 encoder
61
- pinecone_index = initialize_pinecone("uae-national-library-and-archives-vectorstore")
62
- bm25 = BM25Encoder().load("./UAE-NLA.json")
63
 
64
  ##################################################
65
  ##################################################
66
 
67
- # old_embed_model = HuggingFaceEmbeddings(model_name="sentence-transformers/gte-multilingual-base")
68
-
69
  # Initialize models and retriever
70
- embed_model = HuggingFaceEmbeddings(model_name="Alibaba-NLP/gte-multilingual-base", model_kwargs={"trust_remote_code":True})
71
  retriever = PineconeHybridSearchRetriever(
72
  embeddings=embed_model,
73
  sparse_encoder=bm25,
@@ -95,13 +93,13 @@ contextualize_q_prompt = ChatPromptTemplate.from_messages(
95
  history_aware_retriever = create_history_aware_retriever(llm, retriever, contextualize_q_prompt)
96
 
97
  # QA system prompt and chain
98
- qa_system_prompt = """You are a highly skilled information retrieval assistant. Use the following context to answer questions effectively. \
99
- If you don't know the answer, simply state that you don't know. \
100
  Your answer should be in {language} language. \
101
  Provide answers in proper HTML format and keep them concise. \
102
  When responding to queries, follow these guidelines: \
103
  1. Provide Clear Answers: \
104
- - Based on the language of the question, you have to answer in that language. E.g. if the question is in English language then answer in the English language or if the question is in Arabic language then you should answer in Arabic language. /
105
  - Ensure the response directly addresses the query with accurate and relevant information.\
106
  2. Include Detailed References: \
107
  - Links to Sources: Include URLs to credible sources where users can verify information or explore further. \
@@ -110,14 +108,14 @@ When responding to queries, follow these guidelines: \
110
 
111
  3. Formatting for Readability: \
112
  - The answer should be in a proper HTML format with appropriate tags. \
113
- - For arabic language response align the text to right and convert numbers also.
114
- - Double check if the language of answer is correct or not.
115
- - Use bullet points or numbered lists where applicable to present information clearly. \
116
  - Highlight key details using bold or italics. \
117
- - Provide proper and meaningful abbreviations for urls. Do not include naked urls. \
118
 
119
  4. Organize Content Logically: \
120
- - Structure the content in a logical order, ensuring easy navigation and understanding for the user. \
121
 
122
  {context}
123
  """
 
58
  ##################################################
59
 
60
  # Initialize Pinecone index and BM25 encoder
61
+ pinecone_index = initialize_pinecone("updated-uae-nla")
62
+ bm25 = BM25Encoder().load("./updated-uae-nla.json")
63
 
64
  ##################################################
65
  ##################################################
66
 
 
 
67
  # Initialize models and retriever
68
+ embed_model = HuggingFaceEmbeddings(model_name="jinaai/jina-embeddings-v3", model_kwargs={"trust_remote_code":True})
69
  retriever = PineconeHybridSearchRetriever(
70
  embeddings=embed_model,
71
  sparse_encoder=bm25,
 
93
  history_aware_retriever = create_history_aware_retriever(llm, retriever, contextualize_q_prompt)
94
 
95
  # QA system prompt and chain
96
+ qa_system_prompt = """ You are a highly skilled information retrieval assistant. Use the following context to answer questions effectively. \
97
+ If you don't know the answer, state that you don't know. \
98
  Your answer should be in {language} language. \
99
  Provide answers in proper HTML format and keep them concise. \
100
  When responding to queries, follow these guidelines: \
101
  1. Provide Clear Answers: \
102
+ - Based on the language of the question, you have to answer in that language. E.g. if the question is in the English language then answer in the English language or if the question is in Arabic language then you should answer in Arabic language. /
103
  - Ensure the response directly addresses the query with accurate and relevant information.\
104
  2. Include Detailed References: \
105
  - Links to Sources: Include URLs to credible sources where users can verify information or explore further. \
 
108
 
109
  3. Formatting for Readability: \
110
  - The answer should be in a proper HTML format with appropriate tags. \
111
+ - For Arabic language response align the text to the right and convert numbers.
112
+ - Double-check if the language of the answer is correct or not.
113
+ - Use bullet points or numbered lists where applicable to present information. \
114
  - Highlight key details using bold or italics. \
115
+ - Provide proper and meaningful abbreviations for URLs. Do not include naked URLs. \
116
 
117
  4. Organize Content Logically: \
118
+ - Structure the content logically, ensuring easy navigation and understanding for the user. \
119
 
120
  {context}
121
  """