ppsingh commited on
Commit
16ff9c3
1 Parent(s): 98655e4

Update auditqa/doc_process.py

Browse files
Files changed (1) hide show
  1. auditqa/doc_process.py +3 -1
auditqa/doc_process.py CHANGED
@@ -2,9 +2,11 @@ import glob
2
  import os
3
  from langchain.text_splitter import RecursiveCharacterTextSplitter, SentenceTransformersTokenTextSplitter
4
  from transformers import AutoTokenizer
 
5
  from langchain_community.document_loaders import PyMuPDFLoader
6
  from langchain_community.embeddings import HuggingFaceEmbeddings, HuggingFaceInferenceAPIEmbeddings
7
  from langchain_community.vectorstores import Qdrant
 
8
  #from dotenv import load_dotenv
9
  #load_dotenv()
10
 
@@ -55,7 +57,7 @@ def process_pdf():
55
 
56
 
57
  embeddings = HuggingFaceEmbeddings(
58
- model_kwargs = {'device': 'cpu'},
59
  encode_kwargs = {'normalize_embeddings': True},
60
  model_name="BAAI/bge-small-en-v1.5"
61
  )
 
2
  import os
3
  from langchain.text_splitter import RecursiveCharacterTextSplitter, SentenceTransformersTokenTextSplitter
4
  from transformers import AutoTokenizer
5
+ from torch import cuda
6
  from langchain_community.document_loaders import PyMuPDFLoader
7
  from langchain_community.embeddings import HuggingFaceEmbeddings, HuggingFaceInferenceAPIEmbeddings
8
  from langchain_community.vectorstores import Qdrant
9
+ device = 'cuda' if cuda.is_available() else 'cpu'
10
  #from dotenv import load_dotenv
11
  #load_dotenv()
12
 
 
57
 
58
 
59
  embeddings = HuggingFaceEmbeddings(
60
+ model_kwargs = {'device': device},
61
  encode_kwargs = {'normalize_embeddings': True},
62
  model_name="BAAI/bge-small-en-v1.5"
63
  )