Views
No views yet
git clone --single-branch --branch 6_5 https://huggingface.co/numind_-_NuExtract-tiny-exl2 NuExtract-tiny-6_5pip3 install huggingface-hub--revision parameter. For example, to download the 6.5 bpw branch:
Linux:huggingface-cli download numind_-_NuExtract-tiny-exl2 --revision 6_5 --local-dir NuExtract-tiny-6_5 --local-dir-use-symlinks Falsehuggingface-cli download numind_-_NuExtract-tiny-exl2 --revision 6_5 --local-dir NuExtract-tiny-6.5 --local-dir-use-symlinks False⚠️ NOTE: This model is out-dated. Find the updated version here
1import json
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4
5def predict_NuExtract(model, tokenizer, text, schema, example=["","",""]):
6 schema = json.dumps(json.loads(schema), indent=4)
7 input_llm = "<|input|>\n### Template:\n" + schema + "\n"
8 for i in example:
9 if i != "":
10 input_llm += "### Example:\n"+ json.dumps(json.loads(i), indent=4)+"\n"
11
12 input_llm += "### Text:\n"+text +"\n<|output|>\n"
13 input_ids = tokenizer(input_llm, return_tensors="pt", truncation=True, max_length=4000).to("cuda")
14
15 output = tokenizer.decode(model.generate(**input_ids)[0], skip_special_tokens=True)
16 return output.split("<|output|>")[1].split("<|end-output|>")[0]
17
18
19model = AutoModelForCausalLM.from_pretrained("numind/NuExtract-tiny", trust_remote_code=True)
20tokenizer = AutoTokenizer.from_pretrained("numind/NuExtract-tiny", trust_remote_code=True)
21
22model.to("cuda")
23
24model.eval()
25
26text = """We introduce Mistral 7B, a 7–billion-parameter language model engineered for
27superior performance and efficiency. Mistral 7B outperforms the best open 13B
28model (Llama 2) across all evaluated benchmarks, and the best released 34B
29model (Llama 1) in reasoning, mathematics, and code generation. Our model
30leverages grouped-query attention (GQA) for faster inference, coupled with sliding
31window attention (SWA) to effectively handle sequences of arbitrary length with a
32reduced inference cost. We also provide a model fine-tuned to follow instructions,
33Mistral 7B – Instruct, that surpasses Llama 2 13B – chat model both on human and
34automated benchmarks. Our models are released under the Apache 2.0 license.
35Code: https://github.com/mistralai/mistral-src
36Webpage: https://mistral.ai/news/announcing-mistral-7b/"""
37
38schema = """{
39 "Model": {
40 "Name": "",
41 "Number of parameters": "",
42 "Number of max token": "",
43 "Architecture": []
44 },
45 "Usage": {
46 "Use case": [],
47 "Licence": ""
48 }
49}"""
50
51prediction = predict_NuExtract(model, tokenizer, text, schema, example=["","",""])
52print(prediction)
53