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