Spaces:
Running
Running
Commit
·
71b8d91
1
Parent(s):
8ddee2d
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,7 @@ import gradio as gr
|
|
| 4 |
import torch
|
| 5 |
torch.set_num_threads(1)
|
| 6 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 7 |
-
from typing import Optional, Union, List, Dict, Any
|
| 8 |
import random
|
| 9 |
import time
|
| 10 |
import datetime
|
|
@@ -31,6 +31,10 @@ from typing import List
|
|
| 31 |
import numpy as np
|
| 32 |
import tensorflow_hub as hub
|
| 33 |
import tensorflow_text
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
|
| 36 |
class Encoder(ABC):
|
|
@@ -52,11 +56,7 @@ class MUSEEncoder(Encoder):
|
|
| 52 |
return embeds
|
| 53 |
|
| 54 |
|
| 55 |
-
from dataclasses import dataclass
|
| 56 |
-
from typing import Dict, List, Tuple
|
| 57 |
|
| 58 |
-
import numpy as np
|
| 59 |
-
import tensorflow as tf
|
| 60 |
|
| 61 |
|
| 62 |
@dataclass
|
|
@@ -132,7 +132,6 @@ model = AutoModelForCausalLM.from_pretrained(
|
|
| 132 |
offload_folder="./",
|
| 133 |
low_cpu_mem_usage=True,
|
| 134 |
)
|
| 135 |
-
model=torch.compile(model)
|
| 136 |
tokenizer = AutoTokenizer.from_pretrained("facebook/xglm-7.5B")
|
| 137 |
|
| 138 |
|
|
@@ -294,6 +293,21 @@ with gr.Blocks(height=900) as demo:
|
|
| 294 |
verbose=True,
|
| 295 |
memory=ConversationBufferWindowMemory(k=2),
|
| 296 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 297 |
with gr.Tab("Text Generation"):
|
| 298 |
with gr.Row():
|
| 299 |
with gr.Column():
|
|
|
|
| 4 |
import torch
|
| 5 |
torch.set_num_threads(1)
|
| 6 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 7 |
+
from typing import Optional, Union, List, Dict, Any, Tuple
|
| 8 |
import random
|
| 9 |
import time
|
| 10 |
import datetime
|
|
|
|
| 31 |
import numpy as np
|
| 32 |
import tensorflow_hub as hub
|
| 33 |
import tensorflow_text
|
| 34 |
+
from dataclasses import dataclass
|
| 35 |
+
|
| 36 |
+
import numpy as np
|
| 37 |
+
import tensorflow as tf
|
| 38 |
|
| 39 |
|
| 40 |
class Encoder(ABC):
|
|
|
|
| 56 |
return embeds
|
| 57 |
|
| 58 |
|
|
|
|
|
|
|
| 59 |
|
|
|
|
|
|
|
| 60 |
|
| 61 |
|
| 62 |
@dataclass
|
|
|
|
| 132 |
offload_folder="./",
|
| 133 |
low_cpu_mem_usage=True,
|
| 134 |
)
|
|
|
|
| 135 |
tokenizer = AutoTokenizer.from_pretrained("facebook/xglm-7.5B")
|
| 136 |
|
| 137 |
|
|
|
|
| 293 |
verbose=True,
|
| 294 |
memory=ConversationBufferWindowMemory(k=2),
|
| 295 |
)
|
| 296 |
+
gr.Markdown(
|
| 297 |
+
"""
|
| 298 |
+
# 🐘 WangChanGLM v0.2 demo
|
| 299 |
+
|
| 300 |
+
[Blog](https://medium.com/@iwishcognitivedissonance/wangchanglm-the-thai-turned-multilingual-instruction-following-model-7aa9a0f51f5f) | [Codes](https://github.com/pythainlp/wangchanglm) | [Demo](https://colab.research.google.com/github/pythainlp/WangChanGLM/blob/main/demo/WangChanGLM_v0_1_demo.ipynb)
|
| 301 |
+
|
| 302 |
+

|
| 303 |
+
|
| 304 |
+
|
| 305 |
+
This demo use CPU only, so It may be slow or very slow. If you want the speed, try [Google colab](https://colab.research.google.com/github/pythainlp/WangChanGLM/blob/main/demo/WangChanGLM_v0_1_demo.ipynb).
|
| 306 |
+
|
| 307 |
+
|
| 308 |
+
**We do not guarantee a reply message.**
|
| 309 |
+
"""
|
| 310 |
+
)
|
| 311 |
with gr.Tab("Text Generation"):
|
| 312 |
with gr.Row():
|
| 313 |
with gr.Column():
|