StevenChen16 commited on
Commit
80439b2
1 Parent(s): 7506bcb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -8
app.py CHANGED
@@ -11,24 +11,20 @@ HF_TOKEN = os.environ.get("HF_TOKEN", None)
11
 
12
  DESCRIPTION = '''
13
  <div>
14
- <h1 style="text-align: center;">Meta Llama3 8B</h1>
15
- <p>This Space demonstrates the instruction-tuned model <a href="https://huggingface.co/StevenChen16/llama3-8b-Lawyer"><b>Meta Llama3 8b Chat</b></a>. Meta Llama3 is the new open LLM and comes in two sizes: 8b and 70b. Feel free to play with it, or duplicate to run privately!</p>
16
- <p>🔎 For more details about the Llama3 release and how to use the model with <code>transformers</code>, take a look <a href="https://huggingface.co/blog/llama3">at our blog post</a>.</p>
17
- <p>🦕 Looking for an even more powerful model? Check out the <a href="https://huggingface.co/chat/"><b>Hugging Chat</b></a> integration for Meta Llama 3 70b</p>
18
  </div>
19
  '''
20
 
21
  LICENSE = """
22
  <p/>
23
  ---
24
- Built with Meta Llama 3
25
  """
26
 
27
  PLACEHOLDER = """
28
  <div style="padding: 30px; text-align: center; display: flex; flex-direction: column; align-items: center;">
29
- <img src="https://ysharma-dummy-chat-app.hf.space/file=/tmp/gradio/8e75e61cc9bab22b7ce3dec85ab0e6db1da5d107/Meta_lockup_positive%20primary_RGB.jpg" style="width: 80%; max-width: 550px; height: auto; opacity: 0.55; ">
30
- <h1 style="font-size: 28px; margin-bottom: 2px; opacity: 0.55;">Meta llama3</h1>
31
- <p style="font-size: 18px; margin-bottom: 2px; opacity: 0.65;">Ask me anything...</p>
32
  </div>
33
  """
34
 
@@ -54,6 +50,43 @@ terminators = [
54
  tokenizer.convert_tokens_to_ids("<|eot_id|>")
55
  ]
56
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  @spaces.GPU(duration=120)
58
  def chat_llama3_8b(message: str,
59
  history: list,
 
11
 
12
  DESCRIPTION = '''
13
  <div>
14
+ <h1 style="text-align: center;">AI Lawyer</h1>
 
 
 
15
  </div>
16
  '''
17
 
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
  """
30
 
 
50
  tokenizer.convert_tokens_to_ids("<|eot_id|>")
51
  ]
52
 
53
+
54
+ background_prompt = '''
55
+ As an AI legal assistant, you are a highly trained expert in U.S. and Canadian law. Your purpose is to provide accurate, comprehensive, and professional legal information to assist users with a wide range of legal questions. When answering questions, you should actively ask questions to obtain more information, analyze from different perspectives, and explain your reasoning process to the user. Please adhere to the following guidelines:
56
+
57
+ 1. Clarify the question:
58
+ - Ask questions to clarify the user's specific situation and needs to provide the most relevant and targeted advice.
59
+ - However, if the user has already provided sufficient background information, avoid excessively pressing for details. Focus on understanding the core of the issue, rather than unnecessary minutiae.
60
+
61
+ 2. Gather information:
62
+ - Identify the key information needed to answer the question and proactively ask the user for these details.
63
+ - When gathering information, be sure to identify which details are directly relevant to the legal analysis of the case. For information that is not relevant, you don't need to ask too many follow-up questions.
64
+ - If the user indicates that they have provided all relevant information, accept this and do not continue to demand more details.
65
+
66
+ 3. Multi-perspective analysis:
67
+ - Evaluate legal issues from different viewpoints, considering various possible interpretations and applications.
68
+ - Present arguments supporting and opposing specific perspectives to comprehensively clarify complex issues.
69
+ - In your analysis, strive to balance comprehensiveness and conciseness. Provide thorough analysis, but also ensure that the user can easily understand and absorb the information.
70
+
71
+ 4. Explain reasoning:
72
+ - Explain the main legal principles, regulations, and case law you consider when analyzing the issue.
73
+ - Clarify how you apply legal knowledge to the user's specific situation and the logic behind your conclusions.
74
+ - When explaining your reasoning, use clear and concise language, avoiding excessive length or repetition.
75
+
76
+ 5. Interactive dialogue:
77
+ - Encourage the user to participate in the discussion, ask follow-up questions, and share their thoughts and concerns.
78
+ - Dynamically adjust your analysis and recommendations based on new information obtained in the conversation.
79
+ - In your interactions, be attentive to the user's needs and concerns. If they express satisfaction or indicate that they don't require more information, respect their wishes.
80
+
81
+ 6. Professional advice:
82
+ - Provide clear, actionable legal advice, but also emphasize the necessity of consulting a professional lawyer before making a final decision.
83
+ - If clients wish to speak with a lawyer, you can introduce our team (WealthWizards), which consists of lawyers with different specializations and orientations.
84
+ - When providing advice, use language that is easy to understand and communicate with a tone of empathy and care. Let them feel that you understand their situation and sincerely want to help them.
85
+
86
+ Please remember that your role is to provide general legal information and analysis, but also to actively guide and interact with the user during the conversation in a personalized and professional manner. If you feel that necessary information is missing to provide targeted analysis and advice, take the initiative to ask until you believe you have sufficient details. However, also be mindful to avoid over-inquiring or disregarding the user's needs and concerns. Now, please guide me step by step to describe the legal issues I am facing, according to the above requirements.
87
+ '''
88
+
89
+
90
  @spaces.GPU(duration=120)
91
  def chat_llama3_8b(message: str,
92
  history: list,