Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -11,6 +11,25 @@ MAX_MAX_NEW_TOKENS = 2048
|
|
11 |
DEFAULT_MAX_NEW_TOKENS = 1024
|
12 |
MAX_INPUT_TOKEN_LENGTH = int(os.getenv("MAX_INPUT_TOKEN_LENGTH", "4096"))
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
if torch.cuda.is_available():
|
15 |
model_id = "meta-llama/Llama-2-13b-chat-hf"
|
16 |
model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto", load_in_4bit=True)
|
@@ -114,5 +133,11 @@ chat_interface = gr.ChatInterface(
|
|
114 |
cache_examples=False,
|
115 |
)
|
116 |
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
if __name__ == "__main__":
|
118 |
-
demo.queue(max_size=20).launch()
|
|
|
11 |
DEFAULT_MAX_NEW_TOKENS = 1024
|
12 |
MAX_INPUT_TOKEN_LENGTH = int(os.getenv("MAX_INPUT_TOKEN_LENGTH", "4096"))
|
13 |
|
14 |
+
DESCRIPTION = """\
|
15 |
+
# Llama-2 13B Chat
|
16 |
+
This Space demonstrates model [Llama-2-13b-chat](https://huggingface.co/meta-llama/Llama-2-13b-chat) by Meta, a Llama 2 model with 13B parameters fine-tuned for chat instructions. Feel free to play with it, or duplicate to run generations without a queue! If you want to run your own service, you can also [deploy the model on Inference Endpoints](https://huggingface.co/inference-endpoints).
|
17 |
+
🔎 For more details about the Llama 2 family of models and how to use them with `transformers`, take a look [at our blog post](https://huggingface.co/blog/llama2).
|
18 |
+
🔨 Looking for an even more powerful model? Check out the large [**70B** model demo](https://huggingface.co/spaces/ysharma/Explore_llamav2_with_TGI).
|
19 |
+
🐇 For a smaller model that you can run on many GPUs, check our [7B model demo](https://huggingface.co/spaces/huggingface-projects/llama-2-7b-chat).
|
20 |
+
"""
|
21 |
+
|
22 |
+
LICENSE = """
|
23 |
+
<p/>
|
24 |
+
---
|
25 |
+
As a derivate work of [Llama-2-13b-chat](https://huggingface.co/meta-llama/Llama-2-13b-chat) by Meta,
|
26 |
+
this demo is governed by the original [license](https://huggingface.co/spaces/huggingface-projects/llama-2-13b-chat/blob/main/LICENSE.txt) and [acceptable use policy](https://huggingface.co/spaces/huggingface-projects/llama-2-13b-chat/blob/main/USE_POLICY.md).
|
27 |
+
"""
|
28 |
+
|
29 |
+
if not torch.cuda.is_available():
|
30 |
+
DESCRIPTION += "\n<p>Running on CPU 🥶 This demo does not work on CPU.</p>"
|
31 |
+
|
32 |
+
|
33 |
if torch.cuda.is_available():
|
34 |
model_id = "meta-llama/Llama-2-13b-chat-hf"
|
35 |
model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto", load_in_4bit=True)
|
|
|
133 |
cache_examples=False,
|
134 |
)
|
135 |
|
136 |
+
with gr.Blocks(css="style.css", fill_height=True) as demo:
|
137 |
+
gr.Markdown(DESCRIPTION)
|
138 |
+
gr.DuplicateButton(value="Duplicate Space for private use", elem_id="duplicate-button")
|
139 |
+
chat_interface.render()
|
140 |
+
gr.Markdown(LICENSE)
|
141 |
+
|
142 |
if __name__ == "__main__":
|
143 |
+
demo.queue(max_size=20).launch()
|