ariG23498 HF Staff commited on
Commit
60dd2dc
·
verified ·
1 Parent(s): e8e8ea7

Upload jinaai_jina-reranker-v3_0.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. jinaai_jina-reranker-v3_0.py +31 -0
jinaai_jina-reranker-v3_0.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # /// script
2
+ # requires-python = ">=3.12"
3
+ # dependencies = [
4
+ # "torch",
5
+ # "torchvision",
6
+ # "transformers",
7
+ # "accelerate",
8
+ # "peft",
9
+ # ]
10
+ # ///
11
+
12
+ try:
13
+ # Load model directly
14
+ from transformers import AutoTokenizer, AutoModel
15
+
16
+ tokenizer = AutoTokenizer.from_pretrained("jinaai/jina-reranker-v3", trust_remote_code=True)
17
+ model = AutoModel.from_pretrained("jinaai/jina-reranker-v3", trust_remote_code=True)
18
+ with open('jinaai_jina-reranker-v3_0.txt', 'w') as f:
19
+ f.write('Everything was good in jinaai_jina-reranker-v3_0.txt')
20
+ except Exception as e:
21
+ with open('jinaai_jina-reranker-v3_0.txt', 'w') as f:
22
+ import traceback
23
+ traceback.print_exc(file=f)
24
+ finally:
25
+ from huggingface_hub import upload_file
26
+ upload_file(
27
+ path_or_fileobj='jinaai_jina-reranker-v3_0.txt',
28
+ repo_id='model-metadata/custom_code_execution_files',
29
+ path_in_repo='jinaai_jina-reranker-v3_0.txt',
30
+ repo_type='dataset',
31
+ )