Alexandre-Numind commited on
Commit
600d2d8
1 Parent(s): d897ec4

Create README.md

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