Spaces:
Runtime error
Runtime error
StevenChen16
commited on
Commit
•
1041d8d
1
Parent(s):
d7c1a74
Update UI
Browse files
app.py
CHANGED
@@ -9,7 +9,7 @@ HF_TOKEN = os.environ.get("HF_TOKEN", None)
|
|
9 |
|
10 |
DESCRIPTION = '''
|
11 |
<div>
|
12 |
-
<h1 style="text-align: center;">
|
13 |
<p>This Space demonstrates the instruction-tuned model <a href="https://huggingface.co/StevenChen16/llama3-8b-Lawyer"><b>StevenChen16 Llama3 8B Lawyer</b></a>. This model is fine-tuned to provide legal advice based on US and Canada law.</p>
|
14 |
<p>Feel free to play with it, or duplicate to run privately!</p>
|
15 |
</div>
|
@@ -18,12 +18,12 @@ DESCRIPTION = '''
|
|
18 |
LICENSE = """
|
19 |
<p/>
|
20 |
---
|
21 |
-
Built with StevenChen16
|
22 |
"""
|
23 |
|
24 |
PLACEHOLDER = """
|
25 |
<div style="padding: 30px; text-align: center; display: flex; flex-direction: column; align-items: center;">
|
26 |
-
<h1 style="font-size: 28px; margin-bottom: 2px; opacity: 0.55;">
|
27 |
<p style="font-size: 18px; margin-bottom: 2px; opacity: 0.65;">Ask me anything about US and Canada law...</p>
|
28 |
</div>
|
29 |
"""
|
@@ -60,12 +60,12 @@ You are an advanced AI legal assistant trained to assist with a wide range of le
|
|
60 |
5. **Professional Tone**: Maintain a professional and respectful tone in all responses. Ensure that your advice is legally sound and adheres to ethical standards.
|
61 |
"""
|
62 |
|
63 |
-
def query_model(user_input, history
|
64 |
combined_query = background_prompt + user_input
|
65 |
messages = [{"role": "user", "content": combined_query}]
|
66 |
|
67 |
response = ""
|
68 |
-
for new_text in chat_model.stream_chat(messages):
|
69 |
response += new_text
|
70 |
yield response
|
71 |
|
@@ -78,20 +78,16 @@ with gr.Blocks(css=css) as demo:
|
|
78 |
gr.ChatInterface(
|
79 |
fn=query_model,
|
80 |
chatbot=chatbot,
|
81 |
-
additional_inputs=[
|
82 |
-
gr.Slider(minimum=0, maximum=1, step=0.1, value=0.95, label="Temperature"),
|
83 |
-
gr.Slider(minimum=128, maximum=4096, step=1, value=512, label="Max new tokens"),
|
84 |
-
],
|
85 |
examples=[
|
86 |
-
['
|
87 |
-
['
|
88 |
-
['
|
89 |
-
['
|
90 |
-
['
|
91 |
],
|
92 |
cache_examples=False,
|
93 |
)
|
94 |
gr.Markdown(LICENSE)
|
95 |
|
96 |
if __name__ == "__main__":
|
97 |
-
demo.launch(
|
|
|
9 |
|
10 |
DESCRIPTION = '''
|
11 |
<div>
|
12 |
+
<h1 style="text-align: center;">AI Lawyer</h1>
|
13 |
<p>This Space demonstrates the instruction-tuned model <a href="https://huggingface.co/StevenChen16/llama3-8b-Lawyer"><b>StevenChen16 Llama3 8B Lawyer</b></a>. This model is fine-tuned to provide legal advice based on US and Canada law.</p>
|
14 |
<p>Feel free to play with it, or duplicate to run privately!</p>
|
15 |
</div>
|
|
|
18 |
LICENSE = """
|
19 |
<p/>
|
20 |
---
|
21 |
+
Built with model "StevenChen16/Llama3-8B-Lawyer", based on "meta-llama/Meta-Llama-3-8B"
|
22 |
"""
|
23 |
|
24 |
PLACEHOLDER = """
|
25 |
<div style="padding: 30px; text-align: center; display: flex; flex-direction: column; align-items: center;">
|
26 |
+
<h1 style="font-size: 28px; margin-bottom: 2px; opacity: 0.55;">AI Lawyer</h1>
|
27 |
<p style="font-size: 18px; margin-bottom: 2px; opacity: 0.65;">Ask me anything about US and Canada law...</p>
|
28 |
</div>
|
29 |
"""
|
|
|
60 |
5. **Professional Tone**: Maintain a professional and respectful tone in all responses. Ensure that your advice is legally sound and adheres to ethical standards.
|
61 |
"""
|
62 |
|
63 |
+
def query_model(user_input, history):
|
64 |
combined_query = background_prompt + user_input
|
65 |
messages = [{"role": "user", "content": combined_query}]
|
66 |
|
67 |
response = ""
|
68 |
+
for new_text in chat_model.stream_chat(messages, max_new_tokens=512, temperature=0.9):
|
69 |
response += new_text
|
70 |
yield response
|
71 |
|
|
|
78 |
gr.ChatInterface(
|
79 |
fn=query_model,
|
80 |
chatbot=chatbot,
|
|
|
|
|
|
|
|
|
81 |
examples=[
|
82 |
+
['What are the key differences between a sole proprietorship and a partnership?'],
|
83 |
+
['What legal steps should I take if I want to start a business in the US?'],
|
84 |
+
['Can you explain the concept of "duty of care" in negligence law?'],
|
85 |
+
['What are the legal requirements for obtaining a patent in Canada?'],
|
86 |
+
['How can I protect my intellectual property when sharing my idea with potential investors?']
|
87 |
],
|
88 |
cache_examples=False,
|
89 |
)
|
90 |
gr.Markdown(LICENSE)
|
91 |
|
92 |
if __name__ == "__main__":
|
93 |
+
demo.launch()
|