Instructions to use LR-AI-Labs/tiny-universal-NER with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use LR-AI-Labs/tiny-universal-NER with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="LR-AI-Labs/tiny-universal-NER")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("LR-AI-Labs/tiny-universal-NER") model = AutoModelForCausalLM.from_pretrained("LR-AI-Labs/tiny-universal-NER", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use LR-AI-Labs/tiny-universal-NER with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "LR-AI-Labs/tiny-universal-NER" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "LR-AI-Labs/tiny-universal-NER", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/LR-AI-Labs/tiny-universal-NER
- SGLang
How to use LR-AI-Labs/tiny-universal-NER with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "LR-AI-Labs/tiny-universal-NER" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "LR-AI-Labs/tiny-universal-NER", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "LR-AI-Labs/tiny-universal-NER" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "LR-AI-Labs/tiny-universal-NER", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use LR-AI-Labs/tiny-universal-NER with Docker Model Runner:
docker model run hf.co/LR-AI-Labs/tiny-universal-NER
File size: 3,166 Bytes
cb2b4e1 c720d49 cb2b4e1 254332b cb2b4e1 254332b c720d49 254332b 0872948 cb2b4e1 d1cd385 254332b c720d49 254332b b3c885c 254332b b3c885c 254332b 0ba446b b3c885c 655f956 254332b 655f956 254332b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | ---
license: apache-2.0
datasets:
- Universal-NER/Pile-NER-type
language:
- en
---
<div align="center">
# tiny-universal-NER
</div>
This model is finetuned from [TinyLLama](https://huggingface.co/TinyLlama/TinyLlama-1.1B-intermediate-step-1431k-3T).
It is trained on ChatGPT-generated [Pile-NER-type data](https://huggingface.co/datasets/Universal-NER/Pile-NER-type).
Check this [paper](https://arxiv.org/abs/2308.03279) for more information.
### How to use
You will need the transformers>=4.34
Do check the [TinyLlama](https://github.com/jzhang38/TinyLlama) github page for more information.
```python
# Install transformers from source - only needed for versions <= v4.34
# pip install git+https://github.com/huggingface/transformers.git
# pip install accelerate
import torch
from transformers import pipeline
pipe = pipeline("text-generation", model="LR-AI-Labs/tiny-universal-NER",
torch_dtype=torch.bfloat16, device_map="auto")
messages = [
{
"role": "system",
"content": "A virtual assistant answers questions from a user based on the provided text.",
},
{
"role": "user",
"content": "Text: VinBigData Joint Stock Company provides platform technology solutions and advanced products based on Big Data and Artificial Intelligence. With a staff of professors, doctors, and global technology experts, VinBigData is currently developing and deploying products such as ViVi virtual assistant, VinBase the comprehensive multi-cognitive artificial intelligence ecosystem, Vizone the ecosystem of smart image analysis solutions, VinDr the medical image digitization platform,..."
},
{
"role": "assistant",
"content": "I've read this text."
},
{
"role": "user",
"content": "What describes products in the text?"
}
]
prompt = pipe.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
outputs = pipe(prompt, max_new_tokens=256, do_sample=False)
print(outputs[0]["generated_text"])
# <|system|>
# A virtual assistant answers questions from a user based on the provided text.</s>
# <|user|>
# Text: The American Bank Note Company Printing Plant is a repurposed complex of three interconnected buildings in the Hunts Point neighborhood of the Bronx in New York City. The innovative Kirby, Petit & Green design was built in 1909–1911 by the American Bank Note Company on land which had previously been part of Edward G. Faile's country estate. A wide variety of financial instruments were printed there; at one point, over five million documents were produced per day, including half the securities traded on the New York Stock Exchange.</s>
# <|assistant|>
# I've read this text.</s>
# <|user|>
# What describes location in the text?</s>
# <|assistant|>
# ["ViVi", "VinBase", "Vizone", "VinDr"]
```
### Note: Inferences are based on one entity type at a time. For multiple entity types, create separate instances for each type.
## License
This model and its associated data are released under the [CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/) license. They are primarily used for research purposes. |