mav23 commited on
Commit
dc3c3ad
·
verified ·
1 Parent(s): a616afa

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. .gitattributes +1 -0
  2. README.md +85 -0
  3. triplex.Q4_0.gguf +3 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ triplex.Q4_0.gguf filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-nc-sa-4.0
3
+
4
+ ---
5
+
6
+ # Triplex: a SOTA LLM for knowledge graph construction.
7
+
8
+ Knowledge graphs, like Microsoft's Graph RAG, enhance RAG methods but are expensive to build. Triplex offers a 98% cost reduction for knowledge graph creation, outperforming GPT-4 at 1/60th the cost and enabling local graph building with SciPhi's R2R.
9
+
10
+ Triplex is a finetuned version of Phi3-3.8B for creating knowledge graphs from unstructured data developed by [SciPhi.AI](https://www.sciphi.ai). It works by extracting triplets - simple statements consisting of a subject, predicate, and object - from text or other data sources.
11
+
12
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/668d8d7a2413acbd544530d1/kcUC5FDEoziMSEcjVHQ3-.png)
13
+
14
+ ## Benchmark
15
+
16
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/668d8d7a2413acbd544530d1/xsZ2UPZE5mnTFvgAsQwtl.png)
17
+
18
+ ## Usage:
19
+
20
+
21
+ - **Blog:** [https://www.sciphi.ai/blog/triplex](https://www.sciphi.ai/blog/triplex)
22
+ - **Demo:** [kg.sciphi.ai](https://kg.sciphi.ai)
23
+ - **Cookbook:** [https://r2r-docs.sciphi.ai/cookbooks/knowledge-graph](https://r2r-docs.sciphi.ai/cookbooks/knowledge-graph)
24
+ - **Python:**
25
+
26
+ ```python
27
+ import json
28
+ from transformers import AutoModelForCausalLM, AutoTokenizer
29
+
30
+ def triplextract(model, tokenizer, text, entity_types, predicates):
31
+
32
+ input_format = """Perform Named Entity Recognition (NER) and extract knowledge graph triplets from the text. NER identifies named entities of given entity types, and triple extraction identifies relationships between entities using specified predicates.
33
+
34
+ **Entity Types:**
35
+ {entity_types}
36
+
37
+ **Predicates:**
38
+ {predicates}
39
+
40
+ **Text:**
41
+ {text}
42
+ """
43
+
44
+ message = input_format.format(
45
+ entity_types = json.dumps({"entity_types": entity_types}),
46
+ predicates = json.dumps({"predicates": predicates}),
47
+ text = text)
48
+
49
+ messages = [{'role': 'user', 'content': message}]
50
+ input_ids = tokenizer.apply_chat_template(messages, add_generation_prompt = True, return_tensors="pt").to("cuda")
51
+ output = tokenizer.decode(model.generate(input_ids=input_ids, max_length=2048)[0], skip_special_tokens=True)
52
+ return output
53
+
54
+ model = AutoModelForCausalLM.from_pretrained("sciphi/triplex", trust_remote_code=True).to('cuda').eval()
55
+ tokenizer = AutoTokenizer.from_pretrained("sciphi/triplex", trust_remote_code=True)
56
+
57
+ entity_types = [ "LOCATION", "POSITION", "DATE", "CITY", "COUNTRY", "NUMBER" ]
58
+ predicates = [ "POPULATION", "AREA" ]
59
+ text = """
60
+ San Francisco,[24] officially the City and County of San Francisco, is a commercial, financial, and cultural center in Northern California.
61
+
62
+ With a population of 808,437 residents as of 2022, San Francisco is the fourth most populous city in the U.S. state of California behind Los Angeles, San Diego, and San Jose.
63
+ """
64
+
65
+ prediction = triplextract(model, tokenizer, text, entity_types, predicates)
66
+ print(prediction)
67
+
68
+
69
+ ```
70
+
71
+ ## Commercial usage
72
+ We want Triplex to be as widely accessible as possible, but we also need to keep commercial concerns in mind as we are still an early stage organization. Research and personal usage is fine, but we are placing some restrictions on commercial usage.
73
+
74
+ The weights for the models are licensed cc-by-nc-sa-4.0, but we will waive them for any organization with under $5M USD in gross revenue in the most recent 12-month period. If you want to remove the GPL license requirements (dual-license) and/or use the weights commercially over the revenue limit, please reach out to our team at founders@sciphi.ai.
75
+
76
+ ## Citation
77
+
78
+ ```
79
+ @misc{pimpalgaonkar2024triplex,
80
+ author = {Pimpalgaonkar, Shreyas and Tremelling, Nolan and Colegrove, Owen},
81
+ title = {Triplex: a SOTA LLM for knowledge graph construction},
82
+ year = {2024},
83
+ url = {https://huggingface.co/sciphi/triplex}
84
+ }
85
+ ```
triplex.Q4_0.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1bdd53903aa05879a72b15618f61fb82955d00355dde76c295cd8bd1e01f8e43
3
+ size 2176176864