Downloads · 30 days
10
1% of all-time downloads
daisd-ai/UniNER-W4A16
UniNER-W4A16 is a machine learning model from daisd-ai. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as cc-by-nc-4.0.
This model is quantized version of Universal-NER/UniNER-7B-all.
Downloads · 30 days
10
1% of all-time downloads
All-time downloads
1.6K
Public
Parameters
6.8B
4.5 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors4.5 GB · 100%
How the weights are stored.
I326.5B · 95%
From the Hugging Face model README
This model is quantized version of Universal-NER/UniNER-7B-all.
The quantization was applied using LLM Compressor with 512 random examples from Universal-NER/Pile-NER-definition dataset.
The recipe for quantization:
recipe = [
SmoothQuantModifier(smoothing_strength=0.8),
GPTQModifier(targets="Linear", scheme="W4A16", ignore=["lm_head"]),
]
We added chat template for the tokenizer, thus it can be directly used with vLLM without any other preprocessing compered to original model.
Example:
import json
from vllm import LLM, SamplingParams
# Loading model
llm = LLM(model="daisd-ai/UniNER-W4A16")
sampling_params = SamplingParams(temperature=0, max_tokens=256)
# Define text and entities types
text = "Some long text with multiple entities"
entities_types = ["entity type 1", "entity type 2"]
# Applying tokenizer
prompts = []
for entity_type in entities_types:
messages = [
{
"role": "user",
"content": f"Text: {text}",
},
{"role": "assistant", "content": "I've read this text."},
{"role": "user", "content":f"What describes {entity_type} in the text?"},
]
prompt = self.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
prompts.append(prompt)
# Run inference
outputs = llm.generate(prompts, self.sampling_params)
outputs = [output.outputs[0].text for output in outputs]
# Results are returned is JSON format, parse it to python list
results = []
for lst in outputs:
try:
entities = list(set(json.loads(lst)))
except Exception:
entities = []
results.append(entities)