Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- README.md +3 -9
- app.py +49 -0
- requirements.txt +6 -0
- tf_model.h5 +3 -0
README.md
CHANGED
|
@@ -1,12 +1,6 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji: 🐠
|
| 4 |
-
colorFrom: red
|
| 5 |
-
colorTo: purple
|
| 6 |
-
sdk: gradio
|
| 7 |
-
sdk_version: 4.18.0
|
| 8 |
app_file: app.py
|
| 9 |
-
|
|
|
|
| 10 |
---
|
| 11 |
-
|
| 12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: google-flan-t5
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
app_file: app.py
|
| 4 |
+
sdk: gradio
|
| 5 |
+
sdk_version: 3.44.4
|
| 6 |
---
|
|
|
|
|
|
app.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from langchain.prompts import PromptTemplate
|
| 2 |
+
from langchain.llms import CTransformers
|
| 3 |
+
import os
|
| 4 |
+
import gradio as gr
|
| 5 |
+
|
| 6 |
+
def GetLlamaResponse(topic):
|
| 7 |
+
llm = CTransformers(
|
| 8 |
+
model_type="google-flan",
|
| 9 |
+
model="tf_model.h5",
|
| 10 |
+
config={"max_new_tokens": 64, "temperature": 0.75},
|
| 11 |
+
)
|
| 12 |
+
template = """
|
| 13 |
+
You are a helpful assistant
|
| 14 |
+
"""
|
| 15 |
+
prompt = PromptTemplate(
|
| 16 |
+
input_variables=["topic", "word_count", "temperature"],
|
| 17 |
+
template=template,
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
response = llm(
|
| 21 |
+
prompt.format(
|
| 22 |
+
word_count=64,
|
| 23 |
+
temperature=0.4,
|
| 24 |
+
topic=topic,
|
| 25 |
+
)
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
return response
|
| 29 |
+
|
| 30 |
+
inputs_image_url = [
|
| 31 |
+
gr.Textbox(type="text", label="Topic Name"),
|
| 32 |
+
]
|
| 33 |
+
|
| 34 |
+
outputs_result_dict = [
|
| 35 |
+
gr.Textbox(type="text", label="Result"),
|
| 36 |
+
]
|
| 37 |
+
|
| 38 |
+
interface_image_url = gr.Interface(
|
| 39 |
+
fn=GetLlamaResponse,
|
| 40 |
+
inputs=inputs_image_url,
|
| 41 |
+
outputs=outputs_result_dict,
|
| 42 |
+
title="Text Generation",
|
| 43 |
+
cache_examples=False,
|
| 44 |
+
)
|
| 45 |
+
|
| 46 |
+
gr.TabbedInterface(
|
| 47 |
+
[interface_image_url],
|
| 48 |
+
tab_names=['Some inference']
|
| 49 |
+
).queue().launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
sentence-transformers
|
| 2 |
+
uvicorn
|
| 3 |
+
ctransformers
|
| 4 |
+
langchain
|
| 5 |
+
python-box
|
| 6 |
+
gradio
|
tf_model.h5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1e41a6feb46b32caa15dde6cf644fce4fd96614f42a1e69d10b5a4069c89f4ce
|
| 3 |
+
size 3396920920
|