mav23 commited on
Commit
cb406cd
1 Parent(s): 1c5fe75

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. .gitattributes +1 -0
  2. README.md +98 -0
  3. nuextract.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
+ nuextract.Q4_0.gguf filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ language:
4
+ - en
5
+ base_model: microsoft/Phi-3-mini-4k-instruct
6
+ ---
7
+ # Structure Extraction Model by NuMind 🔥
8
+
9
+ NuExtract is a version of [phi-3-mini](https://huggingface.co/microsoft/Phi-3-mini-4k-instruct), fine-tuned on a private high-quality synthetic dataset for information extraction.
10
+ To use the model, provide an input text (less than 2000 tokens) and a JSON template describing the information you need to extract.
11
+
12
+ Note: This model is purely extractive, so all text output by the model is present as is in the original text. You can also provide an example of output formatting to help the model understand your task more precisely.
13
+
14
+ Try it here: https://huggingface.co/spaces/numind/NuExtract
15
+
16
+ We also provide a tiny(0.5B) and large(7B) version of this model: [NuExtract-tiny](https://huggingface.co/numind/NuExtract-tiny) and [NuExtract-large](https://huggingface.co/numind/NuExtract-large)
17
+
18
+ **Checkout other models by NuMind:**
19
+ * SOTA Zero-shot NER Model [NuNER Zero](https://huggingface.co/numind/NuNER_Zero)
20
+ * SOTA Multilingual Entity Recognition Foundation Model: [link](https://huggingface.co/numind/entity-recognition-multilingual-general-sota-v1)
21
+ * SOTA Sentiment Analysis Foundation Model: [English](https://huggingface.co/numind/generic-sentiment-v1), [Multilingual](https://huggingface.co/numind/generic-sentiment-multi-v1)
22
+
23
+
24
+ ## Benchmark
25
+
26
+ Benchmark 0 shot (will release soon):
27
+
28
+ <p align="left">
29
+ <img src="result.png" width="600">
30
+ </p>
31
+
32
+ Benchmark fine-tunning (see blog post):
33
+
34
+ <p align="left">
35
+ <img src="result_ft.png" width="600">
36
+ </p>
37
+
38
+
39
+ ## Usage
40
+
41
+ To use the model:
42
+
43
+ ```python
44
+ import json
45
+ from transformers import AutoModelForCausalLM, AutoTokenizer
46
+
47
+
48
+ def predict_NuExtract(model, tokenizer, text, schema, example=["", "", ""]):
49
+ schema = json.dumps(json.loads(schema), indent=4)
50
+ input_llm = "<|input|>\n### Template:\n" + schema + "\n"
51
+ for i in example:
52
+ if i != "":
53
+ input_llm += "### Example:\n"+ json.dumps(json.loads(i), indent=4)+"\n"
54
+
55
+ input_llm += "### Text:\n"+text +"\n<|output|>\n"
56
+ input_ids = tokenizer(input_llm, return_tensors="pt",truncation = True, max_length=4000).to("cuda")
57
+
58
+ output = tokenizer.decode(model.generate(**input_ids)[0], skip_special_tokens=True)
59
+ return output.split("<|output|>")[1].split("<|end-output|>")[0]
60
+
61
+
62
+ # We recommend using bf16 as it results in negligable performance loss
63
+ model = AutoModelForCausalLM.from_pretrained("numind/NuExtract", torch_dtype=torch.bfloat16, trust_remote_code=True)
64
+ tokenizer = AutoTokenizer.from_pretrained("numind/NuExtract", trust_remote_code=True)
65
+
66
+ model.to("cuda")
67
+
68
+ model.eval()
69
+
70
+ text = """We introduce Mistral 7B, a 7–billion-parameter language model engineered for
71
+ superior performance and efficiency. Mistral 7B outperforms the best open 13B
72
+ model (Llama 2) across all evaluated benchmarks, and the best released 34B
73
+ model (Llama 1) in reasoning, mathematics, and code generation. Our model
74
+ leverages grouped-query attention (GQA) for faster inference, coupled with sliding
75
+ window attention (SWA) to effectively handle sequences of arbitrary length with a
76
+ reduced inference cost. We also provide a model fine-tuned to follow instructions,
77
+ Mistral 7B – Instruct, that surpasses Llama 2 13B – chat model both on human and
78
+ automated benchmarks. Our models are released under the Apache 2.0 license.
79
+ Code: https://github.com/mistralai/mistral-src
80
+ Webpage: https://mistral.ai/news/announcing-mistral-7b/"""
81
+
82
+ schema = """{
83
+ "Model": {
84
+ "Name": "",
85
+ "Number of parameters": "",
86
+ "Number of max token": "",
87
+ "Architecture": []
88
+ },
89
+ "Usage": {
90
+ "Use case": [],
91
+ "Licence": ""
92
+ }
93
+ }"""
94
+
95
+ prediction = predict_NuExtract(model, tokenizer, text, schema, example=["","",""])
96
+ print(prediction)
97
+
98
+ ```
nuextract.Q4_0.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9fafbd3216b315e1a77e3148371233c3ff6e7d1516a7e352db15eb7a920c92b6
3
+ size 2176176576