vietexob commited on
Commit
943f351
·
1 Parent(s): b845e1d

Small updates

Browse files
Files changed (2) hide show
  1. app.py +6 -6
  2. phi3_instruct_graph.py +0 -20
app.py CHANGED
@@ -234,17 +234,17 @@ def process_and_visualize(text, progress=gr.Progress()):
234
 
235
  # Example texts in different languages
236
  EXAMPLES = [
237
- [handle_text("""My son Tom, as my direct descendant and John's father, has built a long-standing, companion-like relationship with Brown, significantly influencing each other's growth within the family.
238
- Mary, my maternal grandmother, has imparted unwavering wisdom and love not only to Brown and me but also to Tom and John, and she has maintained a deep familial bond with Jane's mother.
239
- Brown, transcending a mere brotherly relationship, has forged a strong father-child bond with Daniel as his biological father, and with Jane, they have significantly impacted each other's lives through numerous family gatherings, forming a solid connection.
240
- Jane, my cousin, contributes to the family's unity through her informal rapport with Tom, and with Lisa, she shares a special bond that goes beyond ordinary cousin relationships, mutually supporting each other.""")],
 
 
241
 
242
  [handle_text("""Pop star Justin Timberlake, 43, had his driver's license suspended by a New York judge during a virtual
243
  court hearing on August 2, 2024. The suspension follows Timberlake's arrest for driving while intoxicated (DWI)
244
  in Sag Harbor on June 18. Timberlake, who is currently on tour in Europe,
245
  pleaded not guilty to the charges.""")],
246
-
247
- [handle_text("""The family of Azerbaijan President Ilham Aliyev leads a charmed, glamorous life, thanks in part to financial interests in almost every sector of the economy. His wife, Mehriban, comes from the privileged and powerful Pashayev family that owns banks, insurance and construction companies, a television station and a line of cosmetics. She has led the Heydar Aliyev Foundation, Azerbaijan’s pre-eminent charity behind the construction of schools, hospitals and the country’s major sports complex. Their eldest daughter, Leyla, editor of Baku magazine, and her sister, Arzu, have financial stakes in a firm that won rights to mine for gold in the western village of Chovdar and Azerfon, the country’s largest mobile phone business. Arzu is also a significant shareholder in SW Holding, which controls nearly every operation related to Azerbaijan Airlines (“Azal”), from meals to airport taxis. Both sisters and brother Heydar own property in Dubai valued at roughly $75 million in 2010; Heydar is the legal owner of nine luxury mansions in Dubai purchased for some $44 million.""")]
248
  ]
249
 
250
  # Function to preprocess the first example when the app starts
 
234
 
235
  # Example texts in different languages
236
  EXAMPLES = [
237
+ [handle_text("""The family of Azerbaijan President Ilham Aliyev leads a charmed, glamorous life, thanks in part to financial interests in almost every sector of the economy. His wife, Mehriban, comes from the privileged and powerful Pashayev family that owns banks, insurance and construction companies, a television station and a line of cosmetics. She has led the Heydar Aliyev Foundation, Azerbaijan’s pre-eminent charity behind the construction of schools, hospitals and the country’s major sports complex. Their eldest daughter, Leyla, editor of Baku magazine, and her sister, Arzu, have financial stakes in a firm that won rights to mine for gold in the western village of Chovdar and Azerfon, the country’s largest mobile phone business. Arzu is also a significant shareholder in SW Holding, which controls nearly every operation related to Azerbaijan Airlines (“Azal”), from meals to airport taxis. Both sisters and brother Heydar own property in Dubai valued at roughly $75 million in 2010; Heydar is the legal owner of nine luxury mansions in Dubai purchased for some $44 million.""")],
238
+
239
+ [handle_text("""Legendary rock band Aerosmith has officially announced their retirement from touring after 54 years, citing
240
+ lead singer Steven Tyler's unrecoverable vocal cord injury.
241
+ The decision comes after months of unsuccessful treatment for Tyler's fractured larynx,
242
+ which he suffered in September 2023.""")],
243
 
244
  [handle_text("""Pop star Justin Timberlake, 43, had his driver's license suspended by a New York judge during a virtual
245
  court hearing on August 2, 2024. The suspension follows Timberlake's arrest for driving while intoxicated (DWI)
246
  in Sag Harbor on June 18. Timberlake, who is currently on tour in Europe,
247
  pleaded not guilty to the charges.""")],
 
 
248
  ]
249
 
250
  # Function to preprocess the first example when the app starts
phi3_instruct_graph.py CHANGED
@@ -18,27 +18,8 @@ class Phi3InstructGraph:
18
  def __init__(self, model = "EmergentMethods/Phi-3-mini-4k-instruct-graph"):
19
 
20
  self.model_path = model
21
- # self.model = AutoModelForCausalLM.from_pretrained(
22
- # self.model_path,
23
- # device_map="cuda",
24
- # torch_dtype="auto",
25
- # trust_remote_code=True,
26
- # )
27
- # self.tokenizer = AutoTokenizer.from_pretrained(self.model_path)
28
- # self.pipe = pipeline(
29
- # "text-generation",
30
- # model=self.model,
31
- # tokenizer=self.tokenizer,
32
- # )
33
 
34
  def _generate(self, messages):
35
- # generation_args = {
36
- # "max_new_tokens": 2000,
37
- # "return_full_text": False,
38
- # "temperature": 0.1,
39
- # "do_sample": False,
40
- # }
41
-
42
  # Use the chat_completion method
43
  response = client.chat_completion(
44
  messages=messages,
@@ -48,7 +29,6 @@ class Phi3InstructGraph:
48
  # Access the generated text
49
  generated_text = response.choices[0].message.content
50
  return generated_text
51
- # return self.pipe(messages, **generation_args)
52
 
53
  def _get_messages(self, text):
54
  context = dedent("""\n
 
18
  def __init__(self, model = "EmergentMethods/Phi-3-mini-4k-instruct-graph"):
19
 
20
  self.model_path = model
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  def _generate(self, messages):
 
 
 
 
 
 
 
23
  # Use the chat_completion method
24
  response = client.chat_completion(
25
  messages=messages,
 
29
  # Access the generated text
30
  generated_text = response.choices[0].message.content
31
  return generated_text
 
32
 
33
  def _get_messages(self, text):
34
  context = dedent("""\n