ubiai deep learning
UniNER-7B

UniNER-7B Definition

September 9th, 2024

In today’s data-driven world, extracting meaningful information from massive amounts of unstructured text has become critical. Named Entity Recognition (NER) is a cornerstone of natural language processing (NLP) used to identify and classify key entities (like people, organizations, locations, etc.) in text. Traditional NER systems, however, often struggle with language diversity, domain specificity, and edge cases. Enter Universal NER a breakthrough approach that aims to transcend these limitations by creating models capable of understanding and identifying entities across languages, domains, and contexts.

UniNER-7B

What is NER ?

Named Entity Recognition (NER) is a key technique in natural language processing (NLP) that involves identifying and categorizing entities such as names of people, organizations, locations, dates, and more within unstructured text. The goal is to extract meaningful pieces of
information and classify them into predefined categories, helping machines to better understand and analyze the content of texts. NER is widely used in applications like search engines, information retrieval, and data extraction, making it an essential component of AI systems that process large volumes of text.

What is Universal NER?

Universal NER builds on the foundations of traditional NER but takes it several steps further. Instead of being confined to a single language or domain, Universal NER models are designed to be cross-lingual and domain-agnostic, meaning they can operate across different languages and domains with minimal retraining. It is a significant shift towards creating a more generalized understanding of how entities are represented in text, independent of their specific contexts. This ambitious approach incorporates advanced machine-learning techniques, including transfer learning, zero-shot learning, and multilingual embeddings, to make it adaptable and scalable across global datasets. Universal NER opens up possibilities for businesses and organizations working in multilingual environments, where traditional models struggle with translation discrepancies, contextual nuances, and specialized vocabularies.

Why Do We Need Universal NER?

While traditional NER models have performed well in specific languages or domains, they require large, annotated datasets for each application. A model trained to extract entities from English financial reports, for instance, may perform poorly on German medical texts. This lack of flexibility is inefficient and costly. Moreover, the world is rapidly becoming more connected, with data flowing across languages and industries. In global applications like news aggregation, social media monitoring, and e-commerce, relying on monolingual or domain-specific models becomes impractical. Universal NER addresses these challenges by offering a single model that can perform well across multiple scenarios without requiring extensive retraining.

Universal NER Workflow

The core of Universal NER lies in its ability to share knowledge across languages and domains. Here’s how it works:

 

1. Multilingual Embeddings:

Universal NER leverages multilingual embeddings like mBERT or XLM-RoBERTa, which are pre-trained on massive corpora in multiple languages. These embeddings allow the model to represent words and phrases in a shared vector space, regardless of language.

 

2. Transfer Learning:

Using transfer learning, Universal NER models are trained on one or more source tasks and then fine-tuned on specific target tasks. The knowledge acquired from the source tasks can be transferred to new, unseen domains or languages, drastically reducing the need for large annotated datasets.

 

3. Zero-Shot Learning:

A cutting-edge feature of Universal NER is its zero-shot capability, meaning the model can recognize and classify entities in new languages or domains without being explicitly trained on them. For example, a Universal NER model trained primarily in English could still recognize French entities with little to no additional training.

 

4. Self-Supervised Learning:

Another important component of Universal NER is self-supervised learning, where models learn to predict parts of the input data based on other parts. This technique helps Universal NER systems become better at generalizing across different contexts by learning from patterns in unannotated text data.

 

5. Entity Linking and Disambiguation:

Universal NER doesn’t stop at merely identifying entities; it also integrates entity linking and disambiguation. Once an entity is detected, the model links it to a knowledge base (like Wikipedia or Wikidata) and resolves ambiguities, ensuring that “Washington” refers to either the U.S. state or the capital city depending on the context.

UniNER-7B Model Overview

The UniNER-7B model is the top-performing model from the Universal NER project, trained on a rich mix of data sources: Pile-NER-type and Pile-NER-definition data generated by ChatGPT and 40 supervised datasets from the Universal NER benchmark. This powerful model surpasses comparable NER models like wiki neural-multilingual-ner and bert-base-NER, making it a highly effective solution for named entity recognition tasks.

Model Inputs and Outputs

The UniNER-7B-all model is a text-to-text AI system designed for named entity recognition (NER) tasks. It processes a given text input and generates predictions of the entities identified within, along with their respective categories.

• Inputs:

Text: The model accepts raw text as input, which can range from a simple sentence to more complex paragraphs or documents. This input can be sourced from various domains such as news articles, research papers, legal documents, or social media posts. The task of the model is to analyze the provided text and identify relevant named entities, regardless of the domain or context.

• Outputs:

Entity Predictions: After processing the input, the model generates a list of predictions, highlighting the named entities present in the text. These entities are then classified into predefined categories such as person, location, organization, date.. The output provides not just the entity itself, but also its type, making it a highly valuable tool for text analysis, content extraction, and information retrieval in various applications like search engines, chatbots, and document processing systems.

Model Inputs and Outputs

The UniNER-7B model offers several advantages, here are some key benefits:

 

1. High Accuracy:
The UniNER-7B model is optimized for recognizing and classifying various entity types, such as people, organizations, locations, and more. Its performance, especially for large datasets and diverse domains, makes it effective at identifying entities with high accuracy.

 

2. Multilingual Capability:
UniNER-7B is likely capable of handling multiple languages or has been trained on multilingual datasets, allowing it to recognize entities across different languages, which is beneficial for global applications.

 

3. Versatility Across Domains:

It can be applied across various domains such as healthcare, legal, finance, and e-commerce, where accurate entity recognition is critical. This makes it adaptable for specialized tasks beyond general-purpose NER.

 

4. Pretrained on Large-scale Data:
Being a large model, UniNER-7B has been pre-trained on massive datasets, allowing it to have a strong general understanding of language and context. This improves its performance in recognizing entities in complex or ambiguous contexts.

Code Example

				
					from langchain import HuggingFacePipeline import transformers import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
model = "Universal-NER/UniNER-7B-all*
tokenizer - AutoTokenizer.from_pretrained(model)
pipeline = transformers-pipeline(
    "text-generation", #task 
    model-model, 
    tokenizer-tokenizer, 
    trust_remote_code-True, 
    device_map="auto" 
    torch_dtype-torch.bfloat1,
    max_length-1000, 
    do_sample-True, 
    top_k=10, 
    num_return_sequences=1, 
    eos_token_id-tokenizer.es_token_id,
				
			

We start by developing a text generation pipeline using the Hugging Face transformers library with the UniNER-7B-all model. It loads the model and tokenizer, sets up the pipeline for text generation, and configures various parameters like sampling options, maximum output length, and device management to optimize performance. The pipeline is designed to generate text with controlled diversity, using advanced settings like top-k sampling and bfloat16 precision to reduce memory usage while ensuring efficient inference.

				
					llm = HuggingFacePipeline(pipeline - pipeline, model_kwargs = ('temperature':0})
				
			

After we initialize a Hugging Face pipeline with the UniNER-7B model, we set it to generate deterministic outputs by using a temperature of 0, meaning it will always choose the most likely prediction without randomness

				
					text="Tesla, Inc. is an American multinational automotive and clean energy company headquartered in Palo Alto, California. Fou
entity_type="Person"
print (11m _chain.run({"input_text":text, "entity_type" :entity_type))
				
			

In this code, we evaluate the performance of the UniNER-7B model by testing its ability to recognize person entities within a given input text allowing us to assess its prediction accuracy.

Conclusion

Universal NER represents a leap forward in how we extract and interpret information from global datasets. Its ability to break language and domain barriers offers a future where entity recognition is seamless and scalable across borders and industries. Universal NER is a powerful step toward more inclusive, efficient, and flexible NLP systems, with the potential to transform a wide range of applications in the digital age.

Unlocking the Power of SLM Distillation for Higher Accuracy and Lower Cost​

How to make smaller models as intelligent as larger ones

Recording Date : March 7th, 2025

Unlock the True Potential of LLMs !

Harnessing AI Agents for Advanced Fraud Detection

How AI Agents Are Revolutionizing Fraud Detection

Recording Date : February 13th, 2025

Unlock the True Potential of LLMs !

Thank you for registering!

Check your email for the live demo details

see you on February 19th

While you’re here, discover how you can use UbiAI to fine-tune highly accurate and reliable AI models!

Thank you for registering!

Check your email for webinar details

see you on March 5th

While you’re here, discover how you can use UbiAI to fine-tune highly accurate and reliable AI models!

Fine Tuning LLMs on Your Own Dataset ​

Fine-Tuning Strategies and Practical Applications

Recording Date : January 15th, 2025

Unlock the True Potential of LLMs !