shreyaspimpalgaonkar commited on
Commit
4cd16ae
1 Parent(s): 4099389

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +5 -16
README.md CHANGED
@@ -14,8 +14,6 @@ It is a finetuned version of Phi3-3.8B on a high quality proprietary dataset con
14
 
15
  ### Model Description
16
 
17
-
18
-
19
  - **Developed by:** [https://www.SciPhi.ai](SciPhi.ai)
20
 
21
  ### Model Sources
@@ -32,7 +30,6 @@ It is a finetuned version of Phi3-3.8B on a high quality proprietary dataset con
32
  import json
33
  from transformers import AutoModelForCausalLM, AutoTokenizer
34
 
35
-
36
  def triplextract(model, tokenizer, text, entity_types, predicates):
37
 
38
  input_format = """
@@ -46,29 +43,21 @@ def triplextract(model, tokenizer, text, entity_types, predicates):
46
  {text}
47
  """
48
 
49
- message = input_format.format(entity_types = json.dumps({"entity_types": entity_types}), predicates = json.dumps({"predicates": predicates}), text = text)
 
 
 
50
 
51
  messages = [{'role': 'user', 'content': message}]
52
  input_ids = tokenizer.apply_chat_template(messages, add_generation_prompt = True, return_tensors="pt").to("cuda")
53
  output = tokenizer.decode(model.generate(input_ids=input_ids, max_length=2048)[0], skip_special_tokens=True)
54
- print(output)
55
  return output
56
 
57
-
58
-
59
  tokenizer = AutoTokenizer.from_pretrained("sciphi/triplex", trust_remote_code=True)
60
- model = AutoModelForCausalLM.from_pretrained("sciphi/triplex", trust_remote_code=True)
61
-
62
-
63
- model.to("cuda")
64
-
65
- model.eval()
66
-
67
 
68
  entity_types = [ "LOCATION", "POSITION", "DATE", "CITY", "COUNTRY", "NUMBER" ]
69
-
70
  predicates = [ "POPULATION", "AREA" ]
71
-
72
  text = """
73
  San Francisco,[24] officially the City and County of San Francisco, is a commercial, financial, and cultural center in Northern California.
74
 
 
14
 
15
  ### Model Description
16
 
 
 
17
  - **Developed by:** [https://www.SciPhi.ai](SciPhi.ai)
18
 
19
  ### Model Sources
 
30
  import json
31
  from transformers import AutoModelForCausalLM, AutoTokenizer
32
 
 
33
  def triplextract(model, tokenizer, text, entity_types, predicates):
34
 
35
  input_format = """
 
43
  {text}
44
  """
45
 
46
+ message = input_format.format(
47
+ entity_types = json.dumps({"entity_types": entity_types}),
48
+ predicates = json.dumps({"predicates": predicates}),
49
+ text = text)
50
 
51
  messages = [{'role': 'user', 'content': message}]
52
  input_ids = tokenizer.apply_chat_template(messages, add_generation_prompt = True, return_tensors="pt").to("cuda")
53
  output = tokenizer.decode(model.generate(input_ids=input_ids, max_length=2048)[0], skip_special_tokens=True)
 
54
  return output
55
 
56
+ model = AutoModelForCausalLM.from_pretrained("sciphi/triplex", trust_remote_code=True).to('cuda').eval()
 
57
  tokenizer = AutoTokenizer.from_pretrained("sciphi/triplex", trust_remote_code=True)
 
 
 
 
 
 
 
58
 
59
  entity_types = [ "LOCATION", "POSITION", "DATE", "CITY", "COUNTRY", "NUMBER" ]
 
60
  predicates = [ "POPULATION", "AREA" ]
 
61
  text = """
62
  San Francisco,[24] officially the City and County of San Francisco, is a commercial, financial, and cultural center in Northern California.
63