Spaces:
Sleeping
Sleeping
xavierbarbier
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -24,11 +24,21 @@ Mistral does not support system prompt symbol (such as ```<<SYS>>```) now, input
|
|
24 |
[Model From TheBloke/Mistral-7B-Instruct-v0.1-GGUF](https://huggingface.co/TheBloke/Mistral-7B-Instruct-v0.1-GGUF)
|
25 |
[Mistral-instruct-v0.1 System prompt](https://docs.mistral.ai/usage/guardrailing)
|
26 |
"""
|
27 |
-
|
28 |
model_path = "models"
|
29 |
model_name = "SmolLM-1.7B-Instruct.Q2_K.gguf"
|
30 |
|
31 |
hf_hub_download(repo_id="mradermacher/SmolLM-1.7B-Instruct-GGUF", filename=model_name, local_dir=model_path, local_dir_use_symlinks=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
print("Start the model init process")
|
34 |
model = model = GPT4All(model_name, model_path, allow_download = False, device="cpu")
|
@@ -100,10 +110,16 @@ def qa(question):
|
|
100 |
Given the context information and not prior knowledge, answer the query.
|
101 |
Query: {question}
|
102 |
Answer:
|
103 |
-
|
|
|
104 |
max_new_tokens = 2048
|
105 |
-
outputs = model.generate(prompt=prompt, temp=0.5, top_k = 40, top_p = 1, max_tokens = max_new_tokens)
|
106 |
-
|
|
|
|
|
|
|
|
|
|
|
107 |
|
108 |
|
109 |
with gr.Blocks() as demo:
|
|
|
24 |
[Model From TheBloke/Mistral-7B-Instruct-v0.1-GGUF](https://huggingface.co/TheBloke/Mistral-7B-Instruct-v0.1-GGUF)
|
25 |
[Mistral-instruct-v0.1 System prompt](https://docs.mistral.ai/usage/guardrailing)
|
26 |
"""
|
27 |
+
"""
|
28 |
model_path = "models"
|
29 |
model_name = "SmolLM-1.7B-Instruct.Q2_K.gguf"
|
30 |
|
31 |
hf_hub_download(repo_id="mradermacher/SmolLM-1.7B-Instruct-GGUF", filename=model_name, local_dir=model_path, local_dir_use_symlinks=False)
|
32 |
+
"""
|
33 |
+
|
34 |
+
|
35 |
+
import torch
|
36 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
37 |
+
|
38 |
+
|
39 |
+
model_name = "croissantllm/CroissantLLMBase"
|
40 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
41 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16, device_map="auto")
|
42 |
|
43 |
print("Start the model init process")
|
44 |
model = model = GPT4All(model_name, model_path, allow_download = False, device="cpu")
|
|
|
110 |
Given the context information and not prior knowledge, answer the query.
|
111 |
Query: {question}
|
112 |
Answer:
|
113 |
+
"""
|
114 |
+
"""
|
115 |
max_new_tokens = 2048
|
116 |
+
outputs = model.generate(prompt=prompt, temp=0.5, top_k = 40, top_p = 1, max_tokens = max_new_tokens)"""
|
117 |
+
|
118 |
+
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
119 |
+
tokens = model.generate(**inputs, max_length=100, do_sample=True, top_p=0.95, top_k=60, temperature=0.3)
|
120 |
+
|
121 |
+
|
122 |
+
return tokenizer.decode(tokens[0])
|
123 |
|
124 |
|
125 |
with gr.Blocks() as demo:
|