Alexandre-Numind commited on
Commit
fac7b94
1 Parent(s): 01c3b83

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +69 -0
README.md ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SOTA Structure Extraction Model by NuMind 🔥
2
+
3
+ NuExtract is a fine-tuned version of phi-3-small, on a private high-quality syntactic dataset for information extraction. To use the model, provide an input text (less than 2000 tokens) and a JSON schema describing the information you need to extract. This model is purely extractive, so each information output by the model is present as it is in the text. You can also provide an example of output to help the model understand your task more precisely.
4
+
5
+ **Checkout other models by NuMind:**
6
+ * SOTA Zero-shot NER Model [NuNER Zero](https://huggingface.co/numind/NuNER_Zero)
7
+ * SOTA Multilingual Entity Recognition Foundation Model: [link](https://huggingface.co/numind/entity-recognition-multilingual-general-sota-v1)
8
+ * SOTA Sentiment Analysis Foundation Model: [English](https://huggingface.co/numind/generic-sentiment-v1), [Multilingual](https://huggingface.co/numind/generic-sentiment-multi-v1)
9
+
10
+
11
+ ## Usage
12
+
13
+ To use the model:
14
+
15
+ ```python
16
+
17
+ from transformers import AutoModelForCausalLM, AutoTokenizer
18
+
19
+
20
+ def predict_NuExtract(model,tokenizer,text, schema,example = ["","",""]):
21
+ schema = json.dumps(json.loads(schema), indent=4)
22
+ input_llm = "<|input|>\n### Template:\n" + schema + "\n"
23
+ for i in example:
24
+ if i != "":
25
+ input_llm += "### Example:\n"+ json.dumps(json.loads(i), indent=4)+"\n"
26
+
27
+ input_llm += "### Text:\n"+text +"\n<|output|>\n"
28
+ input_ids = tokenizer(input_llm, return_tensors="pt",truncation = True, max_length = 4000).to("cuda")
29
+
30
+ output = tokenizer.decode(model.generate(**input_ids)[0], skip_special_tokens=True)
31
+ return output.split("<|output|>")[1].split("<|end-output|>")[0]
32
+
33
+
34
+ model = AutoModelForCausalLM.from_pretrained("numind/NuExtract", trust_remote_code=True)
35
+ tokenizer = AutoTokenizer.from_pretrained("numind/NuExtract", trust_remote_code=True)
36
+
37
+ #model.to("cuda")
38
+
39
+ model.eval()
40
+
41
+ text = """We introduce Mistral 7B, a 7–billion-parameter language model engineered for
42
+ superior performance and efficiency. Mistral 7B outperforms the best open 13B
43
+ model (Llama 2) across all evaluated benchmarks, and the best released 34B
44
+ model (Llama 1) in reasoning, mathematics, and code generation. Our model
45
+ leverages grouped-query attention (GQA) for faster inference, coupled with sliding
46
+ window attention (SWA) to effectively handle sequences of arbitrary length with a
47
+ reduced inference cost. We also provide a model fine-tuned to follow instructions,
48
+ Mistral 7B – Instruct, that surpasses Llama 2 13B – chat model both on human and
49
+ automated benchmarks. Our models are released under the Apache 2.0 license.
50
+ Code: https://github.com/mistralai/mistral-src
51
+ Webpage: https://mistral.ai/news/announcing-mistral-7b/"""
52
+
53
+ schema = """{
54
+ "Model": {
55
+ "Name": "",
56
+ "Number of parameters": "",
57
+ "Number of token": "",
58
+ "Architecture": []
59
+ },
60
+ "Usage": {
61
+ "Use case": [],
62
+ "Licence": ""
63
+ }
64
+ }"""
65
+
66
+ prediction = predict_NuExtract(model,tokenizer,text, schema,example = ["","",""])
67
+
68
+
69
+ ```