Upload 2 files
Browse files- app.py +48 -69
- requirements.txt +17 -0
app.py
CHANGED
|
@@ -1,69 +1,48 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
|
| 50 |
-
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
| 51 |
-
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
| 52 |
-
gr.Slider(
|
| 53 |
-
minimum=0.1,
|
| 54 |
-
maximum=1.0,
|
| 55 |
-
value=0.95,
|
| 56 |
-
step=0.05,
|
| 57 |
-
label="Top-p (nucleus sampling)",
|
| 58 |
-
),
|
| 59 |
-
],
|
| 60 |
-
)
|
| 61 |
-
|
| 62 |
-
with gr.Blocks() as demo:
|
| 63 |
-
with gr.Sidebar():
|
| 64 |
-
gr.LoginButton()
|
| 65 |
-
chatbot.render()
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
if __name__ == "__main__":
|
| 69 |
-
demo.launch()
|
|
|
|
| 1 |
+
{\rtf1\ansi\ansicpg1252\cocoartf2868
|
| 2 |
+
\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fmodern\fcharset0 Courier;}
|
| 3 |
+
{\colortbl;\red255\green255\blue255;\red0\green0\blue255;\red255\green255\blue255;\red0\green0\blue0;
|
| 4 |
+
\red131\green0\blue165;\red15\green112\blue1;\red144\green1\blue18;\red86\green65\blue25;\red0\green0\blue109;
|
| 5 |
+
\red19\green85\blue52;}
|
| 6 |
+
{\*\expandedcolortbl;;\cssrgb\c0\c0\c100000;\cssrgb\c100000\c100000\c100000;\cssrgb\c0\c0\c0;
|
| 7 |
+
\cssrgb\c59216\c13725\c70588;\cssrgb\c0\c50196\c0;\cssrgb\c63922\c8235\c8235;\cssrgb\c41569\c32157\c12941;\cssrgb\c0\c6275\c50196;
|
| 8 |
+
\cssrgb\c6667\c40000\c26667;}
|
| 9 |
+
\paperw11900\paperh16840\margl1440\margr1440\vieww11520\viewh8400\viewkind0
|
| 10 |
+
\deftab720
|
| 11 |
+
\pard\pardeftab720\partightenfactor0
|
| 12 |
+
|
| 13 |
+
\f0\fs28 \cf2 \cb3 \expnd0\expndtw0\kerning0
|
| 14 |
+
\outl0\strokewidth0 \strokec2 %%writefile app.py\cf0 \cb1 \strokec4 \
|
| 15 |
+
\
|
| 16 |
+
\pard\pardeftab720\partightenfactor0
|
| 17 |
+
\cf5 \cb3 \strokec5 import\cf0 \strokec4 gradio \cf5 \strokec5 as\cf0 \strokec4 gr\cb1 \
|
| 18 |
+
\cf5 \cb3 \strokec5 from\cf0 \strokec4 transformers \cf5 \strokec5 import\cf0 \strokec4 pipeline\cb1 \
|
| 19 |
+
\
|
| 20 |
+
\pard\pardeftab720\partightenfactor0
|
| 21 |
+
\cf6 \cb3 \strokec6 # Load the model pipeline\cf0 \cb1 \strokec4 \
|
| 22 |
+
\pard\pardeftab720\partightenfactor0
|
| 23 |
+
\cf0 \cb3 pipe = pipeline(\cf7 \strokec7 "text-generation"\cf0 \strokec4 , model=\cf7 \strokec7 "isaacus/open-australian-legal-llm"\cf0 \strokec4 )\cb1 \
|
| 24 |
+
\
|
| 25 |
+
\pard\pardeftab720\partightenfactor0
|
| 26 |
+
\cf6 \cb3 \strokec6 # Define a function to use the pipeline for text generation\cf0 \cb1 \strokec4 \
|
| 27 |
+
\pard\pardeftab720\partightenfactor0
|
| 28 |
+
\cf2 \cb3 \strokec2 def\cf0 \strokec4 \cf8 \strokec8 generate_text\cf0 \strokec4 (\cf9 \strokec9 prompt\cf0 \strokec4 ):\cb1 \
|
| 29 |
+
\pard\pardeftab720\partightenfactor0
|
| 30 |
+
\cf0 \cb3 outputs = pipe(prompt, max_new_tokens=\cf10 \strokec10 50\cf0 \strokec4 , do_sample=\cf2 \strokec2 True\cf0 \strokec4 , temperature=\cf10 \strokec10 0.7\cf0 \strokec4 )\cb1 \
|
| 31 |
+
\cb3 \cf5 \strokec5 return\cf0 \strokec4 outputs[\cf10 \strokec10 0\cf0 \strokec4 ][\cf7 \strokec7 'generated_text'\cf0 \strokec4 ]\cb1 \
|
| 32 |
+
\
|
| 33 |
+
\pard\pardeftab720\partightenfactor0
|
| 34 |
+
\cf6 \cb3 \strokec6 # Create the Gradio interface\cf0 \cb1 \strokec4 \
|
| 35 |
+
\pard\pardeftab720\partightenfactor0
|
| 36 |
+
\cf0 \cb3 iface = gr.Interface(\cb1 \
|
| 37 |
+
\cb3 fn=generate_text,\cb1 \
|
| 38 |
+
\cb3 inputs=gr.Textbox(lines=\cf10 \strokec10 2\cf0 \strokec4 , placeholder=\cf7 \strokec7 "Enter your prompt here..."\cf0 \strokec4 ),\cb1 \
|
| 39 |
+
\cb3 outputs=\cf7 \strokec7 "text"\cf0 \strokec4 ,\cb1 \
|
| 40 |
+
\cb3 title=\cf7 \strokec7 "Open Australian Legal LLM Chat Interface"\cf0 \strokec4 ,\cb1 \
|
| 41 |
+
\cb3 description=\cf7 \strokec7 "Interact with the Open Australian Legal LLM. Enter a legal question or prompt to get a generated response."\cf0 \cb1 \strokec4 \
|
| 42 |
+
\cb3 )\cb1 \
|
| 43 |
+
\
|
| 44 |
+
\pard\pardeftab720\partightenfactor0
|
| 45 |
+
\cf6 \cb3 \strokec6 # Launch the interface (this will be handled by Hugging Face Spaces when deployed)\cf0 \cb1 \strokec4 \
|
| 46 |
+
\pard\pardeftab720\partightenfactor0
|
| 47 |
+
\cf0 \cb3 iface.launch(share=\cf2 \strokec2 False\cf0 \strokec4 )\cb1 \
|
| 48 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
requirements.txt
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{\rtf1\ansi\ansicpg1252\cocoartf2868
|
| 2 |
+
\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fmodern\fcharset0 Courier;}
|
| 3 |
+
{\colortbl;\red255\green255\blue255;\red0\green0\blue255;\red255\green255\blue255;\red0\green0\blue0;
|
| 4 |
+
}
|
| 5 |
+
{\*\expandedcolortbl;;\cssrgb\c0\c0\c100000;\cssrgb\c100000\c100000\c100000;\cssrgb\c0\c0\c0;
|
| 6 |
+
}
|
| 7 |
+
\paperw11900\paperh16840\margl1440\margr1440\vieww11520\viewh8400\viewkind0
|
| 8 |
+
\deftab720
|
| 9 |
+
\pard\pardeftab720\partightenfactor0
|
| 10 |
+
|
| 11 |
+
\f0\fs28 \cf2 \cb3 \expnd0\expndtw0\kerning0
|
| 12 |
+
\outl0\strokewidth0 \strokec2 %%writefile requirements.txt\cf0 \cb1 \strokec4 \
|
| 13 |
+
\
|
| 14 |
+
\pard\pardeftab720\partightenfactor0
|
| 15 |
+
\cf0 \cb3 gradio\cb1 \
|
| 16 |
+
\cb3 transformers\cb1 \
|
| 17 |
+
}
|