Spaces:
Sleeping
Sleeping
AFischer1985
commited on
Commit
•
7357b62
1
Parent(s):
f7d0635
Update run.py
Browse files
run.py
CHANGED
@@ -5,18 +5,25 @@
|
|
5 |
# Last update: October 15th, 2024
|
6 |
#############################################################################
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
dbPath="/home/af/Schreibtisch/Code/gradio/BERUFENET/db"
|
9 |
if(os.path.exists(dbPath)==False): dbPath="/home/user/app/db"
|
10 |
|
11 |
print(dbPath)
|
12 |
|
|
|
13 |
# Chroma-DB
|
14 |
#-----------
|
15 |
|
16 |
-
import chromadb
|
17 |
-
from chromadb import Documents, EmbeddingFunction, Embeddings
|
18 |
-
import torch # chromaDB
|
19 |
-
from transformers import AutoTokenizer, AutoModel # chromaDB
|
20 |
jina = AutoModel.from_pretrained('jinaai/jina-embeddings-v2-base-de', trust_remote_code=True, torch_dtype=torch.bfloat16)
|
21 |
#jira.save_pretrained("jinaai_jina-embeddings-v2-base-de")
|
22 |
device='cuda:0' if torch.cuda.is_available() else 'cpu'
|
@@ -33,14 +40,12 @@ client = chromadb.PersistentClient(path=path)
|
|
33 |
print(client.heartbeat())
|
34 |
print(client.get_version())
|
35 |
print(client.list_collections())
|
36 |
-
from chromadb.utils import embedding_functions
|
37 |
#default_ef = embedding_functions.DefaultEmbeddingFunction()
|
38 |
#sentence_transformer_ef = embedding_functions.SentenceTransformerEmbeddingFunction(model_name="T-Systems-onsite/cross-en-de-roberta-sentence-transformer")
|
39 |
#instructor_ef = embedding_functions.InstructorEmbeddingFunction(model_name="hkunlp/instructor-large", device="cuda")
|
40 |
jina_ef=JinaEmbeddingFunction()
|
41 |
embeddingFunction=jina_ef
|
42 |
print(str(client.list_collections()))
|
43 |
-
|
44 |
|
45 |
global collection
|
46 |
if("name=BerufenetDB1" in str(client.list_collections())):
|
@@ -54,10 +59,6 @@ print(collection.count())
|
|
54 |
# Gradio-GUI
|
55 |
#------------
|
56 |
|
57 |
-
from huggingface_hub import InferenceClient
|
58 |
-
import gradio as gr
|
59 |
-
import json
|
60 |
-
|
61 |
myModel="mistralai/Mixtral-8x7B-Instruct-v0.1"
|
62 |
|
63 |
def format_prompt(message, history):
|
|
|
5 |
# Last update: October 15th, 2024
|
6 |
#############################################################################
|
7 |
|
8 |
+
import os
|
9 |
+
import chromadb
|
10 |
+
from chromadb import Documents, EmbeddingFunction, Embeddings
|
11 |
+
from chromadb.utils import embedding_functions
|
12 |
+
import torch # chromaDB
|
13 |
+
from transformers import AutoTokenizer, AutoModel # chromaDB
|
14 |
+
from huggingface_hub import InferenceClient # Gradio-Interface
|
15 |
+
import gradio as gr # Gradio-Interface
|
16 |
+
import json # Gradio-Interface
|
17 |
+
|
18 |
dbPath="/home/af/Schreibtisch/Code/gradio/BERUFENET/db"
|
19 |
if(os.path.exists(dbPath)==False): dbPath="/home/user/app/db"
|
20 |
|
21 |
print(dbPath)
|
22 |
|
23 |
+
|
24 |
# Chroma-DB
|
25 |
#-----------
|
26 |
|
|
|
|
|
|
|
|
|
27 |
jina = AutoModel.from_pretrained('jinaai/jina-embeddings-v2-base-de', trust_remote_code=True, torch_dtype=torch.bfloat16)
|
28 |
#jira.save_pretrained("jinaai_jina-embeddings-v2-base-de")
|
29 |
device='cuda:0' if torch.cuda.is_available() else 'cpu'
|
|
|
40 |
print(client.heartbeat())
|
41 |
print(client.get_version())
|
42 |
print(client.list_collections())
|
|
|
43 |
#default_ef = embedding_functions.DefaultEmbeddingFunction()
|
44 |
#sentence_transformer_ef = embedding_functions.SentenceTransformerEmbeddingFunction(model_name="T-Systems-onsite/cross-en-de-roberta-sentence-transformer")
|
45 |
#instructor_ef = embedding_functions.InstructorEmbeddingFunction(model_name="hkunlp/instructor-large", device="cuda")
|
46 |
jina_ef=JinaEmbeddingFunction()
|
47 |
embeddingFunction=jina_ef
|
48 |
print(str(client.list_collections()))
|
|
|
49 |
|
50 |
global collection
|
51 |
if("name=BerufenetDB1" in str(client.list_collections())):
|
|
|
59 |
# Gradio-GUI
|
60 |
#------------
|
61 |
|
|
|
|
|
|
|
|
|
62 |
myModel="mistralai/Mixtral-8x7B-Instruct-v0.1"
|
63 |
|
64 |
def format_prompt(message, history):
|