Spaces:
Build error
Build error
Srinivas Tadepalli commited on
Commit ·
5c01019
1
Parent(s): 014beec
Updated file
Browse files
app.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
# Importing necessary modules for embeddings and vector database storage.
|
| 2 |
-
from langchain_huggingface import HuggingFaceEmbeddings
|
| 3 |
from langchain_chroma import Chroma
|
| 4 |
# Importing RunnableLambda for wrapping functions as runnable components.
|
| 5 |
from langchain_core.runnables import RunnableLambda
|
|
@@ -7,7 +6,8 @@ from langchain_core.prompts import PromptTemplate
|
|
| 7 |
from langchain_core.output_parsers import StrOutputParser # to transform the output of an LLM into a more usable format
|
| 8 |
from langchain.schema.runnable import RunnableParallel, RunnablePassthrough
|
| 9 |
# importing HuggingFace model abstraction class from langchain
|
| 10 |
-
from
|
|
|
|
| 11 |
|
| 12 |
import torch
|
| 13 |
import gradio
|
|
@@ -27,14 +27,9 @@ llm = HuggingFaceEndpoint(
|
|
| 27 |
repetition_penalty=1.03, # Slightly penalizes repeated tokens to reduce redundancy in responses.
|
| 28 |
)
|
| 29 |
|
| 30 |
-
#
|
| 31 |
-
embedding = HuggingFaceEmbeddings(
|
| 32 |
-
model_name="mixedbread-ai/mxbai-embed-large-v1", # Using a pre-trained embedding model for text vectorization.
|
| 33 |
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
encode_kwargs={'normalize_embeddings': False} # Disabling normalization to preserve the original embedding scale.
|
| 37 |
-
)
|
| 38 |
|
| 39 |
# Creating a Chroma vector database instance.
|
| 40 |
vectordb = Chroma(
|
|
|
|
| 1 |
# Importing necessary modules for embeddings and vector database storage.
|
|
|
|
| 2 |
from langchain_chroma import Chroma
|
| 3 |
# Importing RunnableLambda for wrapping functions as runnable components.
|
| 4 |
from langchain_core.runnables import RunnableLambda
|
|
|
|
| 6 |
from langchain_core.output_parsers import StrOutputParser # to transform the output of an LLM into a more usable format
|
| 7 |
from langchain.schema.runnable import RunnableParallel, RunnablePassthrough
|
| 8 |
# importing HuggingFace model abstraction class from langchain
|
| 9 |
+
from langchain.llms import HuggingFaceEndpoint
|
| 10 |
+
from sentence_transformers import SentenceTransformer
|
| 11 |
|
| 12 |
import torch
|
| 13 |
import gradio
|
|
|
|
| 27 |
repetition_penalty=1.03, # Slightly penalizes repeated tokens to reduce redundancy in responses.
|
| 28 |
)
|
| 29 |
|
| 30 |
+
# Load the embedding model
|
|
|
|
|
|
|
| 31 |
|
| 32 |
+
embedding = SentenceTransformer("mixedbread-ai/mxbai-embed-large-v1")
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
# Creating a Chroma vector database instance.
|
| 35 |
vectordb = Chroma(
|