prabinpanta0 commited on
Commit
2e16305
1 Parent(s): 49effef

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -6
app.py CHANGED
@@ -15,11 +15,35 @@ login(HF_TOKEN, add_to_git_credential=True)
15
  # Create the pipeline for text generation using the specified model
16
  pipe = pipeline("text-generation", model="distilbert/distilgpt2", token=HF_TOKEN)
17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  def generate(text):
19
  try:
 
 
 
20
  # Generate the response using the pipeline
21
- responses = pipe(text, max_length=1024, num_return_sequences=1)
22
- response_text = responses[0]['generated_text']
 
23
  return response_text if response_text else "No valid response generated."
24
 
25
  except Exception as e:
@@ -29,15 +53,13 @@ iface = gr.Interface(
29
  fn=generate,
30
  inputs=gr.Textbox(lines=2, placeholder="Enter text here..."),
31
  outputs="text",
32
- title="Chuunibyou Text Generator",
33
- description="Transform text into an elaborate and formal style with a nobleman tone.",
34
  live=False
35
  )
36
 
37
  def launch_custom_interface():
38
  iface.launch()
39
- with gr.TabbedInterface(fn=generate, inputs=gr.Textbox(lines=2, placeholder="Enter text here..."), outputs=gr.HTML(label="Output")) as ti:
40
- ti.add(custom_html)
41
 
42
  if __name__ == "__main__":
43
  launch_custom_interface()
 
15
  # Create the pipeline for text generation using the specified model
16
  pipe = pipeline("text-generation", model="distilbert/distilgpt2", token=HF_TOKEN)
17
 
18
+ # Define the initial prompt for the system
19
+ system_prompt = """
20
+ You are an AI model designed to provide concise information about big data analytics across various fields without mentioning the question. Respond with a focused, one-line answer that captures the essence of the key risk, benefit, or trend associated with the topic.
21
+
22
+ input: What do you consider the most significant risk of over-reliance on big data analytics in stock market risk management?
23
+ output: Increased market volatility.
24
+
25
+ input: What is a major benefit of big data analytics in healthcare?
26
+ output: Enhanced patient care through personalized treatment.
27
+
28
+ input: What is a key challenge of big data analytics in retail?
29
+ output: Maintaining data privacy and security.
30
+
31
+ input: What is a primary advantage of big data analytics in manufacturing?
32
+ output: Improved production efficiency and predictive maintenance.
33
+
34
+ input: What is a significant risk associated with big data analytics in education?
35
+ output: Potential widening of the achievement gap if data is not used equitably.
36
+ """
37
+
38
  def generate(text):
39
  try:
40
+ # Combine the system prompt with the user's input
41
+ prompt = system_prompt + f"\ninput: {text}\noutput:"
42
+
43
  # Generate the response using the pipeline
44
+ responses = pipe(prompt, max_length=1024, num_return_sequences=1)
45
+ response_text = responses[0]['generated_text'].split("output:")[-1].strip()
46
+
47
  return response_text if response_text else "No valid response generated."
48
 
49
  except Exception as e:
 
53
  fn=generate,
54
  inputs=gr.Textbox(lines=2, placeholder="Enter text here..."),
55
  outputs="text",
56
+ title="Big Data Analytics Assistant",
57
+ description="Provides concise information about big data analytics across various fields.",
58
  live=False
59
  )
60
 
61
  def launch_custom_interface():
62
  iface.launch()
 
 
63
 
64
  if __name__ == "__main__":
65
  launch_custom_interface()