πŸ“‹ Model Description

Quantization made by Richard Erkhov.

Github

Discord

Request more models

NuExtract-tiny-v1.5 - GGUF

  • Model creator: https://huggingface.co/numind/
  • Original model: https://huggingface.co/numind/NuExtract-tiny-v1.5/

NameQuant methodSize
NuExtract-tiny-v1.5.Q2K.ggufQ2K0.32GB
NuExtract-tiny-v1.5.IQ3XS.ggufIQ3XS0.32GB
NuExtract-tiny-v1.5.IQ3S.ggufIQ3S0.32GB
NuExtract-tiny-v1.5.Q3KS.ggufQ3K_S0.32GB
NuExtract-tiny-v1.5.IQ3M.ggufIQ3M0.32GB
NuExtract-tiny-v1.5.Q3K.ggufQ3K0.33GB
NuExtract-tiny-v1.5.Q3KM.ggufQ3K_M0.33GB
NuExtract-tiny-v1.5.Q3KL.ggufQ3K_L0.34GB
NuExtract-tiny-v1.5.IQ4XS.ggufIQ4XS0.33GB
NuExtract-tiny-v1.5.Q40.ggufQ400.33GB
NuExtract-tiny-v1.5.IQ4NL.ggufIQ4NL0.33GB
NuExtract-tiny-v1.5.Q4KS.ggufQ4K_S0.36GB
NuExtract-tiny-v1.5.Q4K.ggufQ4K0.37GB
NuExtract-tiny-v1.5.Q4KM.ggufQ4K_M0.37GB
NuExtract-tiny-v1.5.Q41.ggufQ410.35GB
NuExtract-tiny-v1.5.Q50.ggufQ500.37GB
NuExtract-tiny-v1.5.Q5KS.ggufQ5K_S0.38GB
NuExtract-tiny-v1.5.Q5K.ggufQ5K0.39GB
NuExtract-tiny-v1.5.Q5KM.ggufQ5K_M0.39GB
NuExtract-tiny-v1.5.Q51.ggufQ510.39GB
NuExtract-tiny-v1.5.Q6K.ggufQ6K0.47GB
NuExtract-tiny-v1.5.Q80.ggufQ800.49GB

Original model description:



license: mit
language:
  • multilingual

tags:
  • nlp

base_model: Qwen/Qwen2.5-0.5B
pipeline_tag: text-generation

NuExtract-tiny-v1.5 by NuMind πŸ”₯

NuExtract-tiny-v1.5 is a fine-tuning of Qwen/Qwen2.5-0.5B, trained on a private high-quality dataset for structured information extraction. It supports long documents and several languages (English, French, Spanish, German, Portuguese, and Italian).
To use the model, provide an input text and a JSON template describing the information you need to extract.

Note: This model is trained to prioritize pure extraction, so in most cases all text generated by the model is present as is in the original text.

We also provide a 3.8B version which is based on Phi-3.5-mini-instruct: NuExtract-v1.5

Check out the blog post.

Try the 3.8B model here: Playground

Benchmark

Zero-shot performance (English):



Few-shot fine-tuning:



Usage

To use the model:

import json
from transformers import AutoModelForCausalLM, AutoTokenizer

def predictNuExtract(model, tokenizer, texts, template, batchsize=1, maxlength=10000, maxnewtokens=4_000):
template = json.dumps(json.loads(template), indent=4)
prompts = [f"""<|input|>\n### Template:\n{template}\n### Text:\n{text}\n\n<|output|>""" for text in texts]

outputs = []
with torch.no_grad():
for i in range(0, len(prompts), batch_size):
batchprompts = prompts[i:i+batchsize]
batchencodings = tokenizer(batchprompts, returntensors="pt", truncation=True, padding=True, maxlength=max_length).to(model.device)

predids = model.generate(batchencodings, maxnewtokens=maxnewtokens)
outputs += tokenizer.batchdecode(predids, skipspecialtokens=True)

return [output.split("<|output|>")[1] for output in outputs]

model_name = "numind/NuExtract-tiny-v1.5"
device = "cuda"
model = AutoModelForCausalLM.frompretrained(modelname, torchdtype=torch.bfloat16, trustremote_code=True).to(device).eval()
tokenizer = AutoTokenizer.frompretrained(modelname, trustremotecode=True)

text = """We introduce Mistral 7B, a 7–billion-parameter language model engineered for
superior performance and efficiency. Mistral 7B outperforms the best open 13B
model (Llama 2) across all evaluated benchmarks, and the best released 34B
model (Llama 1) in reasoning, mathematics, and code generation. Our model
leverages grouped-query attention (GQA) for faster inference, coupled with sliding
window attention (SWA) to effectively handle sequences of arbitrary length with a
reduced inference cost. We also provide a model fine-tuned to follow instructions,
Mistral 7B – Instruct, that surpasses Llama 2 13B – chat model both on human and
automated benchmarks. Our models are released under the Apache 2.0 license.
Code: <https://github.com/mistralai/mistral-src>
Webpage: <https://mistral.ai/news/announcing-mistral-7b/>"""

template = """{
"Model": {
"Name": "",
"Number of parameters": "",
"Number of max token": "",
"Architecture": []
},
"Usage": {
"Use case": [],
"Licence": ""
}
}"""

prediction = predict_NuExtract(model, tokenizer, [text], template)[0]
print(prediction)

Sliding window prompting:

import json

MAXINPUTSIZE = 20_000
MAXNEWTOKENS = 6000

def cleanjsontext(text):
text = text.strip()
text = text.replace("\#", "#").replace("\&", "&")
return text

def predict_chunk(text, template, current, model, tokenizer):
current = cleanjsontext(current)

input_llm = f"<|input|>\n### Template:\n{template}\n### Current:\n{current}\n### Text:\n{text}\n\n<|output|>" + "{"
inputids = tokenizer(inputllm, returntensors="pt", truncation=True, maxlength=MAXINPUTSIZE).to("cuda")
output = tokenizer.decode(model.generate(inputids, maxnewtokens=MAXNEWTOKENS)[0], skipspecial_tokens=True)

return cleanjsontext(output.split("<|output|>")[1])

def splitdocument(document, windowsize, overlap):
tokens = tokenizer.tokenize(document)
print(f"\tLength of document: {len(tokens)} tokens")

chunks = []
if len(tokens) > window_size:
for i in range(0, len(tokens), window_size-overlap):
print(f"\t{i} to {i + len(tokens[i:i + window_size])}")
chunk = tokenizer.converttokenstostring(tokens[i:i + windowsize])
chunks.append(chunk)

if i + len(tokens[i:i + window_size]) >= len(tokens):
break
else:
chunks.append(document)
print(f"\tSplit into {len(chunks)} chunks")

return chunks

def handlebrokenoutput(pred, prev):
try:
if all([(v in ["", []]) for v in json.loads(pred).values()]):
# if empty json, return previous
pred = prev
except:
# if broken json, return previous
pred = prev

return pred

def slidingwindowprediction(text, template, model, tokenizer, window_size=4000, overlap=128):
# split text into chunks of n tokens
tokens = tokenizer.tokenize(text)
chunks = splitdocument(text, windowsize, overlap)

# iterate over text chunks
prev = template
for i, chunk in enumerate(chunks):
print(f"Processing chunk {i}...")
pred = predict_chunk(chunk, template, prev, model, tokenizer)

# handle broken output
pred = handlebrokenoutput(pred, prev)

# iterate
prev = pred

return pred

πŸ“‚ GGUF File List

πŸ“ Filename πŸ“¦ Size ⚑ Download
NuExtract-tiny-v1.5.IQ3_M.gguf
LFS Q3
326.87 MB Download
NuExtract-tiny-v1.5.IQ3_S.gguf
LFS Q3
322.92 MB Download
NuExtract-tiny-v1.5.IQ3_XS.gguf
LFS Q3
322.92 MB Download
NuExtract-tiny-v1.5.IQ4_NL.gguf
LFS Q4
337.89 MB Download
NuExtract-tiny-v1.5.IQ4_XS.gguf
LFS Q4
335.16 MB Download
NuExtract-tiny-v1.5.Q2_K.gguf
LFS Q2
322.92 MB Download
NuExtract-tiny-v1.5.Q3_K.gguf
LFS Q3
339 MB Download
NuExtract-tiny-v1.5.Q3_K_L.gguf
LFS Q3
352.25 MB Download
NuExtract-tiny-v1.5.Q3_K_M.gguf
LFS Q3
339 MB Download
NuExtract-tiny-v1.5.Q3_K_S.gguf
LFS Q3
322.59 MB Download
NuExtract-tiny-v1.5.Q4_0.gguf
Recommended LFS Q4
335.84 MB Download
NuExtract-tiny-v1.5.Q4_1.gguf
LFS Q4
357.17 MB Download
NuExtract-tiny-v1.5.Q4_K.gguf
LFS Q4
379.38 MB Download
NuExtract-tiny-v1.5.Q4_K_M.gguf
LFS Q4
379.38 MB Download
NuExtract-tiny-v1.5.Q4_K_S.gguf
LFS Q4
367.61 MB Download
NuExtract-tiny-v1.5.Q5_0.gguf
LFS Q5
378.5 MB Download
NuExtract-tiny-v1.5.Q5_1.gguf
LFS Q5
399.83 MB Download
NuExtract-tiny-v1.5.Q5_K.gguf
LFS Q5
400.63 MB Download
NuExtract-tiny-v1.5.Q5_K_M.gguf
LFS Q5
400.63 MB Download
NuExtract-tiny-v1.5.Q5_K_S.gguf
LFS Q5
393.59 MB Download
NuExtract-tiny-v1.5.Q6_K.gguf
LFS Q6
482.31 MB Download
NuExtract-tiny-v1.5.Q8_0.gguf
LFS Q8
506.47 MB Download