Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,32 +1,23 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
)
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
<|im_start|>assistant""",
|
25 |
-
]
|
26 |
-
|
27 |
-
for chat in prompts:
|
28 |
-
print(chat)
|
29 |
-
input_ids = tokenizer(chat, return_tensors="pt").input_ids.to("cuda")
|
30 |
-
generated_ids = model.generate(input_ids, max_new_tokens=750, temperature=0.8, repetition_penalty=1.1, do_sample=True, eos_token_id=tokenizer.eos_token_id)
|
31 |
-
response = tokenizer.decode(generated_ids[0][input_ids.shape[-1]:], skip_special_tokens=True, clean_up_tokenization_space=True)
|
32 |
-
print(f"Response: {response}")
|
|
|
1 |
+
from ctransformers import AutoModelForCausalLM
|
2 |
+
|
3 |
+
|
4 |
+
# Set gpu_layers to the number of layers to offload to GPU. Set to 0 if no GPU acceleration is available on your system.
|
5 |
+
#llm = AutoModelForCausalLM.from_pretrained("TheBloke/Mistral-7B-OpenOrca-GGUF", model_file="mistral-7b-openorca.Q4_K_M.gguf", model_type="mistral", gpu_layers=50)
|
6 |
+
|
7 |
+
|
8 |
+
#llm = AutoModelForCausalLM.from_pretrained("Open-Orca/Mistral-7B-OpenOrca",gpu_layers=0, max_new_tokens = 1000, context_length = 10000)
|
9 |
+
|
10 |
+
llm = AutoModelForCausalLM.from_pretrained("NousResearch/Nous-Hermes-2-Mistral-7B-DPO.Q4_0.gguf",gpu_layers=0, max_new_tokens = 500, context_length = 2048)
|
11 |
+
# llm = AutoModelForCausalLM.from_pretrained("/home/ubuntu/.cache/gpt4all/Nous-Hermes-2-Mistral-7B-DPO.Q4_0.gguf",gpu_layers=0, max_new_tokens = 500, context_length = 6000)
|
12 |
+
|
13 |
+
|
14 |
+
|
15 |
+
|
16 |
+
|
17 |
+
#llm = AutoModelForCausalLM.from_pretrained("TheBloke/zephyr-7B-beta-GGUF",model_file="zephyr-7b-beta.Q5_K_M.gguf", model_type="mistral",gpu_layers=0, max_new_tokens = 1000, context_length = 6000)
|
18 |
+
|
19 |
+
contenuto="che ore sono?"
|
20 |
+
print(contenuto)
|
21 |
+
|
22 |
+
if __name__ == '__main__':
|
23 |
+
print(llm(contenuto,threads=16,temperature=0.7,top_k=40,top_p=0.4,repetition_penalty=1.18))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|