Upload README.md
Browse files
README.md
CHANGED
@@ -30,27 +30,51 @@ The dataset encompasses a diverse range of topics, representing various aspects
|
|
30 |
This model can be utilized for various NLP tasks such as text generation, summarization, translation, and more. Due to its comprehensive training on a vast corpus, it promises accurate and contextually relevant outputs, especially for tasks related to the Serbian language.
|
31 |
|
32 |
|
33 |
-
### Decryption the Model:
|
34 |
|
|
|
|
|
|
|
35 |
from cryptography.fernet import Fernet
|
36 |
-
import torch
|
37 |
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
cipher_suite = Fernet(key)
|
40 |
|
41 |
-
decryption_data = '
|
42 |
|
43 |
try:
|
44 |
with open(decryption_data, 'rb') as file:
|
45 |
encrypted_data = file.read()
|
46 |
|
47 |
decrypted_data = cipher_suite.decrypt(encrypted_data)
|
48 |
-
|
49 |
with open(decryption_data, 'wb') as file:
|
50 |
file.write(decrypted_data)
|
51 |
|
52 |
-
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
54 |
|
55 |
# Now you can use the Serbian-GPT-2 model for further operations...
|
56 |
|
|
|
30 |
This model can be utilized for various NLP tasks such as text generation, summarization, translation, and more. Due to its comprehensive training on a vast corpus, it promises accurate and contextually relevant outputs, especially for tasks related to the Serbian language.
|
31 |
|
32 |
|
33 |
+
### Download and Decryption the Model:
|
34 |
|
35 |
+
import os
|
36 |
+
import requests
|
37 |
+
from transformers import GPT2LMHeadModel
|
38 |
from cryptography.fernet import Fernet
|
|
|
39 |
|
40 |
+
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
|
41 |
+
|
42 |
+
print("\nDownload Serbian-GPT-2 model...")
|
43 |
+
|
44 |
+
# Download Serbian-GPT-2 model
|
45 |
+
model_name = 'edukom/Serbian-GPT-2'
|
46 |
+
base_url = f'https://huggingface.co/{model_name}/resolve/main/'
|
47 |
+
files_to_download = ['added_tokens.json', 'config.json', 'generation_config.json', 'merges.txt', 'pytorch_model.bin', 'special_tokens_map.json', 'tokenizer.json', 'tokenizer_config.json', 'vocab.json']
|
48 |
+
|
49 |
+
cache_dir = 'path/to/where/you/want/to/store/the/model'
|
50 |
+
|
51 |
+
for file in files_to_download:
|
52 |
+
response = requests.get(base_url + file)
|
53 |
+
with open(os.path.join(cache_dir, file), 'wb') as f:
|
54 |
+
f.write(response.content)
|
55 |
+
|
56 |
+
# Decryption pytorch_model.bin
|
57 |
+
key = input("\nEnter the decryption key: ").encode()
|
58 |
cipher_suite = Fernet(key)
|
59 |
|
60 |
+
decryption_data = os.path.join(cache_dir, 'pytorch_model.bin')
|
61 |
|
62 |
try:
|
63 |
with open(decryption_data, 'rb') as file:
|
64 |
encrypted_data = file.read()
|
65 |
|
66 |
decrypted_data = cipher_suite.decrypt(encrypted_data)
|
67 |
+
|
68 |
with open(decryption_data, 'wb') as file:
|
69 |
file.write(decrypted_data)
|
70 |
|
71 |
+
# Loading Serbian-GPT-2 model
|
72 |
+
model = GPT2LMHeadModel.from_pretrained(cache_dir)
|
73 |
+
print("\nCongratulations, the Serbian-GPT-2 model is ready for use ヅ\n")
|
74 |
+
|
75 |
+
except Exception as e:
|
76 |
+
print(f"\nError during decryption: {e}")
|
77 |
+
print("\nYou can decrypt the model by contacting the author of this model who will add the key, email: info@edukom.rs")
|
78 |
|
79 |
# Now you can use the Serbian-GPT-2 model for further operations...
|
80 |
|