Spaces:
Build error
Build error
solve custom code issue with workaround
Browse files- langchainapp.py +3 -2
- requirements.txt +1 -1
langchainapp.py
CHANGED
@@ -40,7 +40,8 @@ os.environ['CUDA_LAUNCH_BLOCKING'] = '1'
|
|
40 |
os.environ['CUDA_CACHE_DISABLE'] = '1'
|
41 |
|
42 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
43 |
-
|
|
|
44 |
### Utils
|
45 |
hf_token, yi_token = load_env_variables()
|
46 |
|
@@ -61,7 +62,7 @@ class MyEmbeddingFunction(EmbeddingFunction):
|
|
61 |
self.intention_client = intention_client
|
62 |
self.hf_embeddings = HuggingFaceInstructEmbeddings(
|
63 |
model_name=model_name,
|
64 |
-
model_kwargs={'device': 'cuda' if torch.cuda.is_available() else 'cpu', "trust_remote_code": True},
|
65 |
encode_kwargs={'normalize_embeddings': True}
|
66 |
)
|
67 |
|
|
|
40 |
os.environ['CUDA_CACHE_DISABLE'] = '1'
|
41 |
|
42 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
43 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name, token=token, trust_remote_code=True)
|
44 |
+
nvidiamodel = AutoModel.from_pretrained(model_name, token=token, trust_remote_code=True).to(device)
|
45 |
### Utils
|
46 |
hf_token, yi_token = load_env_variables()
|
47 |
|
|
|
62 |
self.intention_client = intention_client
|
63 |
self.hf_embeddings = HuggingFaceInstructEmbeddings(
|
64 |
model_name=model_name,
|
65 |
+
model_kwargs={'device': 'cuda' if torch.cuda.is_available() else 'cpu'}, #, "trust_remote_code": True},
|
66 |
encode_kwargs={'normalize_embeddings': True}
|
67 |
)
|
68 |
|
requirements.txt
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
huggingface_hub
|
2 |
einops
|
3 |
-
sentence-transformers
|
4 |
torch==2.2.0
|
5 |
transformers
|
6 |
openai
|
|
|
1 |
huggingface_hub
|
2 |
einops
|
3 |
+
sentence-transformers
|
4 |
torch==2.2.0
|
5 |
transformers
|
6 |
openai
|