RichardErkhov commited on
Commit
ddb1e25
·
verified ·
1 Parent(s): b74d070

uploaded readme

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